Socket
Socket
Sign inDemoInstall

jest-watch-typeahead

Package Overview
Dependencies
313
Maintainers
8
Versions
30
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.2.0 to 2.2.1

5

build/file_name_plugin/plugin.js

@@ -18,3 +18,2 @@ import { Prompt } from 'jest-watcher';

}
apply(jestHooks) {

@@ -27,7 +26,5 @@ jestHooks.onFileChange(({

}
onKey(key) {
this._prompt.put(key);
}
run(globalConfig, updateConfigAndRun) {

@@ -46,7 +43,5 @@ const p = new FileNamePatternPrompt(this._stdout, this._prompt);

}
getUsageInfo() {
return this._usageInfo;
}
}

@@ -15,12 +15,8 @@ import chalk from 'chalk';

}
_onChange(pattern, options) {
super._onChange(pattern, options);
this._printTypeahead(pattern, options);
}
_printTypeahead(pattern, options) {
const matchedTests = this._getMatchedTests(pattern);
const total = matchedTests.length;

@@ -31,3 +27,2 @@ const pipe = this._pipe;

pipe.write(ansiEscapes.cursorLeft);
if (pattern) {

@@ -51,3 +46,2 @@ printPatternMatches(total, 'file', pipe);

}).map((item, i) => formatTypeaheadSelection(item, i, index, prompt)).forEach(item => printTypeaheadItem(item, pipe));
if (total > end) {

@@ -59,9 +53,6 @@ printMore('file', pipe, total - end);

}
printRestoredPatternCaret(pattern, this._currentUsageRows, pipe);
}
_getMatchedTests(pattern) {
let regex;
try {

@@ -72,3 +63,2 @@ regex = new RegExp(pattern, 'i');

}
return this._searchSources.reduce((tests, {

@@ -86,7 +76,5 @@ testPaths,

}
updateSearchSources(searchSources) {
this._searchSources = searchSources;
}
run(onSuccess, onCancel, options) {

@@ -97,3 +85,2 @@ super.run(value => {

}
}

3

build/lib/pattern_mode_helpers.js
import chalk from 'chalk';
import stripAnsi from 'strip-ansi';
const pluralize = (count, text) => count === 1 ? text : `${text}s`;
export const printPatternMatches = (count, entity, pipe, extraText = '') => {

@@ -25,4 +23,3 @@ const pluralized = pluralize(count, entity);

}
return item;
};

@@ -8,3 +8,2 @@ const scroll = (size, {

const halfScreen = max / 2;
if (index <= halfScreen) {

@@ -16,6 +15,4 @@ start = 0;

}
index = Math.min(index - start, size);
}
return {

@@ -27,3 +24,2 @@ end: Math.min(size, start + max),

};
export default scroll;

@@ -7,3 +7,2 @@ import path from 'path';

const ENTER = '⏎';
const relativePath = (config, testPath) => {

@@ -18,5 +17,3 @@ const relativeTestPath = path.relative(config.cwd || config.rootDir, testPath);

};
const colorize = (str, start, end) => chalk.dim(str.slice(0, start)) + chalk.reset(str.slice(start, end)) + chalk.dim(str.slice(end));
export const trimAndFormatPath = (pad, config, testPath, columns) => {

@@ -30,11 +27,11 @@ const maxLength = columns - pad;

dirname
} = relative; // length is ok
} = relative;
// length is ok
if ((dirname + path.sep + basename).length <= maxLength) {
return slash(chalk.dim(dirname + path.sep) + chalk.bold(basename));
} // we can fit trimmed dirname and full basename
}
// we can fit trimmed dirname and full basename
const basenameLength = basename.length;
if (basenameLength + 4 < maxLength) {

@@ -45,8 +42,6 @@ const dirnameLength = maxLength - 4 - basenameLength;

}
if (basenameLength + 4 === maxLength) {
return slash(chalk.dim(`${TRIMMING_DOTS}${path.sep}`) + chalk.bold(basename));
} // can't fit dirname, but can fit trimmed basename
}
// can't fit dirname, but can fit trimmed basename
return slash(chalk.bold(`${TRIMMING_DOTS}${basename.slice(-maxLength + 3)}`));

@@ -58,3 +53,2 @@ };

let regexp;
try {

@@ -65,14 +59,10 @@ regexp = new RegExp(pattern, 'i');

}
const strippedRawPath = stripAnsi(rawPath);
const strippedFilePath = stripAnsi(filePath);
const match = strippedRawPath.match(regexp);
if (!match || match.index == null) {
return chalk.dim(strippedFilePath);
}
const offset = strippedRawPath.length - strippedFilePath.length;
let trimLength;
if (strippedFilePath.startsWith(TRIMMING_DOTS)) {

@@ -85,3 +75,2 @@ trimLength = TRIMMING_DOTS.length;

}
const start = match.index - offset;

