- Download the gist
npm installnpm test
This would lead you to the following output:
> [email protected] test /Users/mrorz/workspace/testAsyncReduxAction
> mocha --compilers js:babel-core/register test.js
async actions
1) shall not pass
2) shall not pass
0 passing (47ms)
2 failing
1) async actions shall not pass:
Error: done() called multiple times
at Suite.<anonymous> (test.js:57:3)
at Object.<anonymous> (test.js:56:1)
at loader (node_modules/babel-core/node_modules/babel-register/lib/node.js:127:5)
at Object.require.extensions.(anonymous function) [as .js] (node_modules/babel-core/node_modules/babel-register/lib/node.js:137:7)
at Array.forEach (native)
at node.js:961:3
2) async actions shall not pass:
Error: done() called multiple times
at Suite.<anonymous> (test.js:57:3)
at Object.<anonymous> (test.js:56:1)
at loader (node_modules/babel-core/node_modules/babel-register/lib/node.js:127:5)
at Object.require.extensions.(anonymous function) [as .js] (node_modules/babel-core/node_modules/babel-register/lib/node.js:137:7)
at Array.forEach (native)
at node.js:961:3
In test.js, the first "expectedAction" triggers an assertion error. The error is caught by the catch clause inside mockStore and done(e) is invoked.
However, actionUnderTest still invokes dispatch the second time, causing done to be invoked again.
dispatch should be no-op after done() is invoked.