jest-watch-typeahead 0.6.1 → 0.6.5

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Build Status](https://travis-ci.org/jest-community/jest-watch-typeahead.svg?branch=master)](https://travis-ci.org/jest-community/jest-watch-typeahead) [![npm version](https://badge.fury.io/js/jest-watch-typeahead.svg)](https://badge.fury.io/js/jest-watch-typeahead)
1
+ [![Build Status](https://github.com/jest-community/jest-watch-typeahead/actions/workflows/nodejs.yml/badge.svg?branch=main)](https://github.com/jest-community/jest-watch-typeahead/actions/workflows/nodejs.yml) [![npm version](https://badge.fury.io/js/jest-watch-typeahead.svg)](https://badge.fury.io/js/jest-watch-typeahead)
2
2
 
3
3
  <div align="center">
4
4
  <a href="https://jestjs.io/">
@@ -1,5 +1,10 @@
1
1
  "use strict";
2
2
 
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
3
8
  var _jestWatcher = require("jest-watcher");
4
9
 
5
10
  var _prompt = _interopRequireDefault(require("./prompt"));
@@ -54,4 +59,4 @@ class FileNamePlugin {
54
59
 
55
60
  }
56
61
 
57
- module.exports = FileNamePlugin;
62
+ exports.default = FileNamePlugin;
@@ -19,7 +19,7 @@ var _utils = require("../lib/utils");
19
19
 
20
20
  var _pattern_mode_helpers = require("../lib/pattern_mode_helpers");
21
21
 
22
- var _scroll2 = _interopRequireDefault(require("../lib/scroll"));
22
+ var _scroll = _interopRequireDefault(require("../lib/scroll"));
23
23
 
24
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
25
 
@@ -50,19 +50,18 @@ class FileNamePatternPrompt extends _jestWatcher.PatternPrompt {
50
50
  const prefix = ` ${_chalk.default.dim('\u203A')} `;
51
51
  const padding = (0, _stringLength.default)(prefix) + 2;
52
52
  const width = (0, _utils.getTerminalWidth)(pipe);
53
-
54
- const _scroll = (0, _scroll2.default)(total, options),
55
- start = _scroll.start,
56
- end = _scroll.end,
57
- index = _scroll.index;
58
-
53
+ const {
54
+ start,
55
+ end,
56
+ index
57
+ } = (0, _scroll.default)(total, options);
59
58
  prompt.setPromptLength(total);
60
59
  matchedTests.slice(start, end).map(({
61
60
  path,
62
61
  context
63
62
  }) => {
64
63
  const filePath = (0, _utils.trimAndFormatPath)(padding, context.config, path, width);
65
- return (0, _utils.highlight)(path, filePath, pattern, context.config.rootDir);
64
+ return (0, _utils.highlight)(path, filePath, pattern);
66
65
  }).map((item, i) => (0, _pattern_mode_helpers.formatTypeaheadSelection)(item, i, index, prompt)).forEach(item => (0, _pattern_mode_helpers.printTypeaheadItem)(item, pipe));
67
66
 
68
67
  if (total > end) {
@@ -9,8 +9,6 @@ var _chalk = _interopRequireDefault(require("chalk"));
9
9
 
10
10
  var _stripAnsi = _interopRequireDefault(require("strip-ansi"));
11
11
 
12
- var _jestWatcher = require("jest-watcher");
13
-
14
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
13
 
16
14
  const pluralize = (count, text) => count === 1 ? text : `${text}s`;
@@ -35,7 +33,9 @@ const printMore = (entity, pipe, more) => {
35
33
 
36
34
  exports.printMore = printMore;
37
35
 
38
- const printTypeaheadItem = (item, pipe) => pipe.write(`\n ${_chalk.default.dim('\u203A')} ${item}`);
36
+ const printTypeaheadItem = (item, pipe) => {
37
+ pipe.write(`\n ${_chalk.default.dim('\u203A')} ${item}`);
38
+ };
39
39
 
40
40
  exports.printTypeaheadItem = printTypeaheadItem;
41
41
 
@@ -15,16 +15,15 @@ var _stripAnsi = _interopRequireDefault(require("strip-ansi"));
15
15
 
16
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
17
 
18
- /* eslint-disable no-param-reassign */
19
18
  const TRIMMING_DOTS = '...';
20
19
  const ENTER = '⏎';
21
20
 
22
21
  const relativePath = (config, testPath) => {
23
- testPath = _path.default.relative(config.cwd || config.rootDir, testPath);
22
+ const relativeTestPath = _path.default.relative(config.cwd || config.rootDir, testPath);
24
23
 
25
- const dirname = _path.default.dirname(testPath);
24
+ const dirname = _path.default.dirname(relativeTestPath);
26
25
 
27
- const basename = _path.default.basename(testPath);
26
+ const basename = _path.default.basename(relativeTestPath);
28
27
 
29
28
  return {
30
29
  basename,
@@ -37,8 +36,12 @@ const colorize = (str, start, end) => _chalk.default.dim(str.slice(0, start)) +
37
36
  const trimAndFormatPath = (pad, config, testPath, columns) => {
38
37
  const maxLength = columns - pad;
39
38
  const relative = relativePath(config, testPath);
40
- const basename = relative.basename;
41
- let dirname = relative.dirname; // length is ok
39
+ const {
40
+ basename
41
+ } = relative;
42
+ let {
43
+ dirname
44
+ } = relative; // length is ok
42
45
 
43
46
  if ((dirname + _path.default.sep + basename).length <= maxLength) {
44
47
  return (0, _slash.default)(_chalk.default.dim(dirname + _path.default.sep) + _chalk.default.bold(basename));
@@ -67,7 +70,7 @@ const getTerminalWidth = (pipe = process.stdout) => pipe.columns;
67
70
 
68
71
  exports.getTerminalWidth = getTerminalWidth;
69
72
 
70
- const highlight = (rawPath, filePath, pattern, rootDir) => {
73
+ const highlight = (rawPath, filePath, pattern) => {
71
74
  const relativePathHead = './';
72
75
  let regexp;
73
76
 
@@ -77,31 +80,28 @@ const highlight = (rawPath, filePath, pattern, rootDir) => {
77
80
  return _chalk.default.dim(filePath);
78
81
  }
79
82
 
80
- rawPath = (0, _stripAnsi.default)(rawPath);
81
- filePath = (0, _stripAnsi.default)(filePath);
82
- const match = rawPath.match(regexp);
83
+ const strippedRawPath = (0, _stripAnsi.default)(rawPath);
84
+ const strippedFilePath = (0, _stripAnsi.default)(filePath);
85
+ const match = strippedRawPath.match(regexp);
83
86
 
84
- if (!match) {
85
- return _chalk.default.dim(filePath);
87
+ if (!match || match.index == null) {
88
+ return _chalk.default.dim(strippedFilePath);
86
89
  }
87
90
 
88
- let offset;
91
+ const offset = strippedRawPath.length - strippedFilePath.length;
89
92
  let trimLength;
90
93
 
91
- if (filePath.startsWith(TRIMMING_DOTS)) {
92
- offset = rawPath.length - filePath.length;
94
+ if (strippedFilePath.startsWith(TRIMMING_DOTS)) {
93
95
  trimLength = TRIMMING_DOTS.length;
94
- } else if (filePath.startsWith(relativePathHead)) {
95
- offset = rawPath.length - filePath.length;
96
+ } else if (strippedFilePath.startsWith(relativePathHead)) {
96
97
  trimLength = relativePathHead.length;
97
98
  } else {
98
- offset = rootDir.length + _path.default.sep.length;
99
99
  trimLength = 0;
100
100
  }
101
101
 
102
102
  const start = match.index - offset;
103
103
  const end = start + match[0].length;
104
- return colorize(filePath, Math.max(start, 0), Math.max(end, trimLength));
104
+ return colorize(strippedFilePath, Math.max(start, 0), Math.max(end, trimLength));
105
105
  };
106
106
 
107
107
  exports.highlight = highlight;
@@ -118,10 +118,9 @@ const formatTestNameByPattern = (testName, pattern, width) => {
118
118
 
119
119
  const match = inlineTestName.match(regexp);
120
120
 
121
- if (!match) {
121
+ if (!match || match.index == null) {
122
122
  return _chalk.default.dim(inlineTestName);
123
- } // $FlowFixMe
124
-
123
+ }
125
124
 
126
125
  const startPatternIndex = Math.max(match.index, 0);
127
126
  const endPatternIndex = startPatternIndex + match[0].length;
@@ -1,5 +1,10 @@
1
1
  "use strict";
2
2
 
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
3
8
  var _jestWatcher = require("jest-watcher");
4
9
 
5
10
  var _prompt = _interopRequireDefault(require("./prompt"));
@@ -54,4 +59,4 @@ class TestNamePlugin {
54
59
 
55
60
  }
56
61
 
57
- module.exports = TestNamePlugin;
62
+ exports.default = TestNamePlugin;
@@ -1,5 +1,10 @@
1
1
  "use strict";
2
2
 
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
3
8
  var _chalk = _interopRequireDefault(require("chalk"));
4
9
 
5
10
  var _ansiEscapes = _interopRequireDefault(require("ansi-escapes"));
@@ -8,7 +13,7 @@ var _jestWatcher = require("jest-watcher");
8
13
 
9
14
  var _jestRegexUtil = require("jest-regex-util");
10
15
 
11
- var _scroll2 = _interopRequireDefault(require("../lib/scroll"));
16
+ var _scroll = _interopRequireDefault(require("../lib/scroll"));
12
17
 
13
18
  var _utils = require("../lib/utils");
14
19
 
@@ -44,12 +49,11 @@ class TestNamePatternPrompt extends _jestWatcher.PatternPrompt {
44
49
  if (pattern) {
45
50
  (0, _pattern_mode_helpers.printPatternMatches)(total, 'test', pipe, ` from ${_chalk.default.yellow('cached')} test suites`);
46
51
  const width = (0, _utils.getTerminalWidth)(pipe);
47
-
48
- const _scroll = (0, _scroll2.default)(total, options),
49
- start = _scroll.start,
50
- end = _scroll.end,
51
- index = _scroll.index;
52
-
52
+ const {
53
+ start,
54
+ end,
55
+ index
56
+ } = (0, _scroll.default)(total, options);
53
57
  prompt.setPromptLength(total);
54
58
  matchedTests.slice(start, end).map(name => (0, _utils.formatTestNameByPattern)(name, pattern, width - 4)).map((item, i) => (0, _pattern_mode_helpers.formatTypeaheadSelection)(item, i, index, prompt)).forEach(item => (0, _pattern_mode_helpers.printTypeaheadItem)(item, pipe));
55
59
 
@@ -97,4 +101,4 @@ class TestNamePatternPrompt extends _jestWatcher.PatternPrompt {
97
101
 
98
102
  }
99
103
 
100
- module.exports = TestNamePatternPrompt;
104
+ exports.default = TestNamePatternPrompt;
@@ -1 +1,5 @@
1
- "use strict";
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
package/filename.js CHANGED
@@ -1,3 +1,4 @@
1
- const FileNamePlugin = require('./build/file_name_plugin/plugin');
1
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
2
+ const FileNamePlugin = require('./build/file_name_plugin/plugin').default;
2
3
 
3
4
  module.exports = FileNamePlugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jest-watch-typeahead",
3
- "version": "0.6.1",
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",
@@ -18,17 +18,17 @@
18
18
  "scripts": {
19
19
  "test": "jest",
20
20
  "lint": "eslint .",
21
- "watch": "babel src -w --ignore **/*.test.js,integration -d build",
22
21
  "prebuild": "rimraf build",
23
- "build": "babel src --ignore **/*.test.js,integration -d build",
22
+ "build": "babel --extensions .js,.ts src -d build && rimraf **/*.test.{js,ts},integration build/**/__tests__ build/test_utils",
24
23
  "prepublish": "yarn build",
25
- "format": "prettier --write \"**/*.js\" \"**/*.md\""
24
+ "format": "prettier --write \"**/*.js\" \"**/*.md\" \"**/*.ts\"",
25
+ "typecheck": "yarn tsc -p ."
26
26
  },
27
27
  "dependencies": {
28
28
  "ansi-escapes": "^4.3.1",
29
29
  "chalk": "^4.0.0",
30
- "jest-regex-util": "^26.0.0",
31
- "jest-watcher": "^26.3.0",
30
+ "jest-regex-util": "^27.0.0",
31
+ "jest-watcher": "^27.0.0",
32
32
  "slash": "^3.0.0",
33
33
  "string-length": "^4.0.1",
34
34
  "strip-ansi": "^6.0.0"
@@ -37,23 +37,30 @@
37
37
  "@babel/cli": "^7.8.4",
38
38
  "@babel/core": "^7.9.6",
39
39
  "@babel/preset-env": "^7.9.6",
40
- "@babel/preset-flow": "^7.9.0",
40
+ "@babel/preset-typescript": "^7.10.4",
41
+ "@jest/types": "^27.0.0",
42
+ "@semantic-release/changelog": "^5.0.1",
43
+ "@semantic-release/git": "^9.0.0",
44
+ "@types/jest": "^27.0.0",
45
+ "@types/node": "^14.6.4",
46
+ "@typescript-eslint/eslint-plugin": "^4.0.1",
47
+ "@typescript-eslint/parser": "^4.0.1",
41
48
  "babel-eslint": "^10.1.0",
42
- "babel-jest": "^26.0.0",
49
+ "babel-jest": "^27.0.0",
43
50
  "eslint": "^7.8.1",
44
51
  "eslint-config-airbnb-base": "^14.1.0",
45
- "eslint-config-prettier": "^6.11.0",
46
- "eslint-plugin-flowtype": "^5.2.0",
52
+ "eslint-config-prettier": "^8.0.0",
47
53
  "eslint-plugin-import": "^2.20.2",
48
54
  "eslint-plugin-jest": "^24.0.0",
49
55
  "eslint-plugin-prettier": "^3.1.3",
50
- "flow-bin": "^0.133.0",
51
- "jest": "^26.0.0",
56
+ "jest": "^27.0.0",
52
57
  "prettier": "^2.1.1",
53
- "rimraf": "^3.0.2"
58
+ "rimraf": "^3.0.2",
59
+ "semantic-release": "^17.4.3",
60
+ "typescript": "^4.0.2"
54
61
  },
55
62
  "peerDependencies": {
56
- "jest": "^26.0.0"
63
+ "jest": "^26.0.0 || ^27.0.0"
57
64
  },
58
65
  "jest": {
59
66
  "watchPlugins": [
@@ -74,5 +81,22 @@
74
81
  },
75
82
  "engines": {
76
83
  "node": ">=10"
84
+ },
85
+ "resolutions": {
86
+ "semantic-release/@semantic-release/github/fs-extra": "^9.0.0",
87
+ "semantic-release/@semantic-release/npm/fs-extra": "^9.0.0"
88
+ },
89
+ "release": {
90
+ "branches": [
91
+ "main"
92
+ ],
93
+ "plugins": [
94
+ "@semantic-release/commit-analyzer",
95
+ "@semantic-release/release-notes-generator",
96
+ "@semantic-release/changelog",
97
+ "@semantic-release/npm",
98
+ "@semantic-release/git",
99
+ "@semantic-release/github"
100
+ ]
77
101
  }
78
102
  }
package/testname.js CHANGED
@@ -1,3 +1,4 @@
1
- const TestNamePlugin = require('./build/test_name_plugin/plugin');
1
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
2
+ const TestNamePlugin = require('./build/test_name_plugin/plugin').default;
2
3
 
3
4
  module.exports = TestNamePlugin;
package/CHANGELOG.md DELETED
@@ -1,93 +0,0 @@
1
- ## 0.6.1
2
-
3
- ### Fixes
4
-
5
- - Provide exact pattern for selected test names
6
-
7
- ## 0.6.0
8
-
9
- ### Chore & Maintenance
10
-
11
- - Update dependencies and drop Node 8 ([#35](https://github.com/jest-community/jest-watch-typeahead/pull/35))
12
-
13
- ## 0.5.0
14
-
15
- ### Chore & Maintenance
16
-
17
- - Update dependencies
18
-
19
- ## 0.4.2
20
-
21
- ### Fixes
22
-
23
- - Fix issue with overly trimmed basenames when formatting test paths ([#33](https://github.com/jest-community/jest-watch-typeahead/pull/33))
24
-
25
- ## 0.4.1
26
-
27
- ### Fixes
28
-
29
- - Allow selecting tests and files containing regexp special characters ([#32](https://github.com/jest-community/jest-watch-typeahead/pull/32))
30
-
31
- ### Chore & Maintenance
32
-
33
- - Remove build directory before building ([#31](https://github.com/jest-community/jest-watch-typeahead/pull/31))
34
-
35
- ## 0.4.0
36
-
37
- ### Chore & Maintenance
38
-
39
- - Update dependencies and drop Node 6 ([#30](https://github.com/jest-community/jest-watch-typeahead/pull/30))
40
-
41
- ## 0.3.1
42
-
43
- ### Fixes
44
-
45
- - Helpful error message when attempting to use the package main file ([#29](https://github.com/jest-community/jest-watch-typeahead/pull/29))
46
-
47
- ## 0.3.0
48
-
49
- ### Chore & Maintenance
50
-
51
- - Bump dated dependencies ([#25](https://github.com/jest-community/jest-watch-typeahead/pull/25))
52
- - Get better truncation for testname typeahead by truncating the start and not the end ([#28](https://github.com/jest-community/jest-watch-typeahead/pull/28))
53
-
54
- ### Fixes
55
-
56
- - Use fullName(to show ancestor titles) for test name pattern plugin ([#26](https://github.com/jest-community/jest-watch-typeahead/pull/26))
57
-
58
- ## 0.2.1
59
-
60
- - Fix cursor in terminal app ([#21](https://github.com/jest-community/jest-watch-typeahead/pull/21))
61
-
62
- ### Chore & Maintenance
63
-
64
- - Bump dated dependencies ([#23](https://github.com/jest-community/jest-watch-typeahead/pull/23))
65
-
66
- ## 0.2.0
67
-
68
- ### Features
69
-
70
- - Add support for plugin config ([#13](https://github.com/jest-community/jest-watch-typeahead/pull/13))
71
-
72
- ### Fixes
73
-
74
- - Make matching case insensitive ([#18](https://github.com/jest-community/jest-watch-typeahead/pull/18))
75
- - fix: migrate to use jest-watcher ([#6](https://github.com/jest-community/jest-watch-typeahead/pull/6))
76
-
77
- ### Chore & Maintenance
78
-
79
- - Upgrade Prettier to 1.13.7 ([#17](https://github.com/jest-community/jest-watch-typeahead/pull/17))
80
- - New directory structure ([#14](https://github.com/jest-community/jest-watch-typeahead/pull/14))
81
- - Move ansi-escapes to dependencies _23f22d4_
82
- - Setup Travis and add tests ([#12](https://github.com/jest-community/jest-watch-typeahead/pull/12))
83
-
84
- ## 0.1.0
85
-
86
- ### Features
87
-
88
- - Add test name typeahead ([#1](https://github.com/jest-community/jest-watch-typeahead/pull/1))
89
- - Rename to jest-watch-typeahead
90
-
91
- ## 0.0.1
92
-
93
- Initial Release
@@ -1,61 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
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
- const 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
- config: options.config
46
- });
47
- plugin.apply(jestHooks.getSubscriber());
48
-
49
- const type = (...keys) => keys.forEach(key => plugin.onKey(key));
50
-
51
- return {
52
- stdout,
53
- hookEmitter: jestHooks.getEmitter(),
54
- updateConfigAndRun: jest.fn(),
55
- plugin,
56
- type
57
- };
58
- };
59
-
60
- var _default = pluginTester;
61
- exports.default = _default;