Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Standardise error message for validating hook functions in circus sim…
…ilar to how jasmine_light does it
  • Loading branch information
Alcedo Nathaniel De Guzman Jr committed Aug 31, 2018
commit d0c28bd03fb685e27675668aedcd3beee86126a4
10 changes: 6 additions & 4 deletions packages/jest-circus/src/__tests__/hooks_error.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ describe('hooks error throwing', () => {
test.each([['beforeEach'], ['beforeAll'], ['afterEach'], ['afterAll']])(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can change this to describe.each, then have the inner for-loop be test.each

'%s throws an error when the first argument is not a function',
fn => {
expect(() => {
circus[fn]('param');
}).toThrowError(
'Invalid first argument, param. It must be a callback function.',
['String', 1, {}, Symbol('hello'), true, null, undefined].forEach(el =>
expect(() => {
circus[fn](el);
}).toThrowError(
'Invalid first argument. It must be a callback function.',
),
);
},
);
Expand Down
4 changes: 1 addition & 3 deletions packages/jest-circus/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ const _dispatchDescribe = (blockFn, blockName, mode?: BlockMode) => {

const _addHook = (fn: HookFn, hookType: HookType, hookFn, timeout: ?number) => {
if (typeof fn !== 'function') {
throw new Error(
`Invalid first argument, ${fn}. It must be a callback function.`,
);
throw new Error(`Invalid first argument. It must be a callback function.`);
}

const asyncError = new Error();
Expand Down