forked from jestjs/jest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
circusItTestError.test.ts
38 lines (32 loc) · 1.31 KB
/
circusItTestError.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import {runTest} from '../__mocks__/testUtils';
describe('error throwing', () => {
test(`doesn't throw an error with valid arguments`, () => {
expect(runTest(`test('test1', () => {});`).stderr).toEqual('');
});
test(`throws error with missing callback function`, () => {
expect(runTest(`test('test2');`).stderr).toContain(
'Missing second argument. It must be a callback function. Perhaps you want to use `test.todo` for a test placeholder.',
);
});
test(`throws an error when first argument isn't a string`, () => {
expect(runTest(`test(() => {});`).stderr).toContain(
'Invalid first argument, () => {}. It must be a string.',
);
});
test(`throws an error when callback function is not a function`, () => {
expect(runTest(`test('test4', 'test4b');`).stderr).toContain(
'Invalid second argument, test4b. It must be a callback function.',
);
});
test(`doesn't throw an error with valid arguments`, () => {
expect(runTest(`test('test4', 'test4b');`).stderr).toContain(
'Invalid second argument, test4b. It must be a callback function.',
);
});
});