How to use jest-watcher - 10 common examples

To help you get started, we’ve selected a few jest-watcher examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jest-community / jest-watch-typeahead / src / test_name_plugin / prompt.js View on Github external
_printTypeahead(pattern: string, options: ScrollOptions) {
    const matchedTests = this._getMatchedTests(pattern);
    const total = matchedTests.length;
    const pipe = this._pipe;
    const prompt = this._prompt;

    printPatternCaret(pattern, pipe);

    pipe.write(ansiEscapes.cursorLeft);

    if (pattern) {
      printPatternMatches(
        total,
        'test',
        pipe,
        ` from ${chalk.yellow('cached')} test suites`,
      );

      const width = getTerminalWidth(pipe);
      const { start, end, index } = scroll(total, options);

      prompt.setPromptLength(total);
github jest-community / jest-watch-typeahead / src / test_name_plugin / prompt.js View on Github external
prompt.setPromptLength(total);

      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) {
        printMore('test', pipe, total - end);
      }
    } else {
      printStartTyping('test name', pipe);
    }

    printRestoredPatternCaret(pattern, this._currentUsageRows, pipe);
  }
github sikidamjanovic / cowrite / node_modules / jest-watch-typeahead / build / test_utils / pluginTester.js View on Github external
const pluginTester = (Plugin, config = {}) => {
  const stdout = {
    columns: 80,
    write: jest.fn()
  };
  const jestHooks = new _jestWatcher.JestHook();
  const plugin = new Plugin({
    stdout,
    config
  });
  plugin.apply(jestHooks.getSubscriber());

  const type = (...keys) => keys.forEach(key => plugin.onKey(key));

  return {
    stdout,
    hookEmitter: jestHooks.getEmitter(),
    updateConfigAndRun: jest.fn(),
    plugin,
    type
  };
};
github jest-community / jest-watch-typeahead / src / test_utils / pluginTester.js View on Github external
const pluginTester = (Plugin, options = {}) => {
  const stdout = {
    columns: (options.stdout || {}).columns || 80,
    write: jest.fn(),
  };
  const jestHooks = new JestHook();
  const plugin = new Plugin({ stdout, config: options.config });
  plugin.apply(jestHooks.getSubscriber());

  const type = (...keys) => keys.forEach(key => plugin.onKey(key));

  return {
    stdout,
    hookEmitter: jestHooks.getEmitter(),
    updateConfigAndRun: jest.fn(),
    plugin,
    type,
  };
};
github jest-community / jest-watch-typeahead / src / test_name_plugin / plugin.js View on Github external
constructor({
    stdin,
    stdout,
    config = {},
  }: {
    stdin: stream$Readable | tty$ReadStream,
    stdout: stream$Writable | tty$WriteStream,
    config: PluginConfig,
  }) {
    this._stdin = stdin;
    this._stdout = stdout;
    this._prompt = new Prompt();
    this._testResults = [];
    this._usageInfo = {
      key: config.key || 't',
      prompt: config.prompt || 'filter by a test name regex pattern',
    };
  }
github jest-community / jest-watch-typeahead / src / file_name_plugin / prompt.js View on Github external
_printTypeahead(pattern: string, options: ScrollOptions) {
    const matchedTests = this._getMatchedTests(pattern);
    const total = matchedTests.length;
    const pipe = this._pipe;
    const prompt = this._prompt;

    printPatternCaret(pattern, pipe);

    pipe.write(ansiEscapes.cursorLeft);

    if (pattern) {
      printPatternMatches(total, 'file', pipe);

      const prefix = `  ${chalk.dim('\u203A')} `;
      const padding = stringLength(prefix) + 2;
      const width = getTerminalWidth(pipe);
      const { start, end, index } = scroll(total, options);

      prompt.setPromptLength(total);

      matchedTests
        .slice(start, end)
        .map(({ path, context }) => {
github jest-community / jest-watch-typeahead / src / file_name_plugin / prompt.js View on Github external
path,
            width,
          );
          return highlight(path, filePath, pattern, context.config.rootDir);
        })
        .map((item, i) => formatTypeaheadSelection(item, i, index, prompt))
        .forEach(item => printTypeaheadItem(item, pipe));

      if (total > end) {
        printMore('file', pipe, total - end);
      }
    } else {
      printStartTyping('filename', pipe);
    }

    printRestoredPatternCaret(pattern, this._currentUsageRows, pipe);
  }
github jest-community / jest-watch-typeahead / src / file_name_plugin / plugin.js View on Github external
constructor({
    stdin,
    stdout,
    config = {},
  }: {
    stdin: stream$Readable | tty$ReadStream,
    stdout: stream$Writable | tty$WriteStream,
    config: PluginConfig,
  }) {
    this._stdin = stdin;
    this._stdout = stdout;
    this._prompt = new Prompt();
    this._projects = [];
    this._usageInfo = {
      key: config.key || 'p',
      prompt: config.prompt || 'filter by a filename regex pattern',
    };
  }
github facebook / jest / packages / jest-core / src / lib / handle_deprecation_warnings.ts View on Github external
stdin.on('data', (key: string) => {
        if (key === KEYS.ENTER) {
          resolve();
        } else if (
          [KEYS.ESCAPE, KEYS.CONTROL_C, KEYS.CONTROL_D].indexOf(key) !== -1
        ) {
          reject();
        }
      });
    } else {
github facebook / jest / packages / jest-core / src / lib / handle_deprecation_warnings.ts View on Github external
stdin.on('data', (key: string) => {
        if (key === KEYS.ENTER) {
          resolve();
        } else if (
          [KEYS.ESCAPE, KEYS.CONTROL_C, KEYS.CONTROL_D].indexOf(key) !== -1
        ) {
          reject();
        }
      });
    } else {

jest-watcher

Delightful JavaScript Testing.

MIT
Latest version published 1 year ago

Package Health Score

88 / 100
Full package analysis

Similar packages