Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Oct 7, 2018
1 parent 4a077dd commit ebc0d65
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 20 deletions.
4 changes: 2 additions & 2 deletions e2e/__tests__/__snapshots__/globals.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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 supplied to 'test/it'. 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 supplied to 'test/it'. It must be a callback function. Perhaps you want to use \`test.todo\` for a test placeholder.
1 |
2 | it('it', () => {});
Expand Down
28 changes: 16 additions & 12 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,26 @@ 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.',
"Missing second argument supplied to 'test/it'. 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 supplied to 'test/it', () => {}. 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 supplied to 'test/it', test4b. It must be a callback function.",
);
});
it(`test doesn't throw an error with valid arguments`, () => {
Expand All @@ -62,24 +64,26 @@ 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.',
"Missing second argument supplied to 'test/it'. 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 supplied to 'test/it', () => {}. 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 supplied to 'test/it', test8b. It must be a callback function.",
);
});
});
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 supplied to 'test/it'. 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 supplied to 'test/it', 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 supplied to 'test/it'. 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 supplied to 'test/it', test6b. It must be a callback function.",
);
});
});
4 changes: 2 additions & 2 deletions packages/jest-jasmine2/src/jasmine/Env.js
Original file line number Diff line number Diff line change
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 supplied to 'test/it'. 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 supplied to 'test/it', ${fn}. It must be a callback function.`,
);
}
const spec = specFactory(
Expand Down

0 comments on commit ebc0d65

Please sign in to comment.