-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
/
each.test.ts
63 lines (54 loc) · 2.06 KB
/
each.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
/**
* 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 * as path from 'path';
import {wrap} from 'jest-snapshot-serializer-raw';
import {extractSummary} from '../Utils';
import runJest from '../runJest';
const dir = path.resolve(__dirname, '../each');
test('works with passing tests', () => {
const result = runJest(dir, ['success.test.js']);
expect(result.exitCode).toBe(0);
});
test('shows error message when not enough arguments are supplied to tests', () => {
const result = runJest(dir, ['eachException.test.js']);
expect(result.exitCode).toBe(1);
const {rest} = extractSummary(result.stderr);
expect(wrap(rest)).toMatchSnapshot();
});
test('shows the correct errors in stderr when failing tests', () => {
const result = runJest(dir, ['failure.test.js']);
expect(result.exitCode).toBe(1);
const output = extractSummary(result.stderr)
.rest.split('\n')
.map(line => line.trimRight())
.join('\n');
expect(wrap(output)).toMatchSnapshot();
});
test('shows only the tests with .only as being ran', () => {
const result = runJest(dir, ['eachOnly.test.js']);
expect(result.exitCode).toBe(0);
const {rest} = extractSummary(result.stderr);
expect(wrap(rest)).toMatchSnapshot();
});
test('shows only the tests without .skip as being ran', () => {
const result = runJest(dir, ['eachSkip.test.js']);
const {rest} = extractSummary(result.stderr);
expect(wrap(rest)).toMatchSnapshot();
expect(result.exitCode).toBe(0);
});
test('runs only the describe.only.each tests', () => {
const result = runJest(dir, ['describeOnly.test.js']);
const {rest} = extractSummary(result.stderr);
expect(wrap(rest)).toMatchSnapshot();
expect(result.exitCode).toBe(0);
});
test('formats args with pretty format when given %p', () => {
const result = runJest(dir, ['pretty.test.js']);
const {rest} = extractSummary(result.stderr);
expect(wrap(rest)).toMatchSnapshot();
expect(result.exitCode).toBe(0);
});