Skip to content

Commit

Permalink
Fix done.fail not passing arguments (jestjs#3241)
Browse files Browse the repository at this point in the history
* Fix done.fail context issue

* Use concat instead of spread to fix node 4
  • Loading branch information
thymikee authored and aaronabramov committed Apr 3, 2017
1 parent 6c10e2c commit 13173c9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
13 changes: 13 additions & 0 deletions packages/jest-jasmine2/src/__tests__/queueRunner-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,17 @@ describe('queueRunner', () => {
);
expect(fnTwo).toHaveBeenCalled();
});

it('calls `fail` with arguments', async () => {
const failFn = jest.fn(next => next.fail('miserably', 'failed'));
const options = {
clearTimeout,
fail: jest.fn(),
queueableFns: [{fn: failFn}],
setTimeout,
};
await queueRunner(options);

expect(options.fail).toHaveBeenCalledWith('miserably', 'failed');
});
});
2 changes: 1 addition & 1 deletion packages/jest-jasmine2/src/queueRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function queueRunner(options: Options) {
const mapper = ({fn, timeout}) => {
const promise = new Promise(resolve => {
const next = once(resolve);
next.fail = () => {
next.fail = function() {
options.fail.apply(null, arguments);
resolve();
};
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-jasmine2/src/treeProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function treeProcessor(options: Options) {
throw new Error('`node.children` is not defined.');
}
const children = node.children.map(child => executeNode(child, enabled));
return [...node.beforeAllFns, ...children, ...node.afterAllFns];
return node.beforeAllFns.concat(children).concat(node.afterAllFns);
}
}

Expand Down

0 comments on commit 13173c9

Please sign in to comment.