How to use the jest-regex-util.escapeStrForRegex function in jest-regex-util

To help you get started, we’ve selected a few jest-regex-util 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 forcedotcom / salesforcedx-vscode / packages / salesforcedx-vscode-lwc / src / testSupport / testRunner / testRunner.ts View on Github external
const testResultFileName = `test-result-${testRunId}.json`;
    const outputFilePath = path.join(tempFolder, testResultFileName);
    // Specify --runTestsByPath if running test on individual files
    let runTestsByPathArgs: string[];
    if (kind === TestInfoKind.TEST_FILE || kind === TestInfoKind.TEST_CASE) {
      const workspaceFolderFsPath = workspaceFolder.uri.fsPath;
      runTestsByPathArgs = [
        '--runTestsByPath',
        normalizeRunTestsByPath(workspaceFolderFsPath, testFsPath)
      ];
    } else {
      runTestsByPathArgs = [];
    }
    const testNamePatternArgs = testName
      ? ['--testNamePattern', `"${escapeStrForRegex(testName)}"`]
      : [];

    let runModeArgs: string[];
    if (testRunType === TestRunType.WATCH) {
      runModeArgs = ['--watch'];
    } else {
      runModeArgs = [];
    }
    const args = [
      ...runModeArgs,
      '--json',
      '--outputFile',
      outputFilePath,
      '--testLocationInResults',
      ...runTestsByPathArgs,
      ...testNamePatternArgs
github forcedotcom / salesforcedx-vscode / packages / salesforcedx-vscode-lwc / src / testSupport / testIndexer / jestUtils.ts View on Github external
export function extractPositionFromFailureMessage(
  testFsPath: string,
  failureMessage: string
) {
  try {
    const locationMatcher = new RegExp(
      escapeStrForRegex(testFsPath) + '\\:(\\d+)\\:(\\d+)',
      'i'
    );
    const matchResult = failureMessage.match(locationMatcher);
    if (matchResult) {
      const lineString = matchResult[1];
      const columnString = matchResult[2];
      const line = parseInt(lineString, 10);
      const column = parseInt(columnString, 10);
      if (isNaN(line) || isNaN(column)) {
        return undefined;
      }
      return new vscode.Position(line - 1, column - 1);
    }
    return undefined;
  } catch (error) {
    return undefined;
github jest-community / jest-watch-typeahead / src / test_name_plugin / plugin.js View on Github external
p.run(value => {
        updateConfigAndRun({
          mode: 'watch',
          testNamePattern: escapeStrForRegex(removeTrimmingDots(value)),
        });
        res();
      }, rej);
    });

jest-regex-util

MIT
Latest version published 8 months ago

Package Health Score

91 / 100
Full package analysis