node.js mocha before function runs after test execution

I have moved this around so much and tried with done(), asyncand chaining then(), moving the describe() around and my latest attempt was to return a promise in the before as Async function in mocha before() is alway finished before it() spec? suggested. The console.log(‘finished!’) that indicates the tables have been created is printed way after console.log(‘starting tests’) that indicates the start of the tests. I should mention that somehow the user table is created and all the user tests works like a charm. All of my tests fail because they try to perform operations on tables that does not

Why do these sinon stubs resolve to undefined?

I’ve written a unit test for the following code and stubbed the browser methods (read: web-extension API) using Sinon (more specifically: sinon-chrome, a dated but still functioning library for my use case). The unit test: The tests fail due to both the stubbed methods returning undefined, but the Sinon docs state quite clearly that stub.resolves(value): Causes the stub to return a Promise which resolves to the provided value. When constructing the Promise, sinon uses the Promise.resolve method. You are responsible for providing a polyfill in environments which do not provide Promise. The Promise library can be overwritten using the usingPromise

Change default timeout for mocha

If we have a unit test file my-spec.js and running with mocha: The default timeout will be 2000 ms. It can be overwritten for partial test with a command line parameter: Is it possible to change the default timeout globally for all tests? i.e. the default timeout value will be different from 2000 ms when you call: Answer By default Mocha will read a file named test/mocha.opts that can contain command line arguments. So you could create such a file that contains: Whenever you run Mocha at the command line, it will read this file and set a timeout of