Mocha Flashcards
0
Q
What directory does Mocha look for tests in?
A
/test/
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
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.
3
Q
Break up modules and methods in Mocha.
A
describe("module name", function() { describe(".methodName()", function() { ... }); });
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 }); }); });
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(...);