jest-watch-typeahead 0.2.2-0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,8 +1,21 @@
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
 
5
17
  - Bump dated dependencies ([#25](https://github.com/jest-community/jest-watch-typeahead/pull/25))
18
+ - 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))
6
19
 
7
20
  ### Fixes
8
21
 
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
+ `);
@@ -125,22 +125,23 @@ const formatTestNameByPattern = (testName, pattern, width) => {
125
125
 
126
126
  const startPatternIndex = Math.max(match.index, 0);
127
127
  const endPatternIndex = startPatternIndex + match[0].length;
128
+ const testNameFitsInTerminal = inlineTestName.length <= width;
128
129
 
129
- if (inlineTestName.length <= width) {
130
+ if (testNameFitsInTerminal) {
130
131
  return colorize(inlineTestName, startPatternIndex, endPatternIndex);
131
132
  }
132
133
 
133
- const slicedTestName = inlineTestName.slice(0, width - DOTS.length);
134
+ const numberOfTruncatedChars = DOTS.length + inlineTestName.length - width;
135
+ const end = Math.max(endPatternIndex - numberOfTruncatedChars, 0);
136
+ const truncatedTestName = inlineTestName.slice(numberOfTruncatedChars);
137
+ const shouldHighlightDots = startPatternIndex <= numberOfTruncatedChars;
134
138
 
135
- if (startPatternIndex < slicedTestName.length) {
136
- if (endPatternIndex > slicedTestName.length) {
137
- return colorize(slicedTestName + DOTS, startPatternIndex, slicedTestName.length + DOTS.length);
138
- }
139
-
140
- return colorize(slicedTestName + DOTS, Math.min(startPatternIndex, slicedTestName.length), endPatternIndex);
139
+ if (shouldHighlightDots) {
140
+ return colorize(DOTS + truncatedTestName, 0, end + DOTS.length);
141
141
  }
142
142
 
143
- return `${_chalk.default.dim(slicedTestName)}${_chalk.default.reset(DOTS)}`;
143
+ const start = startPatternIndex - numberOfTruncatedChars;
144
+ return colorize(DOTS + truncatedTestName, start + DOTS.length, end + DOTS.length);
144
145
  };
145
146
 
146
147
  exports.formatTestNameByPattern = formatTestNameByPattern;
@@ -33,16 +33,6 @@ 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
37
  const pluginTester = (Plugin, config = {}) => {
48
38
  const stdout = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jest-watch-typeahead",
3
- "version": "0.2.2-0",
3
+ "version": "0.4.0",
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",
@@ -24,11 +24,11 @@
24
24
  "format": "prettier --single-quote --trailing-comma all --write \"!(build)/**/*.js\""
25
25
  },
26
26
  "dependencies": {
27
- "ansi-escapes": "^3.0.0",
27
+ "ansi-escapes": "^4.2.1",
28
28
  "chalk": "^2.4.1",
29
29
  "jest-watcher": "^24.3.0",
30
- "slash": "^2.0.0",
31
- "string-length": "^2.0.0",
30
+ "slash": "^3.0.0",
31
+ "string-length": "^3.1.0",
32
32
  "strip-ansi": "^5.0.0"
33
33
  },
34
34
  "devDependencies": {
@@ -39,14 +39,14 @@
39
39
  "babel-core": "^7.0.0-bridge.0",
40
40
  "babel-eslint": "^10.0.1",
41
41
  "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",
42
+ "eslint": "^6.2.0",
43
+ "eslint-config-airbnb-base": "^14.0.0",
44
+ "eslint-config-prettier": "^6.1.0",
45
+ "eslint-plugin-flowtype": "^4.2.0",
46
46
  "eslint-plugin-import": "^2.9.0",
47
47
  "eslint-plugin-jest": "^22.1.3",
48
48
  "eslint-plugin-prettier": "^3.0.1",
49
- "flow-bin": "^0.94.0",
49
+ "flow-bin": "^0.105.2",
50
50
  "jest": "^24.3.0",
51
51
  "prettier": "^1.13.7"
52
52
  },
@@ -61,6 +61,10 @@
61
61
  "testPathIgnorePatterns": [
62
62
  "<rootDir>/build/.*",
63
63
  "<rootDir>/src/__tests__/pluginTester.js"
64
+ ],
65
+ "transformIgnorePatterns": [
66
+ "/node_modules/",
67
+ "/__mocks__/"
64
68
  ]
65
69
  }
66
70
  }