forked from jestjs/jest
/
filter.test.ts
53 lines (42 loc) · 1.48 KB
/
filter.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
/**
* 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 runJest from '../runJest';
describe('Dynamic test filtering', () => {
it('uses the default JSON option', () => {
const result = runJest('filter', []);
expect(result.status).toBe(0);
expect(result.stderr).toContain('1 total');
});
it('uses the CLI option', () => {
const result = runJest('filter', [
'--filter=<rootDir>/my-secondary-filter.js',
]);
expect(result.status).toBe(0);
expect(result.stderr).toContain('1 total');
});
it('ingores the filter if requested to do so', () => {
const result = runJest('filter', [
'--filter=<rootDir>/my-secondary-filter.js',
'--skipFilter',
]);
expect(result.status).toBe(0);
expect(result.stderr).toContain('2 total');
});
it('throws when you return clowny stuff', () => {
const result = runJest('filter', [
'--filter=<rootDir>/my-clowny-filter.js',
]);
expect(result.status).toBe(1);
expect(result.stderr).toContain('did not return a valid test list');
expect(result.stderr).toContain('my-clowny-filter');
});
it('will call setup on filter before filtering', () => {
const result = runJest('filter', ['--filter=<rootDir>/my-setup-filter.js']);
expect(result.status).toBe(0);
expect(result.stderr).toContain('1 total');
});
});