Skip to content

Commit

Permalink
remove "supplied to", we get a stack frame showing the function called
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Oct 7, 2018
1 parent 4a077dd commit d9d80e1
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 26 deletions.
6 changes: 3 additions & 3 deletions e2e/__tests__/__snapshots__/globals.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ exports[`cannot have describe with no implementation 1`] = `
"FAIL __tests__/only-constructs.test.js
● Test suite failed to run
Missing second argument supplied to 'describe'. It must be a callback function.
Missing second argument. It must be a callback function.
1 |
> 2 | describe('describe, no implementation');
Expand All @@ -48,7 +48,7 @@ exports[`cannot test with no implementation 1`] = `
"FAIL __tests__/only-constructs.test.js
● Test suite failed to run
Missing second argument supplied to 'it'. It must be a callback function. Perhaps you want to use \`test.todo\` for a test placeholder.
Missing second argument. It must be a callback function. Perhaps you want to use \`test.todo\` for a test placeholder.
1 |
2 | it('it', () => {});
Expand All @@ -75,7 +75,7 @@ exports[`cannot test with no implementation with expand arg 1`] = `
"FAIL __tests__/only-constructs.test.js
● Test suite failed to run
Missing second argument supplied to 'it'. It must be a callback function. Perhaps you want to use \`test.todo\` for a test placeholder.
Missing second argument. It must be a callback function. Perhaps you want to use \`test.todo\` for a test placeholder.
1 |
2 | it('it', () => {});
Expand Down
20 changes: 10 additions & 10 deletions packages/jest-circus/src/__tests__/circus_it_test_error.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,24 @@ describe('test/it error throwing', () => {
});
it(`it throws error with missing callback function`, () => {
expect(() => {
// $FlowFixMe: Easy, we're testing runitme errors here
// $FlowFixMe: Easy, we're testing runtime errors here
circusIt('test2');
}).toThrowError(
'Missing second argument. It must be a callback function. Perhaps you want to use `test.todo` for a test placeholder.',
);
});
it(`it throws an error when first argument isn't a string`, () => {
expect(() => {
// $FlowFixMe: Easy, we're testing runitme errors here
// $FlowFixMe: Easy, we're testing runtime errors here
circusIt(() => {});
}).toThrowError(`Invalid first argument, () => {}. It must be a string.`);
}).toThrowError('Invalid first argument, () => {}. It must be a string.');
});
it('it throws an error when callback function is not a function', () => {
expect(() => {
// $FlowFixMe: Easy, we're testing runitme errors here
// $FlowFixMe: Easy, we're testing runtime errors here
circusIt('test4', 'test4b');
}).toThrowError(
`Invalid second argument, test4b. It must be a callback function.`,
'Invalid second argument, test4b. It must be a callback function.',
);
});
it(`test doesn't throw an error with valid arguments`, () => {
Expand All @@ -62,24 +62,24 @@ describe('test/it error throwing', () => {
});
it(`test throws error with missing callback function`, () => {
expect(() => {
// $FlowFixMe: Easy, we're testing runitme errors here
// $FlowFixMe: Easy, we're testing runtime errors here
circusTest('test6');
}).toThrowError(
'Missing second argument. It must be a callback function. Perhaps you want to use `test.todo` for a test placeholder.',
);
});
it(`test throws an error when first argument isn't a string`, () => {
expect(() => {
// $FlowFixMe: Easy, we're testing runitme errors here
// $FlowFixMe: Easy, we're testing runtime errors here
circusTest(() => {});
}).toThrowError(`Invalid first argument, () => {}. It must be a string.`);
}).toThrowError('Invalid first argument, () => {}. It must be a string.');
});
it('test throws an error when callback function is not a function', () => {
expect(() => {
// $FlowFixMe: Easy, we're testing runitme errors here
// $FlowFixMe: Easy, we're testing runtime errors here
circusTest('test8', 'test8b');
}).toThrowError(
`Invalid second argument, test8b. It must be a callback function.`,
'Invalid second argument, test8b. It must be a callback function.',
);
});
});
10 changes: 5 additions & 5 deletions packages/jest-circus/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ const _dispatchDescribe = (
) => {
const asyncError = new ErrorWithStack(undefined, describeFn);
if (blockFn === undefined) {
asyncError.message = `Missing second argument supplied to 'describe'. It must be a callback function.`;
asyncError.message = `Missing second argument. It must be a callback function.`;
throw asyncError;
}
if (typeof blockFn !== 'function') {
asyncError.message = `Invalid second argument supplied to 'describe', ${blockFn}. It must be a callback function.`;
asyncError.message = `Invalid second argument, ${blockFn}. It must be a callback function.`;
throw asyncError;
}
dispatch({
Expand Down Expand Up @@ -105,18 +105,18 @@ const _addTest = (
const asyncError = new ErrorWithStack(undefined, testFn);

if (typeof testName !== 'string') {
asyncError.message = `Invalid first argument supplied to 'test/it', ${testName}. It must be a string.`;
asyncError.message = `Invalid first argument, ${testName}. It must be a string.`;

throw asyncError;
}
if (fn === undefined) {
asyncError.message =
"Missing second argument supplied to 'test/it'. It must be a callback function. Perhaps you want to use `test.todo` for a test placeholder.";
'Missing second argument. It must be a callback function. Perhaps you want to use `test.todo` for a test placeholder.';

throw asyncError;
}
if (typeof fn !== 'function') {
asyncError.message = `Invalid second argument supplied to 'test/it', ${fn}. It must be a callback function.`;
asyncError.message = `Invalid second argument, ${fn}. It must be a callback function.`;

throw asyncError;
}
Expand Down
8 changes: 4 additions & 4 deletions packages/jest-jasmine2/src/__tests__/it_test_error.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('test/it error throwing', () => {
expect(() => {
it('test1');
}).toThrowError(
"Missing second argument supplied to 'it'. It must be a callback function. Perhaps you want to use `test.todo` for a test placeholder.",
'Missing second argument. It must be a callback function. Perhaps you want to use `test.todo` for a test placeholder.',
);
});
it(`it throws an error when first argument isn't a string`, () => {
Expand All @@ -25,14 +25,14 @@ describe('test/it error throwing', () => {
expect(() => {
it('test3', 'test3b');
}).toThrowError(
"Invalid second argument supplied to 'it', test3b. It must be a callback function.",
'Invalid second argument, test3b. It must be a callback function.',
);
});
test(`test throws error with missing callback function`, () => {
expect(() => {
test('test4');
}).toThrowError(
"Missing second argument supplied to 'it'. It must be a callback function. Perhaps you want to use `test.todo` for a test placeholder.",
'Missing second argument. It must be a callback function. Perhaps you want to use `test.todo` for a test placeholder.',
);
});
test(`test throws an error when first argument isn't a string`, () => {
Expand All @@ -44,7 +44,7 @@ describe('test/it error throwing', () => {
expect(() => {
test('test6', 'test6b');
}).toThrowError(
"Invalid second argument supplied to 'it', test6b. It must be a callback function.",
'Invalid second argument, test6b. It must be a callback function.',
);
});
});
8 changes: 4 additions & 4 deletions packages/jest-jasmine2/src/jasmine/Env.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,12 +327,12 @@ export default function(j$) {
const suite = suiteFactory(description);
if (specDefinitions === undefined) {
throw new Error(
`Missing second argument supplied to 'describe'. It must be a callback function.`,
`Missing second argument. It must be a callback function.`,
);
}
if (typeof specDefinitions !== 'function') {
throw new Error(
`Invalid second argument supplied to 'describe', ${specDefinitions}. It must be a callback function.`,
`Invalid second argument, ${specDefinitions}. It must be a callback function.`,
);
}
if (specDefinitions.length > 0) {
Expand Down Expand Up @@ -466,12 +466,12 @@ export default function(j$) {
}
if (fn === undefined) {
throw new Error(
"Missing second argument supplied to 'it'. It must be a callback function. Perhaps you want to use `test.todo` for a test placeholder.",
"Missing second argument. It must be a callback function. Perhaps you want to use `test.todo` for a test placeholder.",
);
}
if (typeof fn !== 'function') {
throw new Error(
`Invalid second argument supplied to 'it', ${fn}. It must be a callback function.`,
`Invalid second argument, ${fn}. It must be a callback function.`,
);
}
const spec = specFactory(
Expand Down

0 comments on commit d9d80e1

Please sign in to comment.