forked from jestjs/jest
/
circusItFailingTestError.test.ts
72 lines (66 loc) · 2.27 KB
/
circusItFailingTestError.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/**
* 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 type {Global} from '@jest/types';
let circusIt: Global.It;
let circusTest: Global.It;
// using jest-jasmine2's 'it' to test jest-circus's 'it'. Had to differentiate
// the two with this alias.
const aliasCircusIt = () => {
const {it, test} = require('../');
circusIt = it;
circusTest = test;
};
aliasCircusIt();
describe('test/it.failing error throwing', () => {
it("it doesn't throw an error with valid arguments", () => {
expect(() => {
circusIt.failing('test1', () => {});
}).not.toThrowError();
});
it('it throws error with missing callback function', () => {
expect(() => {
circusIt.failing('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 valid", () => {
expect(() => {
circusIt.failing(() => {});
}).toThrowError(
'Invalid first argument, () => {}. It must be a named class, named function, number, or string.',
);
});
it('it throws an error when callback function is not a function', () => {
expect(() => {
circusIt.failing('test4', 'test4b');
}).toThrowError(
'Invalid second argument, test4b. It must be a callback function.',
);
});
it('test throws error with missing callback function', () => {
expect(() => {
circusTest.failing('test5');
}).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(() => {
circusTest.failing(() => {});
}).toThrowError(
'Invalid first argument, () => {}. It must be a named class, named function, number, or string.',
);
});
it('test throws an error when callback function is not a function', () => {
expect(() => {
circusTest.failing('test7', 'test8b');
}).toThrowError(
'Invalid second argument, test8b. It must be a callback function.',
);
});
});