jest-watch-typeahead 0.6.5 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -1
- package/build/file_name_plugin/plugin.js +6 -19
- package/build/file_name_plugin/prompt.js +24 -43
- package/build/index.js +0 -2
- package/build/lib/pattern_mode_helpers.js +13 -37
- package/build/lib/scroll.js +1 -9
- package/build/lib/utils.js +25 -55
- package/build/test_name_plugin/plugin.js +6 -19
- package/build/test_name_plugin/prompt.js +19 -37
- package/build/types/Config.js +1 -5
- package/filename.js +1 -4
- package/package.json +22 -9
- package/testname.js +1 -4
package/README.md
CHANGED
@@ -1,17 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.default = void 0;
|
7
|
-
|
8
|
-
var _jestWatcher = require("jest-watcher");
|
9
|
-
|
10
|
-
var _prompt = _interopRequireDefault(require("./prompt"));
|
11
|
-
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
|
-
|
14
|
-
class FileNamePlugin {
|
1
|
+
import { Prompt } from 'jest-watcher';
|
2
|
+
import FileNamePatternPrompt from "./prompt.js";
|
3
|
+
export default class FileNamePlugin {
|
15
4
|
constructor({
|
16
5
|
stdin,
|
17
6
|
stdout,
|
@@ -19,7 +8,7 @@ class FileNamePlugin {
|
|
19
8
|
}) {
|
20
9
|
this._stdin = stdin;
|
21
10
|
this._stdout = stdout;
|
22
|
-
this._prompt = new
|
11
|
+
this._prompt = new Prompt();
|
23
12
|
this._projects = [];
|
24
13
|
this._usageInfo = {
|
25
14
|
key: config.key || 'p',
|
@@ -40,7 +29,7 @@ class FileNamePlugin {
|
|
40
29
|
}
|
41
30
|
|
42
31
|
run(globalConfig, updateConfigAndRun) {
|
43
|
-
const p = new
|
32
|
+
const p = new FileNamePatternPrompt(this._stdout, this._prompt);
|
44
33
|
p.updateSearchSources(this._projects);
|
45
34
|
return new Promise((res, rej) => {
|
46
35
|
p.run(testPathPattern => {
|
@@ -57,6 +46,4 @@ class FileNamePlugin {
|
|
57
46
|
return this._usageInfo;
|
58
47
|
}
|
59
48
|
|
60
|
-
}
|
61
|
-
|
62
|
-
exports.default = FileNamePlugin;
|
49
|
+
}
|
@@ -1,29 +1,12 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
}
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
var _ansiEscapes = _interopRequireDefault(require("ansi-escapes"));
|
11
|
-
|
12
|
-
var _stringLength = _interopRequireDefault(require("string-length"));
|
13
|
-
|
14
|
-
var _jestWatcher = require("jest-watcher");
|
15
|
-
|
16
|
-
var _jestRegexUtil = require("jest-regex-util");
|
17
|
-
|
18
|
-
var _utils = require("../lib/utils");
|
19
|
-
|
20
|
-
var _pattern_mode_helpers = require("../lib/pattern_mode_helpers");
|
21
|
-
|
22
|
-
var _scroll = _interopRequireDefault(require("../lib/scroll"));
|
23
|
-
|
24
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
25
|
-
|
26
|
-
class FileNamePatternPrompt extends _jestWatcher.PatternPrompt {
|
1
|
+
import chalk from 'chalk';
|
2
|
+
import ansiEscapes from 'ansi-escapes';
|
3
|
+
import stringLength from 'string-length';
|
4
|
+
import { PatternPrompt, printPatternCaret, printRestoredPatternCaret } from 'jest-watcher';
|
5
|
+
import { escapeStrForRegex } from 'jest-regex-util';
|
6
|
+
import { highlight, getTerminalWidth, trimAndFormatPath, removeTrimmingDots } from "../lib/utils.js";
|
7
|
+
import { formatTypeaheadSelection, printMore, printPatternMatches, printStartTyping, printTypeaheadItem } from "../lib/pattern_mode_helpers.js";
|
8
|
+
import scroll from "../lib/scroll.js";
|
9
|
+
export default class FileNamePatternPrompt extends PatternPrompt {
|
27
10
|
constructor(pipe, prompt) {
|
28
11
|
super(pipe, prompt);
|
29
12
|
this._entityName = 'filenames';
|
@@ -42,36 +25,36 @@ class FileNamePatternPrompt extends _jestWatcher.PatternPrompt {
|
|
42
25
|
const total = matchedTests.length;
|
43
26
|
const pipe = this._pipe;
|
44
27
|
const prompt = this._prompt;
|
45
|
-
|
46
|
-
pipe.write(
|
28
|
+
printPatternCaret(pattern, pipe);
|
29
|
+
pipe.write(ansiEscapes.cursorLeft);
|
47
30
|
|
48
31
|
if (pattern) {
|
49
|
-
|
50
|
-
const prefix = ` ${
|
51
|
-
const padding = (
|
52
|
-
const width =
|
32
|
+
printPatternMatches(total, 'file', pipe);
|
33
|
+
const prefix = ` ${chalk.dim('\u203A')} `;
|
34
|
+
const padding = stringLength(prefix) + 2;
|
35
|
+
const width = getTerminalWidth(pipe);
|
53
36
|
const {
|
54
37
|
start,
|
55
38
|
end,
|
56
39
|
index
|
57
|
-
} = (
|
40
|
+
} = scroll(total, options);
|
58
41
|
prompt.setPromptLength(total);
|
59
42
|
matchedTests.slice(start, end).map(({
|
60
43
|
path,
|
61
44
|
context
|
62
45
|
}) => {
|
63
|
-
const filePath =
|
64
|
-
return
|
65
|
-
}).map((item, i) =>
|
46
|
+
const filePath = trimAndFormatPath(padding, context.config, path, width);
|
47
|
+
return highlight(path, filePath, pattern);
|
48
|
+
}).map((item, i) => formatTypeaheadSelection(item, i, index, prompt)).forEach(item => printTypeaheadItem(item, pipe));
|
66
49
|
|
67
50
|
if (total > end) {
|
68
|
-
|
51
|
+
printMore('file', pipe, total - end);
|
69
52
|
}
|
70
53
|
} else {
|
71
|
-
|
54
|
+
printStartTyping('filename', pipe);
|
72
55
|
}
|
73
56
|
|
74
|
-
|
57
|
+
printRestoredPatternCaret(pattern, this._currentUsageRows, pipe);
|
75
58
|
}
|
76
59
|
|
77
60
|
_getMatchedTests(pattern) {
|
@@ -102,10 +85,8 @@ class FileNamePatternPrompt extends _jestWatcher.PatternPrompt {
|
|
102
85
|
|
103
86
|
run(onSuccess, onCancel, options) {
|
104
87
|
super.run(value => {
|
105
|
-
onSuccess(
|
88
|
+
onSuccess(removeTrimmingDots(value).split('/').map(escapeStrForRegex).join('/'));
|
106
89
|
}, onCancel, options);
|
107
90
|
}
|
108
91
|
|
109
|
-
}
|
110
|
-
|
111
|
-
exports.default = FileNamePatternPrompt;
|
92
|
+
}
|
package/build/index.js
CHANGED
@@ -1,51 +1,27 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.formatTypeaheadSelection = exports.printTypeaheadItem = exports.printMore = exports.printStartTyping = exports.printPatternMatches = void 0;
|
7
|
-
|
8
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
9
|
-
|
10
|
-
var _stripAnsi = _interopRequireDefault(require("strip-ansi"));
|
11
|
-
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
1
|
+
import chalk from 'chalk';
|
2
|
+
import stripAnsi from 'strip-ansi';
|
13
3
|
|
14
4
|
const pluralize = (count, text) => count === 1 ? text : `${text}s`;
|
15
5
|
|
16
|
-
const printPatternMatches = (count, entity, pipe, extraText = '') => {
|
6
|
+
export const printPatternMatches = (count, entity, pipe, extraText = '') => {
|
17
7
|
const pluralized = pluralize(count, entity);
|
18
8
|
const result = count ? `\n\n Pattern matches ${count} ${pluralized}` : `\n\n Pattern matches no ${pluralized}`;
|
19
9
|
pipe.write(result + extraText);
|
20
10
|
};
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
const printStartTyping = (entity, pipe) => {
|
25
|
-
pipe.write(`\n\n ${_chalk.default.italic.yellow(`Start typing to filter by a ${entity} regex pattern.`)}`);
|
11
|
+
export const printStartTyping = (entity, pipe) => {
|
12
|
+
pipe.write(`\n\n ${chalk.italic.yellow(`Start typing to filter by a ${entity} regex pattern.`)}`);
|
26
13
|
};
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
const printMore = (entity, pipe, more) => {
|
31
|
-
pipe.write(`\n ${_chalk.default.dim(`...and ${more} more ${pluralize(more, entity)}`)}`);
|
14
|
+
export const printMore = (entity, pipe, more) => {
|
15
|
+
pipe.write(`\n ${chalk.dim(`...and ${more} more ${pluralize(more, entity)}`)}`);
|
32
16
|
};
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
const printTypeaheadItem = (item, pipe) => {
|
37
|
-
pipe.write(`\n ${_chalk.default.dim('\u203A')} ${item}`);
|
17
|
+
export const printTypeaheadItem = (item, pipe) => {
|
18
|
+
pipe.write(`\n ${chalk.dim('\u203A')} ${item}`);
|
38
19
|
};
|
39
|
-
|
40
|
-
exports.printTypeaheadItem = printTypeaheadItem;
|
41
|
-
|
42
|
-
const formatTypeaheadSelection = (item, index, activeIndex, prompt) => {
|
20
|
+
export const formatTypeaheadSelection = (item, index, activeIndex, prompt) => {
|
43
21
|
if (index === activeIndex) {
|
44
|
-
prompt.setPromptSelection((
|
45
|
-
return
|
22
|
+
prompt.setPromptSelection(stripAnsi(item));
|
23
|
+
return chalk.black.bgYellow(stripAnsi(item));
|
46
24
|
}
|
47
25
|
|
48
26
|
return item;
|
49
|
-
};
|
50
|
-
|
51
|
-
exports.formatTypeaheadSelection = formatTypeaheadSelection;
|
27
|
+
};
|
package/build/lib/scroll.js
CHANGED
@@ -1,10 +1,3 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.default = void 0;
|
7
|
-
|
8
1
|
const scroll = (size, {
|
9
2
|
offset,
|
10
3
|
max
|
@@ -30,5 +23,4 @@ const scroll = (size, {
|
|
30
23
|
};
|
31
24
|
};
|
32
25
|
|
33
|
-
|
34
|
-
exports.default = _default;
|
26
|
+
export default scroll;
|
package/build/lib/utils.js
CHANGED
@@ -1,39 +1,23 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
});
|
6
|
-
exports.removeTrimmingDots = exports.formatTestNameByPattern = exports.highlight = exports.getTerminalWidth = exports.trimAndFormatPath = void 0;
|
7
|
-
|
8
|
-
var _path = _interopRequireDefault(require("path"));
|
9
|
-
|
10
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
11
|
-
|
12
|
-
var _slash = _interopRequireDefault(require("slash"));
|
13
|
-
|
14
|
-
var _stripAnsi = _interopRequireDefault(require("strip-ansi"));
|
15
|
-
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
17
|
-
|
1
|
+
import path from 'path';
|
2
|
+
import chalk from 'chalk';
|
3
|
+
import slash from 'slash';
|
4
|
+
import stripAnsi from 'strip-ansi';
|
18
5
|
const TRIMMING_DOTS = '...';
|
19
6
|
const ENTER = '⏎';
|
20
7
|
|
21
8
|
const relativePath = (config, testPath) => {
|
22
|
-
const relativeTestPath =
|
23
|
-
|
24
|
-
const
|
25
|
-
|
26
|
-
const basename = _path.default.basename(relativeTestPath);
|
27
|
-
|
9
|
+
const relativeTestPath = path.relative(config.cwd || config.rootDir, testPath);
|
10
|
+
const dirname = path.dirname(relativeTestPath);
|
11
|
+
const basename = path.basename(relativeTestPath);
|
28
12
|
return {
|
29
13
|
basename,
|
30
14
|
dirname
|
31
15
|
};
|
32
16
|
};
|
33
17
|
|
34
|
-
const colorize = (str, start, end) =>
|
18
|
+
const colorize = (str, start, end) => chalk.dim(str.slice(0, start)) + chalk.reset(str.slice(start, end)) + chalk.dim(str.slice(end));
|
35
19
|
|
36
|
-
const trimAndFormatPath = (pad, config, testPath, columns) => {
|
20
|
+
export const trimAndFormatPath = (pad, config, testPath, columns) => {
|
37
21
|
const maxLength = columns - pad;
|
38
22
|
const relative = relativePath(config, testPath);
|
39
23
|
const {
|
@@ -43,8 +27,8 @@ const trimAndFormatPath = (pad, config, testPath, columns) => {
|
|
43
27
|
dirname
|
44
28
|
} = relative; // length is ok
|
45
29
|
|
46
|
-
if ((dirname +
|
47
|
-
return (
|
30
|
+
if ((dirname + path.sep + basename).length <= maxLength) {
|
31
|
+
return slash(chalk.dim(dirname + path.sep) + chalk.bold(basename));
|
48
32
|
} // we can fit trimmed dirname and full basename
|
49
33
|
|
50
34
|
|
@@ -53,39 +37,33 @@ const trimAndFormatPath = (pad, config, testPath, columns) => {
|
|
53
37
|
if (basenameLength + 4 < maxLength) {
|
54
38
|
const dirnameLength = maxLength - 4 - basenameLength;
|
55
39
|
dirname = `${TRIMMING_DOTS}${dirname.slice(dirname.length - dirnameLength, dirname.length)}`;
|
56
|
-
return (
|
40
|
+
return slash(chalk.dim(dirname + path.sep) + chalk.bold(basename));
|
57
41
|
}
|
58
42
|
|
59
43
|
if (basenameLength + 4 === maxLength) {
|
60
|
-
return (
|
44
|
+
return slash(chalk.dim(`${TRIMMING_DOTS}${path.sep}`) + chalk.bold(basename));
|
61
45
|
} // can't fit dirname, but can fit trimmed basename
|
62
46
|
|
63
47
|
|
64
|
-
return (
|
48
|
+
return slash(chalk.bold(`${TRIMMING_DOTS}${basename.slice(-maxLength + 3)}`));
|
65
49
|
};
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
const getTerminalWidth = (pipe = process.stdout) => pipe.columns;
|
70
|
-
|
71
|
-
exports.getTerminalWidth = getTerminalWidth;
|
72
|
-
|
73
|
-
const highlight = (rawPath, filePath, pattern) => {
|
50
|
+
export const getTerminalWidth = (pipe = process.stdout) => pipe.columns;
|
51
|
+
export const highlight = (rawPath, filePath, pattern) => {
|
74
52
|
const relativePathHead = './';
|
75
53
|
let regexp;
|
76
54
|
|
77
55
|
try {
|
78
56
|
regexp = new RegExp(pattern, 'i');
|
79
57
|
} catch (e) {
|
80
|
-
return
|
58
|
+
return chalk.dim(filePath);
|
81
59
|
}
|
82
60
|
|
83
|
-
const strippedRawPath = (
|
84
|
-
const strippedFilePath = (
|
61
|
+
const strippedRawPath = stripAnsi(rawPath);
|
62
|
+
const strippedFilePath = stripAnsi(filePath);
|
85
63
|
const match = strippedRawPath.match(regexp);
|
86
64
|
|
87
65
|
if (!match || match.index == null) {
|
88
|
-
return
|
66
|
+
return chalk.dim(strippedFilePath);
|
89
67
|
}
|
90
68
|
|
91
69
|
const offset = strippedRawPath.length - strippedFilePath.length;
|
@@ -103,23 +81,20 @@ const highlight = (rawPath, filePath, pattern) => {
|
|
103
81
|
const end = start + match[0].length;
|
104
82
|
return colorize(strippedFilePath, Math.max(start, 0), Math.max(end, trimLength));
|
105
83
|
};
|
106
|
-
|
107
|
-
exports.highlight = highlight;
|
108
|
-
|
109
|
-
const formatTestNameByPattern = (testName, pattern, width) => {
|
84
|
+
export const formatTestNameByPattern = (testName, pattern, width) => {
|
110
85
|
const inlineTestName = testName.replace(/(\r\n|\n|\r)/gm, ENTER);
|
111
86
|
let regexp;
|
112
87
|
|
113
88
|
try {
|
114
89
|
regexp = new RegExp(pattern, 'i');
|
115
90
|
} catch (e) {
|
116
|
-
return
|
91
|
+
return chalk.dim(inlineTestName);
|
117
92
|
}
|
118
93
|
|
119
94
|
const match = inlineTestName.match(regexp);
|
120
95
|
|
121
96
|
if (!match || match.index == null) {
|
122
|
-
return
|
97
|
+
return chalk.dim(inlineTestName);
|
123
98
|
}
|
124
99
|
|
125
100
|
const startPatternIndex = Math.max(match.index, 0);
|
@@ -142,15 +117,10 @@ const formatTestNameByPattern = (testName, pattern, width) => {
|
|
142
117
|
const start = startPatternIndex - numberOfTruncatedChars;
|
143
118
|
return colorize(TRIMMING_DOTS + truncatedTestName, start + TRIMMING_DOTS.length, end + TRIMMING_DOTS.length);
|
144
119
|
};
|
145
|
-
|
146
|
-
exports.formatTestNameByPattern = formatTestNameByPattern;
|
147
|
-
|
148
|
-
const removeTrimmingDots = value => {
|
120
|
+
export const removeTrimmingDots = value => {
|
149
121
|
if (value.startsWith(TRIMMING_DOTS)) {
|
150
122
|
return value.slice(TRIMMING_DOTS.length);
|
151
123
|
}
|
152
124
|
|
153
125
|
return value;
|
154
|
-
};
|
155
|
-
|
156
|
-
exports.removeTrimmingDots = removeTrimmingDots;
|
126
|
+
};
|
@@ -1,17 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.default = void 0;
|
7
|
-
|
8
|
-
var _jestWatcher = require("jest-watcher");
|
9
|
-
|
10
|
-
var _prompt = _interopRequireDefault(require("./prompt"));
|
11
|
-
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
|
-
|
14
|
-
class TestNamePlugin {
|
1
|
+
import { Prompt } from 'jest-watcher';
|
2
|
+
import TestNamePatternPrompt from "./prompt.js";
|
3
|
+
export default class TestNamePlugin {
|
15
4
|
constructor({
|
16
5
|
stdin,
|
17
6
|
stdout,
|
@@ -19,7 +8,7 @@ class TestNamePlugin {
|
|
19
8
|
}) {
|
20
9
|
this._stdin = stdin;
|
21
10
|
this._stdout = stdout;
|
22
|
-
this._prompt = new
|
11
|
+
this._prompt = new Prompt();
|
23
12
|
this._testResults = [];
|
24
13
|
this._usageInfo = {
|
25
14
|
key: config.key || 't',
|
@@ -40,7 +29,7 @@ class TestNamePlugin {
|
|
40
29
|
}
|
41
30
|
|
42
31
|
run(globalConfig, updateConfigAndRun) {
|
43
|
-
const p = new
|
32
|
+
const p = new TestNamePatternPrompt(this._stdout, this._prompt);
|
44
33
|
p.updateCachedTestResults(this._testResults);
|
45
34
|
return new Promise((res, rej) => {
|
46
35
|
p.run(testNamePattern => {
|
@@ -57,6 +46,4 @@ class TestNamePlugin {
|
|
57
46
|
return this._usageInfo;
|
58
47
|
}
|
59
48
|
|
60
|
-
}
|
61
|
-
|
62
|
-
exports.default = TestNamePlugin;
|
49
|
+
}
|
@@ -1,27 +1,11 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
var _ansiEscapes = _interopRequireDefault(require("ansi-escapes"));
|
11
|
-
|
12
|
-
var _jestWatcher = require("jest-watcher");
|
13
|
-
|
14
|
-
var _jestRegexUtil = require("jest-regex-util");
|
15
|
-
|
16
|
-
var _scroll = _interopRequireDefault(require("../lib/scroll"));
|
17
|
-
|
18
|
-
var _utils = require("../lib/utils");
|
19
|
-
|
20
|
-
var _pattern_mode_helpers = require("../lib/pattern_mode_helpers");
|
21
|
-
|
22
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
23
|
-
|
24
|
-
class TestNamePatternPrompt extends _jestWatcher.PatternPrompt {
|
1
|
+
import chalk from 'chalk';
|
2
|
+
import ansiEscapes from 'ansi-escapes';
|
3
|
+
import { PatternPrompt, printPatternCaret, printRestoredPatternCaret } from 'jest-watcher';
|
4
|
+
import { escapeStrForRegex } from 'jest-regex-util';
|
5
|
+
import scroll from "../lib/scroll.js";
|
6
|
+
import { formatTestNameByPattern, getTerminalWidth, removeTrimmingDots } from "../lib/utils.js";
|
7
|
+
import { formatTypeaheadSelection, printMore, printPatternMatches, printStartTyping, printTypeaheadItem } from "../lib/pattern_mode_helpers.js";
|
8
|
+
export default class TestNamePatternPrompt extends PatternPrompt {
|
25
9
|
constructor(pipe, prompt) {
|
26
10
|
super(pipe, prompt);
|
27
11
|
this._entityName = 'tests';
|
@@ -43,28 +27,28 @@ class TestNamePatternPrompt extends _jestWatcher.PatternPrompt {
|
|
43
27
|
const total = matchedTests.length;
|
44
28
|
const pipe = this._pipe;
|
45
29
|
const prompt = this._prompt;
|
46
|
-
|
47
|
-
pipe.write(
|
30
|
+
printPatternCaret(pattern, pipe);
|
31
|
+
pipe.write(ansiEscapes.cursorLeft);
|
48
32
|
|
49
33
|
if (pattern) {
|
50
|
-
|
51
|
-
const width =
|
34
|
+
printPatternMatches(total, 'test', pipe, ` from ${chalk.yellow('cached')} test suites`);
|
35
|
+
const width = getTerminalWidth(pipe);
|
52
36
|
const {
|
53
37
|
start,
|
54
38
|
end,
|
55
39
|
index
|
56
|
-
} = (
|
40
|
+
} = scroll(total, options);
|
57
41
|
prompt.setPromptLength(total);
|
58
|
-
matchedTests.slice(start, end).map(name =>
|
42
|
+
matchedTests.slice(start, end).map(name => formatTestNameByPattern(name, pattern, width - 4)).map((item, i) => formatTypeaheadSelection(item, i, index, prompt)).forEach(item => printTypeaheadItem(item, pipe));
|
59
43
|
|
60
44
|
if (total > end) {
|
61
|
-
|
45
|
+
printMore('test', pipe, total - end);
|
62
46
|
}
|
63
47
|
} else {
|
64
|
-
|
48
|
+
printStartTyping('test name', pipe);
|
65
49
|
}
|
66
50
|
|
67
|
-
|
51
|
+
printRestoredPatternCaret(pattern, this._currentUsageRows, pipe);
|
68
52
|
}
|
69
53
|
|
70
54
|
_getMatchedTests(pattern) {
|
@@ -93,12 +77,10 @@ class TestNamePatternPrompt extends _jestWatcher.PatternPrompt {
|
|
93
77
|
|
94
78
|
run(onSuccess, onCancel, options) {
|
95
79
|
super.run(value => {
|
96
|
-
const preparedPattern =
|
80
|
+
const preparedPattern = escapeStrForRegex(removeTrimmingDots(value));
|
97
81
|
const useExactMatch = this._offset !== -1;
|
98
82
|
onSuccess(useExactMatch ? `^${preparedPattern}$` : preparedPattern);
|
99
83
|
}, onCancel, options);
|
100
84
|
}
|
101
85
|
|
102
|
-
}
|
103
|
-
|
104
|
-
exports.default = TestNamePatternPrompt;
|
86
|
+
}
|
package/build/types/Config.js
CHANGED
package/filename.js
CHANGED
package/package.json
CHANGED
@@ -1,7 +1,14 @@
|
|
1
1
|
{
|
2
2
|
"name": "jest-watch-typeahead",
|
3
|
-
"version": "0.
|
3
|
+
"version": "1.0.0",
|
4
4
|
"main": "build/index.js",
|
5
|
+
"exports": {
|
6
|
+
".": "./build/index.js",
|
7
|
+
"./filename": "./build/file_name_plugin/plugin.js",
|
8
|
+
"./testname": "./build/test_name_plugin/plugin.js",
|
9
|
+
"./package.json": "./package.json"
|
10
|
+
},
|
11
|
+
"type": "module",
|
5
12
|
"author": "Rogelio Guzman <rogelioguzmanh@gmail.com>",
|
6
13
|
"description": "Jest plugin for filtering by filename or test name",
|
7
14
|
"license": "MIT",
|
@@ -16,7 +23,7 @@
|
|
16
23
|
"testname.js"
|
17
24
|
],
|
18
25
|
"scripts": {
|
19
|
-
"test": "jest",
|
26
|
+
"test": "cross-env NODE_OPTIONS=\"--experimental-vm-modules\" jest",
|
20
27
|
"lint": "eslint .",
|
21
28
|
"prebuild": "rimraf build",
|
22
29
|
"build": "babel --extensions .js,.ts src -d build && rimraf **/*.test.{js,ts},integration build/**/__tests__ build/test_utils",
|
@@ -29,15 +36,16 @@
|
|
29
36
|
"chalk": "^4.0.0",
|
30
37
|
"jest-regex-util": "^27.0.0",
|
31
38
|
"jest-watcher": "^27.0.0",
|
32
|
-
"slash": "^
|
33
|
-
"string-length": "^
|
34
|
-
"strip-ansi": "^
|
39
|
+
"slash": "^4.0.0",
|
40
|
+
"string-length": "^5.0.1",
|
41
|
+
"strip-ansi": "^7.0.1"
|
35
42
|
},
|
36
43
|
"devDependencies": {
|
37
44
|
"@babel/cli": "^7.8.4",
|
38
45
|
"@babel/core": "^7.9.6",
|
39
46
|
"@babel/preset-env": "^7.9.6",
|
40
47
|
"@babel/preset-typescript": "^7.10.4",
|
48
|
+
"@jest/globals": "^27.2.3",
|
41
49
|
"@jest/types": "^27.0.0",
|
42
50
|
"@semantic-release/changelog": "^5.0.1",
|
43
51
|
"@semantic-release/git": "^9.0.0",
|
@@ -45,24 +53,29 @@
|
|
45
53
|
"@types/node": "^14.6.4",
|
46
54
|
"@typescript-eslint/eslint-plugin": "^4.0.1",
|
47
55
|
"@typescript-eslint/parser": "^4.0.1",
|
48
|
-
"babel-eslint": "^10.1.0",
|
49
56
|
"babel-jest": "^27.0.0",
|
57
|
+
"babel-plugin-add-import-extension": "^1.6.0",
|
58
|
+
"cross-env": "^7.0.3",
|
50
59
|
"eslint": "^7.8.1",
|
51
60
|
"eslint-config-airbnb-base": "^14.1.0",
|
52
61
|
"eslint-config-prettier": "^8.0.0",
|
53
62
|
"eslint-plugin-import": "^2.20.2",
|
54
63
|
"eslint-plugin-jest": "^24.0.0",
|
55
|
-
"eslint-plugin-prettier": "^
|
64
|
+
"eslint-plugin-prettier": "^4.0.0",
|
56
65
|
"jest": "^27.0.0",
|
57
66
|
"prettier": "^2.1.1",
|
58
67
|
"rimraf": "^3.0.2",
|
59
68
|
"semantic-release": "^17.4.3",
|
69
|
+
"semver": "^7.3.5",
|
60
70
|
"typescript": "^4.0.2"
|
61
71
|
},
|
62
72
|
"peerDependencies": {
|
63
|
-
"jest": "^
|
73
|
+
"jest": "^27.0.0"
|
64
74
|
},
|
65
75
|
"jest": {
|
76
|
+
"extensionsToTreatAsEsm": [
|
77
|
+
".ts"
|
78
|
+
],
|
66
79
|
"watchPlugins": [
|
67
80
|
"<rootDir>/filename",
|
68
81
|
"<rootDir>/testname"
|
@@ -80,7 +93,7 @@
|
|
80
93
|
]
|
81
94
|
},
|
82
95
|
"engines": {
|
83
|
-
"node": ">=
|
96
|
+
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
84
97
|
},
|
85
98
|
"resolutions": {
|
86
99
|
"semantic-release/@semantic-release/github/fs-extra": "^9.0.0",
|
package/testname.js
CHANGED