Mocha Flashcards

0
Q

What directory does Mocha look for tests in?

A

/test/

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
1
Q

Run mocha tests. What is the default timeout and how might you change it?

A

mocha

2 seconds is the default timeout, change via:

# 3 seconds
mocha --timeout 3000
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is Mocha and what isn’t it?

A

Mocha is a test framework. It cares about the structure of tests but not tests themselves. It is typically coupled with an assertion library.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Break up modules and methods in Mocha.

A
describe("module name", function() {
    describe(".methodName()", function() {
        ...
    });
});
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Run particular Mocha tests on a method/module

A
describe("module name", function() {
    describe(".methodName()", function() {
        it("what we are testing", function () {
            // assertion
        });
    });
});
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Run function before or after a describe(), or before or after every it():

A

Before or after describe()
describe(…
before(function() { … });
after(function() { … });

Before or after every it()
describe(...
    beforeEach(function() { ... });
    afterEach(function() { ... });
    it(...);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly