jest-watch-typeahead 0.3.0 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,4 +1,16 @@
1
- ## master
1
+ ## 0.4.0
2
+
3
+ ### Chore & Maintenance
4
+
5
+ - Update dependencies and drop Node 6 ([#30](https://github.com/jest-community/jest-watch-typeahead/pull/30))
6
+
7
+ ## 0.3.1
8
+
9
+ ### Fixes
10
+
11
+ - Helpful error message when attempting to use the package main file ([#29](https://github.com/jest-community/jest-watch-typeahead/pull/29))
12
+
13
+ ## 0.3.0
2
14
 
3
15
  ### Chore & Maintenance
4
16
 
@@ -2,8 +2,12 @@
2
2
 
3
3
  var _jestWatcher = require("jest-watcher");
4
4
 
5
+ var _jestRegexUtil = require("jest-regex-util");
6
+
5
7
  var _prompt = _interopRequireDefault(require("./prompt"));
6
8
 
9
+ var _utils = require("../lib/utils");
10
+
7
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
12
 
9
13
  class FileNamePlugin {
@@ -41,7 +45,7 @@ class FileNamePlugin {
41
45
  p.run(value => {
42
46
  updateConfigAndRun({
43
47
  mode: 'watch',
44
- testPathPattern: value
48
+ testPathPattern: (0, _utils.removeTrimmingDots)(value).split('/').map(_jestRegexUtil.escapeStrForRegex).join('/')
45
49
  });
46
50
  res();
47
51
  }, rej);
package/build/index.js ADDED
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ throw new Error(`
4
+ jest-watch-typeahead includes two watch plugins: The filename plugin and the testname plugin.
5
+ Please configure Jest as follows:
6
+ "watchPlugins": [
7
+ "jest-watch-typeahead/filename",
8
+ "jest-watch-typeahead/testname"
9
+ ]
10
+ `);
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.formatTestNameByPattern = exports.highlight = exports.getTerminalWidth = exports.trimAndFormatPath = void 0;
6
+ exports.removeTrimmingDots = exports.formatTestNameByPattern = exports.highlight = exports.getTerminalWidth = exports.trimAndFormatPath = void 0;
7
7
 
8
8
  var _path = _interopRequireDefault(require("path"));
9
9
 
@@ -16,6 +16,9 @@ var _stripAnsi = _interopRequireDefault(require("strip-ansi"));
16
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
17
 
18
18
  /* eslint-disable no-param-reassign */
19
+ const TRIMMING_DOTS = '...';
20
+ const ENTER = '⏎';
21
+
19
22
  const relativePath = (config, testPath) => {
20
23
  testPath = _path.default.relative(config.cwd || config.rootDir, testPath);
21
24
 
@@ -46,16 +49,16 @@ const trimAndFormatPath = (pad, config, testPath, columns) => {
46
49
 
47
50
  if (basenameLength + 4 < maxLength) {
48
51
  const dirnameLength = maxLength - 4 - basenameLength;
49
- dirname = `...${dirname.slice(dirname.length - dirnameLength, dirname.length)}`;
52
+ dirname = `${TRIMMING_DOTS}${dirname.slice(dirname.length - dirnameLength, dirname.length)}`;
50
53
  return (0, _slash.default)(_chalk.default.dim(dirname + _path.default.sep) + _chalk.default.bold(basename));
51
54
  }
52
55
 
53
56
  if (basenameLength + 4 === maxLength) {
54
- return (0, _slash.default)(_chalk.default.dim(`...${_path.default.sep}`) + _chalk.default.bold(basename));
57
+ return (0, _slash.default)(_chalk.default.dim(`${TRIMMING_DOTS}${_path.default.sep}`) + _chalk.default.bold(basename));
55
58
  } // can't fit dirname, but can fit trimmed basename
56
59
 
57
60
 
58
- return (0, _slash.default)(_chalk.default.bold(`...${basename.slice(basename.length - maxLength - 4, basename.length)}`));
61
+ return (0, _slash.default)(_chalk.default.bold(`${TRIMMING_DOTS}${basename.slice(-maxLength + 3)}`));
59
62
  };
60
63
 
61
64
  exports.trimAndFormatPath = trimAndFormatPath;
@@ -65,7 +68,6 @@ const getTerminalWidth = (pipe = process.stdout) => pipe.columns;
65
68
  exports.getTerminalWidth = getTerminalWidth;
66
69
 
67
70
  const highlight = (rawPath, filePath, pattern, rootDir) => {
68
- const trim = '...';
69
71
  const relativePathHead = './';
70
72
  let regexp;
71
73
 
@@ -86,9 +88,9 @@ const highlight = (rawPath, filePath, pattern, rootDir) => {
86
88
  let offset;
87
89
  let trimLength;
88
90
 
89
- if (filePath.startsWith(trim)) {
91
+ if (filePath.startsWith(TRIMMING_DOTS)) {
90
92
  offset = rawPath.length - filePath.length;
91
- trimLength = trim.length;
93
+ trimLength = TRIMMING_DOTS.length;
92
94
  } else if (filePath.startsWith(relativePathHead)) {
93
95
  offset = rawPath.length - filePath.length;
94
96
  trimLength = relativePathHead.length;
@@ -103,8 +105,6 @@ const highlight = (rawPath, filePath, pattern, rootDir) => {
103
105
  };
104
106
 
105
107
  exports.highlight = highlight;
106
- const DOTS = '...';
107
- const ENTER = '⏎';
108
108
 
109
109
  const formatTestNameByPattern = (testName, pattern, width) => {
110
110
  const inlineTestName = testName.replace(/(\r\n|\n|\r)/gm, ENTER);
@@ -131,17 +131,27 @@ const formatTestNameByPattern = (testName, pattern, width) => {
131
131
  return colorize(inlineTestName, startPatternIndex, endPatternIndex);
132
132
  }
133
133
 
134
- const numberOfTruncatedChars = DOTS.length + inlineTestName.length - width;
134
+ const numberOfTruncatedChars = TRIMMING_DOTS.length + inlineTestName.length - width;
135
135
  const end = Math.max(endPatternIndex - numberOfTruncatedChars, 0);
136
136
  const truncatedTestName = inlineTestName.slice(numberOfTruncatedChars);
137
137
  const shouldHighlightDots = startPatternIndex <= numberOfTruncatedChars;
138
138
 
139
139
  if (shouldHighlightDots) {
140
- return colorize(DOTS + truncatedTestName, 0, end + DOTS.length);
140
+ return colorize(TRIMMING_DOTS + truncatedTestName, 0, end + TRIMMING_DOTS.length);
141
141
  }
142
142
 
143
143
  const start = startPatternIndex - numberOfTruncatedChars;
144
- return colorize(DOTS + truncatedTestName, start + DOTS.length, end + DOTS.length);
144
+ return colorize(TRIMMING_DOTS + truncatedTestName, start + TRIMMING_DOTS.length, end + TRIMMING_DOTS.length);
145
+ };
146
+
147
+ exports.formatTestNameByPattern = formatTestNameByPattern;
148
+
149
+ const removeTrimmingDots = value => {
150
+ if (value.startsWith(TRIMMING_DOTS)) {
151
+ return value.slice(TRIMMING_DOTS.length);
152
+ }
153
+
154
+ return value;
145
155
  };
146
156
 
147
- exports.formatTestNameByPattern = formatTestNameByPattern;
157
+ exports.removeTrimmingDots = removeTrimmingDots;
@@ -2,8 +2,12 @@
2
2
 
3
3
  var _jestWatcher = require("jest-watcher");
4
4
 
5
+ var _jestRegexUtil = require("jest-regex-util");
6
+
5
7
  var _prompt = _interopRequireDefault(require("./prompt"));
6
8
 
9
+ var _utils = require("../lib/utils");
10
+
7
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
12
 
9
13
  class TestNamePlugin {
@@ -41,7 +45,7 @@ class TestNamePlugin {
41
45
  p.run(value => {
42
46
  updateConfigAndRun({
43
47
  mode: 'watch',
44
- testNamePattern: value
48
+ testNamePattern: (0, _jestRegexUtil.escapeStrForRegex)((0, _utils.removeTrimmingDots)(value))
45
49
  });
46
50
  res();
47
51
  }, rej);
@@ -33,26 +33,16 @@ expect.addSnapshotSerializer({
33
33
  test: val => val.includes(WINDOWS_CLEAR),
34
34
  print: val => (0, _stripAnsi.default)(val.replace(WINDOWS_CLEAR, '[MOCK - clear]'))
35
35
  });
36
- jest.mock('ansi-escapes', () => ({
37
- clearScreen: '[MOCK - clearScreen]',
38
- cursorDown: (count = 1) => `[MOCK - cursorDown(${count})]`,
39
- cursorLeft: '[MOCK - cursorLeft]',
40
- cursorHide: '[MOCK - cursorHide]',
41
- cursorRestorePosition: '[MOCK - cursorRestorePosition]',
42
- cursorSavePosition: '[MOCK - cursorSavePosition]',
43
- cursorShow: '[MOCK - cursorShow]',
44
- cursorTo: (x, y) => `[MOCK - cursorTo(${x}, ${y})]`
45
- }));
46
36
 
47
- const pluginTester = (Plugin, config = {}) => {
37
+ const pluginTester = (Plugin, options = {}) => {
48
38
  const stdout = {
49
- columns: 80,
39
+ columns: (options.stdout || {}).columns || 80,
50
40
  write: jest.fn()
51
41
  };
52
42
  const jestHooks = new _jestWatcher.JestHook();
53
43
  const plugin = new Plugin({
54
44
  stdout,
55
- config
45
+ config: options.config
56
46
  });
57
47
  plugin.apply(jestHooks.getSubscriber());
58
48
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jest-watch-typeahead",
3
- "version": "0.3.0",
3
+ "version": "0.4.2",
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,16 +19,18 @@
19
19
  "test": "jest",
20
20
  "lint": "eslint .",
21
21
  "watch": "babel src -w --ignore **/*.test.js,integration -d build",
22
+ "prebuild": "rimraf build",
22
23
  "build": "babel src --ignore **/*.test.js,integration -d build",
23
24
  "prepublish": "yarn build",
24
25
  "format": "prettier --single-quote --trailing-comma all --write \"!(build)/**/*.js\""
25
26
  },
26
27
  "dependencies": {
27
- "ansi-escapes": "^3.0.0",
28
+ "ansi-escapes": "^4.2.1",
28
29
  "chalk": "^2.4.1",
30
+ "jest-regex-util": "^24.9.0",
29
31
  "jest-watcher": "^24.3.0",
30
- "slash": "^2.0.0",
31
- "string-length": "^2.0.0",
32
+ "slash": "^3.0.0",
33
+ "string-length": "^3.1.0",
32
34
  "strip-ansi": "^5.0.0"
33
35
  },
34
36
  "devDependencies": {
@@ -39,16 +41,17 @@
39
41
  "babel-core": "^7.0.0-bridge.0",
40
42
  "babel-eslint": "^10.0.1",
41
43
  "babel-jest": "^24.3.0",
42
- "eslint": "^5.12.1",
43
- "eslint-config-airbnb-base": "^13.1.0",
44
- "eslint-config-prettier": "^4.1.0",
45
- "eslint-plugin-flowtype": "^3.2.1",
44
+ "eslint": "^6.2.0",
45
+ "eslint-config-airbnb-base": "^14.0.0",
46
+ "eslint-config-prettier": "^6.1.0",
47
+ "eslint-plugin-flowtype": "^4.2.0",
46
48
  "eslint-plugin-import": "^2.9.0",
47
49
  "eslint-plugin-jest": "^22.1.3",
48
50
  "eslint-plugin-prettier": "^3.0.1",
49
- "flow-bin": "^0.94.0",
51
+ "flow-bin": "^0.105.2",
50
52
  "jest": "^24.3.0",
51
- "prettier": "^1.13.7"
53
+ "prettier": "^1.13.7",
54
+ "rimraf": "^3.0.0"
52
55
  },
53
56
  "jest": {
54
57
  "watchPlugins": [
@@ -61,6 +64,10 @@
61
64
  "testPathIgnorePatterns": [
62
65
  "<rootDir>/build/.*",
63
66
  "<rootDir>/src/__tests__/pluginTester.js"
67
+ ],
68
+ "transformIgnorePatterns": [
69
+ "/node_modules/",
70
+ "/__mocks__/"
64
71
  ]
65
72
  }
66
73
  }