jest-watch-typeahead 0.6.4 → 0.6.5
Sign up to get free protection for your applications and to get access to all the features.
package/build/types/Config.js
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "jest-watch-typeahead",
|
3
|
-
"version": "0.6.
|
3
|
+
"version": "0.6.5",
|
4
4
|
"main": "build/index.js",
|
5
5
|
"author": "Rogelio Guzman <rogelioguzmanh@gmail.com>",
|
6
6
|
"description": "Jest plugin for filtering by filename or test name",
|
@@ -19,7 +19,7 @@
|
|
19
19
|
"test": "jest",
|
20
20
|
"lint": "eslint .",
|
21
21
|
"prebuild": "rimraf build",
|
22
|
-
"build": "babel --extensions .js,.ts src -d build && rimraf **/*.test.{js,ts},integration",
|
22
|
+
"build": "babel --extensions .js,.ts src -d build && rimraf **/*.test.{js,ts},integration build/**/__tests__ build/test_utils",
|
23
23
|
"prepublish": "yarn build",
|
24
24
|
"format": "prettier --write \"**/*.js\" \"**/*.md\" \"**/*.ts\"",
|
25
25
|
"typecheck": "yarn tsc -p ."
|
@@ -41,7 +41,7 @@
|
|
41
41
|
"@jest/types": "^27.0.0",
|
42
42
|
"@semantic-release/changelog": "^5.0.1",
|
43
43
|
"@semantic-release/git": "^9.0.0",
|
44
|
-
"@types/jest": "^
|
44
|
+
"@types/jest": "^27.0.0",
|
45
45
|
"@types/node": "^14.6.4",
|
46
46
|
"@typescript-eslint/eslint-plugin": "^4.0.1",
|
47
47
|
"@typescript-eslint/parser": "^4.0.1",
|
@@ -1,162 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
var _jestWatcher = require("jest-watcher");
|
4
|
-
|
5
|
-
var _pluginTester = _interopRequireDefault(require("../../test_utils/pluginTester"));
|
6
|
-
|
7
|
-
var _plugin = _interopRequireDefault(require("../plugin"));
|
8
|
-
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
10
|
-
|
11
|
-
const projects = [{
|
12
|
-
config: {
|
13
|
-
rootDir: '/project'
|
14
|
-
},
|
15
|
-
testPaths: ['/project/src/foo.js', '/project/src/file-1.js']
|
16
|
-
}, {
|
17
|
-
config: {
|
18
|
-
rootDir: '/project'
|
19
|
-
},
|
20
|
-
testPaths: ['/project/src/bar.js', '/project/src/file-2.js']
|
21
|
-
}];
|
22
|
-
it('shows the correct initial state', async () => {
|
23
|
-
const {
|
24
|
-
stdout,
|
25
|
-
hookEmitter,
|
26
|
-
updateConfigAndRun,
|
27
|
-
plugin,
|
28
|
-
type
|
29
|
-
} = (0, _pluginTester.default)(_plugin.default);
|
30
|
-
hookEmitter.onFileChange({
|
31
|
-
projects
|
32
|
-
});
|
33
|
-
const runPromise = plugin.run({}, updateConfigAndRun);
|
34
|
-
expect(stdout.write.mock.calls.join('\n')).toMatchSnapshot();
|
35
|
-
type(_jestWatcher.KEYS.ENTER);
|
36
|
-
await runPromise;
|
37
|
-
});
|
38
|
-
it('can use arrows to select a specific file', async () => {
|
39
|
-
const {
|
40
|
-
stdout,
|
41
|
-
hookEmitter,
|
42
|
-
updateConfigAndRun,
|
43
|
-
plugin,
|
44
|
-
type
|
45
|
-
} = (0, _pluginTester.default)(_plugin.default);
|
46
|
-
hookEmitter.onFileChange({
|
47
|
-
projects
|
48
|
-
});
|
49
|
-
const runPromise = plugin.run({}, updateConfigAndRun);
|
50
|
-
stdout.write.mockReset();
|
51
|
-
type('f', 'i', _jestWatcher.KEYS.ARROW_DOWN, _jestWatcher.KEYS.ENTER);
|
52
|
-
expect(stdout.write.mock.calls.join('\n')).toMatchSnapshot();
|
53
|
-
await runPromise;
|
54
|
-
expect(updateConfigAndRun).toHaveBeenCalledWith({
|
55
|
-
mode: 'watch',
|
56
|
-
testPathPattern: 'src/file-1\\.js'
|
57
|
-
});
|
58
|
-
});
|
59
|
-
it('can select a specific file that includes a regexp special character', async () => {
|
60
|
-
const {
|
61
|
-
hookEmitter,
|
62
|
-
updateConfigAndRun,
|
63
|
-
plugin,
|
64
|
-
type
|
65
|
-
} = (0, _pluginTester.default)(_plugin.default);
|
66
|
-
hookEmitter.onFileChange({
|
67
|
-
projects: [{
|
68
|
-
config: {
|
69
|
-
rootDir: '/project'
|
70
|
-
},
|
71
|
-
testPaths: ['/project/src/file_(xyz).js']
|
72
|
-
}]
|
73
|
-
});
|
74
|
-
const runPromise = plugin.run({}, updateConfigAndRun);
|
75
|
-
type('x', 'y', 'z', _jestWatcher.KEYS.ARROW_DOWN, _jestWatcher.KEYS.ENTER);
|
76
|
-
await runPromise;
|
77
|
-
expect(updateConfigAndRun).toHaveBeenCalledWith({
|
78
|
-
mode: 'watch',
|
79
|
-
testPathPattern: 'src/file_\\(xyz\\)\\.js'
|
80
|
-
});
|
81
|
-
});
|
82
|
-
it('can select a pattern that matches multiple files', async () => {
|
83
|
-
const {
|
84
|
-
stdout,
|
85
|
-
hookEmitter,
|
86
|
-
updateConfigAndRun,
|
87
|
-
plugin,
|
88
|
-
type
|
89
|
-
} = (0, _pluginTester.default)(_plugin.default);
|
90
|
-
hookEmitter.onFileChange({
|
91
|
-
projects
|
92
|
-
});
|
93
|
-
const runPromise = plugin.run({}, updateConfigAndRun);
|
94
|
-
stdout.write.mockReset();
|
95
|
-
type('f', 'i', _jestWatcher.KEYS.ENTER);
|
96
|
-
expect(stdout.write.mock.calls.join('\n')).toMatchSnapshot();
|
97
|
-
await runPromise;
|
98
|
-
expect(updateConfigAndRun).toHaveBeenCalledWith({
|
99
|
-
mode: 'watch',
|
100
|
-
testPathPattern: 'fi'
|
101
|
-
});
|
102
|
-
});
|
103
|
-
it('can configure the key and prompt', async () => {
|
104
|
-
const {
|
105
|
-
plugin
|
106
|
-
} = (0, _pluginTester.default)(_plugin.default, {
|
107
|
-
config: {
|
108
|
-
key: 'l',
|
109
|
-
prompt: 'have a custom prompt'
|
110
|
-
}
|
111
|
-
});
|
112
|
-
expect(plugin.getUsageInfo()).toEqual({
|
113
|
-
key: 'l',
|
114
|
-
prompt: 'have a custom prompt'
|
115
|
-
});
|
116
|
-
});
|
117
|
-
it('file matching is case insensitive', async () => {
|
118
|
-
const {
|
119
|
-
stdout,
|
120
|
-
hookEmitter,
|
121
|
-
updateConfigAndRun,
|
122
|
-
plugin,
|
123
|
-
type
|
124
|
-
} = (0, _pluginTester.default)(_plugin.default);
|
125
|
-
hookEmitter.onFileChange({
|
126
|
-
projects
|
127
|
-
});
|
128
|
-
const runPromise = plugin.run({}, updateConfigAndRun);
|
129
|
-
type('f');
|
130
|
-
stdout.write.mockReset();
|
131
|
-
type('I');
|
132
|
-
expect(stdout.write.mock.calls.join('\n')).toMatchSnapshot();
|
133
|
-
type(_jestWatcher.KEYS.ENTER);
|
134
|
-
await runPromise;
|
135
|
-
});
|
136
|
-
it("selected file doesn't include trimming dots", async () => {
|
137
|
-
const {
|
138
|
-
hookEmitter,
|
139
|
-
updateConfigAndRun,
|
140
|
-
plugin,
|
141
|
-
type
|
142
|
-
} = (0, _pluginTester.default)(_plugin.default, {
|
143
|
-
stdout: {
|
144
|
-
columns: 40
|
145
|
-
}
|
146
|
-
});
|
147
|
-
hookEmitter.onFileChange({
|
148
|
-
projects: [{
|
149
|
-
config: {
|
150
|
-
rootDir: '/project'
|
151
|
-
},
|
152
|
-
testPaths: ['/project/src/long_name_gonna_need_trimming.js']
|
153
|
-
}]
|
154
|
-
});
|
155
|
-
const runPromise = plugin.run({}, updateConfigAndRun);
|
156
|
-
type('t', 'r', 'i', 'm', 'm', _jestWatcher.KEYS.ARROW_DOWN, _jestWatcher.KEYS.ENTER);
|
157
|
-
await runPromise;
|
158
|
-
expect(updateConfigAndRun).toHaveBeenCalledWith({
|
159
|
-
mode: 'watch',
|
160
|
-
testPathPattern: 'ong_name_gonna_need_trimming\\.js'
|
161
|
-
});
|
162
|
-
});
|
@@ -1,79 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
4
|
-
|
5
|
-
var _utils = require("../utils");
|
6
|
-
|
7
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
8
|
-
|
9
|
-
describe('trimAndFormatPath', () => {
|
10
|
-
test.each`
|
11
|
-
testPath | pad | columns
|
12
|
-
${'/project/src/gonna/fit/all.js'} | ${6} | ${80}
|
13
|
-
${'/project/src/trimmed_dir/foo.js'} | ${6} | ${20}
|
14
|
-
${'/project/src/exactly/sep_and_basename.js'} | ${6} | ${29}
|
15
|
-
${'/project/src/long_name_gonna_need_trimming.js'} | ${6} | ${40}
|
16
|
-
`('formats when testpath="$testPath", pad="$pad", and columns="$columns"', ({
|
17
|
-
testPath,
|
18
|
-
pad,
|
19
|
-
columns
|
20
|
-
}) => {
|
21
|
-
expect((0, _utils.trimAndFormatPath)(pad, {
|
22
|
-
rootDir: '/project'
|
23
|
-
}, testPath, columns)).toMatchSnapshot();
|
24
|
-
});
|
25
|
-
});
|
26
|
-
describe('formatTestNameByPattern', () => {
|
27
|
-
test.each`
|
28
|
-
testName | pattern | width
|
29
|
-
${'the test name'} | ${'the'} | ${30}
|
30
|
-
${'the test name'} | ${'the'} | ${25}
|
31
|
-
${'the test name'} | ${'the'} | ${20}
|
32
|
-
${'the test name'} | ${'the'} | ${15}
|
33
|
-
${'the test name'} | ${'the'} | ${10}
|
34
|
-
${'the test name'} | ${'the'} | ${5}
|
35
|
-
${'the test name'} | ${'test'} | ${30}
|
36
|
-
${'the test name'} | ${'test'} | ${25}
|
37
|
-
${'the test name'} | ${'test'} | ${20}
|
38
|
-
${'the test name'} | ${'test'} | ${15}
|
39
|
-
${'the test name'} | ${'test'} | ${10}
|
40
|
-
${'the test name'} | ${'test'} | ${5}
|
41
|
-
${'the test name'} | ${'name'} | ${30}
|
42
|
-
${'the test name'} | ${'name'} | ${25}
|
43
|
-
${'the test name'} | ${'name'} | ${20}
|
44
|
-
${'the test name'} | ${'name'} | ${15}
|
45
|
-
${'the test name'} | ${'name'} | ${10}
|
46
|
-
${'the test name'} | ${'name'} | ${5}
|
47
|
-
`('formats when testname="$testName", pattern="$pattern", and width="$width"', ({
|
48
|
-
testName,
|
49
|
-
pattern,
|
50
|
-
width
|
51
|
-
}) => {
|
52
|
-
expect((0, _utils.formatTestNameByPattern)(testName, pattern, width)).toMatchSnapshot();
|
53
|
-
});
|
54
|
-
});
|
55
|
-
describe('highlight', () => {
|
56
|
-
const rawPath = '/Users/janedoe/my-project/src/__tests__/utils/experimentation/entry-point/parseEntryPoint.test.js';
|
57
|
-
const pattern = 'parse';
|
58
|
-
let filePath;
|
59
|
-
/**
|
60
|
-
* Helps us test that the highlight is placed correctly when `filePath`
|
61
|
-
* contains ANSI characters from being formatted by chalk.
|
62
|
-
* Passing a plain string for `filePath` results in false negatives.
|
63
|
-
*/
|
64
|
-
|
65
|
-
const formatWithAnsi = text => _chalk.default.dim(text);
|
66
|
-
|
67
|
-
it('places highlight correctly when file path is not truncated', () => {
|
68
|
-
filePath = formatWithAnsi('__tests__/utils/experimentation/entry-point/parseEntryPoint.test.js');
|
69
|
-
expect((0, _utils.highlight)(rawPath, filePath, pattern)).toMatchInlineSnapshot(`"<dim>__tests__/utils/experimentation/entry-point/</></>parse</><dim>EntryPoint.test.js</>"`);
|
70
|
-
});
|
71
|
-
it('places highlight correctly when file path is truncated', () => {
|
72
|
-
filePath = formatWithAnsi('...tils/experimentation/entry-point/parseEntryPoint.test.js');
|
73
|
-
expect((0, _utils.highlight)(rawPath, filePath, pattern)).toMatchInlineSnapshot(`"<dim>...tils/experimentation/entry-point/</></>parse</><dim>EntryPoint.test.js</>"`);
|
74
|
-
});
|
75
|
-
it('places highlight correctly when file path has relative head', () => {
|
76
|
-
filePath = formatWithAnsi('./src/__tests__/utils/experimentation/entry-point/parseEntryPoint.test.js');
|
77
|
-
expect((0, _utils.highlight)(rawPath, filePath, pattern)).toMatchInlineSnapshot(`"<dim>./src/__tests__/utils/experimentation/entry-point/</></>parse</><dim>EntryPoint.test.js</>"`);
|
78
|
-
});
|
79
|
-
});
|
@@ -1,197 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
var _jestWatcher = require("jest-watcher");
|
4
|
-
|
5
|
-
var _pluginTester = _interopRequireDefault(require("../../test_utils/pluginTester"));
|
6
|
-
|
7
|
-
var _plugin = _interopRequireDefault(require("../plugin"));
|
8
|
-
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
10
|
-
|
11
|
-
const testResults = [{
|
12
|
-
testResults: [{
|
13
|
-
title: 'foo 1',
|
14
|
-
fullName: 'some description foo 1'
|
15
|
-
}, {
|
16
|
-
title: 'bar 1',
|
17
|
-
fullName: 'some description bar 1'
|
18
|
-
}]
|
19
|
-
}, {
|
20
|
-
testResults: [{
|
21
|
-
title: 'foo 2',
|
22
|
-
fullName: 'other description foo 2'
|
23
|
-
}, {
|
24
|
-
title: 'bar 2',
|
25
|
-
fullName: 'other description bar 2'
|
26
|
-
}]
|
27
|
-
}];
|
28
|
-
it('shows the correct initial state', async () => {
|
29
|
-
const {
|
30
|
-
stdout,
|
31
|
-
updateConfigAndRun,
|
32
|
-
plugin,
|
33
|
-
type
|
34
|
-
} = (0, _pluginTester.default)(_plugin.default);
|
35
|
-
const runPromise = plugin.run({}, updateConfigAndRun);
|
36
|
-
expect(stdout.write.mock.calls.join('\n')).toMatchSnapshot();
|
37
|
-
type(_jestWatcher.KEYS.ENTER);
|
38
|
-
await runPromise;
|
39
|
-
});
|
40
|
-
it('shows the correct message when there are no cached tests', async () => {
|
41
|
-
const {
|
42
|
-
stdout,
|
43
|
-
updateConfigAndRun,
|
44
|
-
plugin,
|
45
|
-
type
|
46
|
-
} = (0, _pluginTester.default)(_plugin.default);
|
47
|
-
const runPromise = plugin.run({}, updateConfigAndRun);
|
48
|
-
expect(stdout.write.mock.calls.join('\n')).toMatchSnapshot();
|
49
|
-
type('t', _jestWatcher.KEYS.ENTER);
|
50
|
-
await runPromise;
|
51
|
-
});
|
52
|
-
it('can use arrows to select a specific test', async () => {
|
53
|
-
const {
|
54
|
-
stdout,
|
55
|
-
hookEmitter,
|
56
|
-
updateConfigAndRun,
|
57
|
-
plugin,
|
58
|
-
type
|
59
|
-
} = (0, _pluginTester.default)(_plugin.default);
|
60
|
-
hookEmitter.onTestRunComplete({
|
61
|
-
testResults
|
62
|
-
});
|
63
|
-
const runPromise = plugin.run({}, updateConfigAndRun);
|
64
|
-
stdout.write.mockReset();
|
65
|
-
type('f', _jestWatcher.KEYS.ARROW_DOWN, _jestWatcher.KEYS.ARROW_DOWN, _jestWatcher.KEYS.ENTER);
|
66
|
-
expect(stdout.write.mock.calls.join('\n')).toMatchSnapshot();
|
67
|
-
await runPromise;
|
68
|
-
expect(updateConfigAndRun).toHaveBeenCalledWith({
|
69
|
-
mode: 'watch',
|
70
|
-
testNamePattern: '^other description foo 2$'
|
71
|
-
});
|
72
|
-
});
|
73
|
-
it('can select a pattern that matches multiple tests', async () => {
|
74
|
-
const {
|
75
|
-
stdout,
|
76
|
-
hookEmitter,
|
77
|
-
updateConfigAndRun,
|
78
|
-
plugin,
|
79
|
-
type
|
80
|
-
} = (0, _pluginTester.default)(_plugin.default);
|
81
|
-
hookEmitter.onTestRunComplete({
|
82
|
-
testResults
|
83
|
-
});
|
84
|
-
const runPromise = plugin.run({}, updateConfigAndRun);
|
85
|
-
stdout.write.mockReset();
|
86
|
-
type('f', 'o', _jestWatcher.KEYS.ENTER);
|
87
|
-
expect(stdout.write.mock.calls.join('\n')).toMatchSnapshot();
|
88
|
-
await runPromise;
|
89
|
-
expect(updateConfigAndRun).toHaveBeenCalledWith({
|
90
|
-
mode: 'watch',
|
91
|
-
testNamePattern: 'fo'
|
92
|
-
});
|
93
|
-
});
|
94
|
-
it('can select a pattern that matches a describe block', async () => {
|
95
|
-
const {
|
96
|
-
stdout,
|
97
|
-
hookEmitter,
|
98
|
-
updateConfigAndRun,
|
99
|
-
plugin,
|
100
|
-
type
|
101
|
-
} = (0, _pluginTester.default)(_plugin.default);
|
102
|
-
hookEmitter.onTestRunComplete({
|
103
|
-
testResults
|
104
|
-
});
|
105
|
-
const runPromise = plugin.run({}, updateConfigAndRun);
|
106
|
-
stdout.write.mockReset();
|
107
|
-
type('s', 'o', _jestWatcher.KEYS.ENTER);
|
108
|
-
expect(stdout.write.mock.calls.join('\n')).toMatchSnapshot();
|
109
|
-
await runPromise;
|
110
|
-
expect(updateConfigAndRun).toHaveBeenCalledWith({
|
111
|
-
mode: 'watch',
|
112
|
-
testNamePattern: 'so'
|
113
|
-
});
|
114
|
-
});
|
115
|
-
it('can select a pattern that includes a regexp special character', async () => {
|
116
|
-
const {
|
117
|
-
hookEmitter,
|
118
|
-
updateConfigAndRun,
|
119
|
-
plugin,
|
120
|
-
type
|
121
|
-
} = (0, _pluginTester.default)(_plugin.default);
|
122
|
-
hookEmitter.onTestRunComplete({
|
123
|
-
testResults: [{
|
124
|
-
testResults: [{
|
125
|
-
title: 'bracket',
|
126
|
-
fullName: 'bracket description (foo)'
|
127
|
-
}]
|
128
|
-
}]
|
129
|
-
});
|
130
|
-
const runPromise = plugin.run({}, updateConfigAndRun);
|
131
|
-
type('b', 'r', _jestWatcher.KEYS.ARROW_DOWN, _jestWatcher.KEYS.ENTER);
|
132
|
-
await runPromise;
|
133
|
-
expect(updateConfigAndRun).toHaveBeenCalledWith({
|
134
|
-
mode: 'watch',
|
135
|
-
testNamePattern: '^bracket description \\(foo\\)$'
|
136
|
-
});
|
137
|
-
});
|
138
|
-
it('can configure the key and prompt', async () => {
|
139
|
-
const {
|
140
|
-
plugin
|
141
|
-
} = (0, _pluginTester.default)(_plugin.default, {
|
142
|
-
config: {
|
143
|
-
key: 'l',
|
144
|
-
prompt: 'have a custom prompt'
|
145
|
-
}
|
146
|
-
});
|
147
|
-
expect(plugin.getUsageInfo()).toEqual({
|
148
|
-
key: 'l',
|
149
|
-
prompt: 'have a custom prompt'
|
150
|
-
});
|
151
|
-
});
|
152
|
-
it('test matching is case insensitive', async () => {
|
153
|
-
const {
|
154
|
-
stdout,
|
155
|
-
hookEmitter,
|
156
|
-
updateConfigAndRun,
|
157
|
-
plugin,
|
158
|
-
type
|
159
|
-
} = (0, _pluginTester.default)(_plugin.default);
|
160
|
-
hookEmitter.onTestRunComplete({
|
161
|
-
testResults
|
162
|
-
});
|
163
|
-
const runPromise = plugin.run({}, updateConfigAndRun);
|
164
|
-
type('f');
|
165
|
-
stdout.write.mockReset();
|
166
|
-
type('O');
|
167
|
-
expect(stdout.write.mock.calls.join('\n')).toMatchSnapshot();
|
168
|
-
type(_jestWatcher.KEYS.ENTER);
|
169
|
-
await runPromise;
|
170
|
-
});
|
171
|
-
it("selected pattern doesn't include trimming dots", async () => {
|
172
|
-
const {
|
173
|
-
hookEmitter,
|
174
|
-
updateConfigAndRun,
|
175
|
-
plugin,
|
176
|
-
type
|
177
|
-
} = (0, _pluginTester.default)(_plugin.default, {
|
178
|
-
stdout: {
|
179
|
-
columns: 30
|
180
|
-
}
|
181
|
-
});
|
182
|
-
hookEmitter.onTestRunComplete({
|
183
|
-
testResults: [{
|
184
|
-
testResults: [{
|
185
|
-
title: 'trimmed long',
|
186
|
-
fullName: 'long test name, gonna need trimming'
|
187
|
-
}]
|
188
|
-
}]
|
189
|
-
});
|
190
|
-
const runPromise = plugin.run({}, updateConfigAndRun);
|
191
|
-
type('t', 'r', 'i', 'm', 'm', _jestWatcher.KEYS.ARROW_DOWN, _jestWatcher.KEYS.ENTER);
|
192
|
-
await runPromise;
|
193
|
-
expect(updateConfigAndRun).toHaveBeenCalledWith({
|
194
|
-
mode: 'watch',
|
195
|
-
testNamePattern: '^me, gonna need trimming$'
|
196
|
-
});
|
197
|
-
});
|
@@ -1,59 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.default = pluginTester;
|
7
|
-
|
8
|
-
var _jestWatcher = require("jest-watcher");
|
9
|
-
|
10
|
-
var _stripAnsi = _interopRequireDefault(require("strip-ansi"));
|
11
|
-
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
|
-
|
14
|
-
expect.addSnapshotSerializer({
|
15
|
-
test: val => typeof val === 'string',
|
16
|
-
print: val => (0, _stripAnsi.default)(val)
|
17
|
-
});
|
18
|
-
/**
|
19
|
-
* See https://github.com/facebook/jest/pull/7523 for more details
|
20
|
-
*/
|
21
|
-
|
22
|
-
const CLEAR = '\x1B[2J\x1B[3J\x1B[H';
|
23
|
-
expect.addSnapshotSerializer({
|
24
|
-
test: val => val.includes(CLEAR),
|
25
|
-
print: val => (0, _stripAnsi.default)(val.replace(CLEAR, '[MOCK - clear]'))
|
26
|
-
});
|
27
|
-
/**
|
28
|
-
* See https://github.com/facebook/jest/pull/7523 for more details
|
29
|
-
*/
|
30
|
-
|
31
|
-
const WINDOWS_CLEAR = '\x1B[2J\x1B[0f';
|
32
|
-
expect.addSnapshotSerializer({
|
33
|
-
test: val => val.includes(WINDOWS_CLEAR),
|
34
|
-
print: val => (0, _stripAnsi.default)(val.replace(WINDOWS_CLEAR, '[MOCK - clear]'))
|
35
|
-
});
|
36
|
-
|
37
|
-
function pluginTester(Plugin, options = {}) {
|
38
|
-
const stdout = {
|
39
|
-
columns: (options.stdout || {}).columns || 80,
|
40
|
-
write: jest.fn()
|
41
|
-
};
|
42
|
-
const jestHooks = new _jestWatcher.JestHook();
|
43
|
-
const plugin = new Plugin({
|
44
|
-
stdout,
|
45
|
-
stdin: process.stdin,
|
46
|
-
config: options.config
|
47
|
-
});
|
48
|
-
plugin.apply(jestHooks.getSubscriber());
|
49
|
-
|
50
|
-
const type = (...keys) => keys.forEach(key => plugin.onKey(key));
|
51
|
-
|
52
|
-
return {
|
53
|
-
stdout,
|
54
|
-
hookEmitter: jestHooks.getEmitter(),
|
55
|
-
updateConfigAndRun: jest.fn(),
|
56
|
-
plugin,
|
57
|
-
type
|
58
|
-
};
|
59
|
-
}
|