@@ -94,3 +83,2 @@ const end = start + match[0].length;

let regexp;
try {

@@ -101,17 +89,12 @@ regexp = new RegExp(pattern, 'i');

}
const match = inlineTestName.match(regexp);
if (!match || match.index == null) {
return chalk.dim(inlineTestName);
}
const startPatternIndex = Math.max(match.index, 0);
const endPatternIndex = startPatternIndex + match[0].length;
const testNameFitsInTerminal = inlineTestName.length <= width;
if (testNameFitsInTerminal) {
return colorize(inlineTestName, startPatternIndex, endPatternIndex);
}
const numberOfTruncatedChars = TRIMMING_DOTS.length + inlineTestName.length - width;

@@ -121,7 +104,5 @@ const end = Math.max(endPatternIndex - numberOfTruncatedChars, 0);

const shouldHighlightDots = startPatternIndex <= numberOfTruncatedChars;
if (shouldHighlightDots) {
return colorize(TRIMMING_DOTS + truncatedTestName, 0, end + TRIMMING_DOTS.length);
}
const start = startPatternIndex - numberOfTruncatedChars;

@@ -134,4 +115,3 @@ return colorize(TRIMMING_DOTS + truncatedTestName, start + TRIMMING_DOTS.length, end + TRIMMING_DOTS.length);

}
return value;
};

@@ -18,3 +18,2 @@ import { Prompt } from 'jest-watcher';

}
apply(jestHooks) {

@@ -27,7 +26,5 @@ jestHooks.onTestRunComplete(({

}
onKey(key) {
this._prompt.put(key);
}
run(globalConfig, updateConfigAndRun) {

@@ -46,7 +43,5 @@ const p = new TestNamePatternPrompt(this._stdout, this._prompt);

}
getUsageInfo() {
return this._usageInfo;
}
}

@@ -15,14 +15,9 @@ import chalk from 'chalk';

}
_onChange(pattern, options) {
super._onChange(pattern, options);
this._offset = options.offset;
this._printTypeahead(pattern, options);
}
_printTypeahead(pattern, options) {
const matchedTests = this._getMatchedTests(pattern);
const total = matchedTests.length;

@@ -33,3 +28,2 @@ const pipe = this._pipe;

pipe.write(ansiEscapes.cursorLeft);
if (pattern) {

@@ -45,3 +39,2 @@ printPatternMatches(total, 'test', pipe, ` from ${chalk.yellow('cached')} test suites`);

matchedTests.slice(start, end).map(name => formatTestNameByPattern(name, pattern, width - 4)).map((item, i) => formatTypeaheadSelection(item, i, index, prompt)).forEach(item => printTypeaheadItem(item, pipe));
if (total > end) {

@@ -53,9 +46,6 @@ printMore('test', pipe, total - end);

}
printRestoredPatternCaret(pattern, this._currentUsageRows, pipe);
}
_getMatchedTests(pattern) {
let regex;
try {

@@ -66,3 +56,2 @@ regex = new RegExp(pattern, 'i');

}
return this._cachedTestResults.reduce((matchedTests, {

@@ -78,7 +67,5 @@ testResults

}
updateCachedTestResults(testResults = []) {
this._cachedTestResults = testResults;
}
run(onSuccess, onCancel, options) {

@@ -91,3 +78,2 @@ super.run(value => {

}
}

13

package.json
{
"name": "jest-watch-typeahead",
"version": "2.2.0",
"version": "2.2.1",
"main": "build/index.js",

@@ -35,7 +35,7 @@ "exports": {

"dependencies": {
"ansi-escapes": "^5.0.0",
"ansi-escapes": "^6.0.0",
"chalk": "^4.0.0",
"jest-regex-util": "^29.0.0",
"jest-watcher": "^29.0.0",
"slash": "^4.0.0",
"slash": "^5.0.0",
"string-length": "^5.0.1",

@@ -53,3 +53,3 @@ "strip-ansi": "^7.0.1"

"@semantic-release/git": "^10.0.1",
"@types/node": "^16.0.0",
"@types/node": "^14.0.0",
"@typescript-eslint/eslint-plugin": "^5.0.0",

@@ -114,3 +114,6 @@ "@typescript-eslint/parser": "^5.0.0",

},
"packageManager": "yarn@3.2.3"
"packageManager": "yarn@3.3.0",
"resolutions": {
"ansi-escapes/type-fest": "^3.0.0"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc