How to use the jest-editor-support.parse function in jest-editor-support

To help you get started, we’ve selected a few jest-editor-support 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 / codeLens / provideLwcTestCodeLens.ts View on Github external
export async function provideLwcTestCodeLens(
  document: TextDocument,
  token: CancellationToken
): Promise {
  const fsPath = document.uri.fsPath;
  const parseResults = parse(fsPath, document.getText());
  const { itBlocks } = parseResults;
  return itBlocks
    .map(itBlock => {
      const { name, nameRange, start, end } = itBlock;
      // VS Code position is zero-based
      const range = new Range(
        new Position(nameRange.start.line - 1, nameRange.start.column - 1),
        new Position(nameRange.end.line - 1, nameRange.end.column - 1)
      );

      const testExecutionInfo: TestExecutionInfo = {
        kind: TestInfoKind.TEST_CASE,
        testType: TestType.LWC,
        testUri: document.uri,
        testName: name
      };
github forcedotcom / salesforcedx-vscode / packages / salesforcedx-vscode-lwc / src / testSupport / testExplorer / testIndexer.ts View on Github external
export async function findTestInfoFromLwcJestTestFile(testUri: vscode.Uri) {
  if (testInfoMap.has(testUri)) {
    return testInfoMap.get(testUri);
  }
  // parse
  const { fsPath } = testUri;
  const { itBlocks } = parse(fsPath);
  const testInfo = itBlocks.map(itBlock => {
    const { name, nameRange, start, end } = itBlock;
    const testName = name;
    const testRange = new vscode.Range(
      new vscode.Position(nameRange.start.line - 1, nameRange.start.column - 1),
      new vscode.Position(nameRange.end.line - 1, nameRange.end.column)
    );
    const testLocation = new vscode.Location(testUri, testRange);
    return {
      testType: TestType.LWC,
      testName,
      testUri,
      testLocation
    };
  });
  testInfoMap.set(testUri, testInfo);
github firsttris / vscode-jest-runner / src / jestRunner.ts View on Github external
private findCurrentTestName(editor: vscode.TextEditor): string {
    // from selection
    const { selection, document } = editor;
    if (!selection.isEmpty) {
      return unquote(document.getText(selection));
    }

    const selectedLine = selection.active.line + 1;
    const filePath = editor.document.fileName;
    const testFile = parse(filePath);

    return exactRegexMatch(escapeRegExp(findFullTestName(selectedLine, testFile.root.children)));
  }
github forcedotcom / salesforcedx-vscode / packages / salesforcedx-vscode-lwc / src / testSupport / testIndexer / lwcTestIndexer.ts View on Github external
private parseTestFileAndMergeTestResults(
    testFileInfo: TestFileInfo
  ): TestCaseInfo[] {
    try {
      const { testUri } = testFileInfo;
      const { fsPath: testFsPath } = testUri;
      const parseResults = parse(testFsPath) as IExtendedParseResults;
      populateAncestorTitles(parseResults);
      const itBlocks = (parseResults.itBlocksWithAncestorTitles ||
        parseResults.itBlocks) as ItBlockWithAncestorTitles[];
      const testCasesInfo: TestCaseInfo[] = itBlocks.map(itBlock => {
        const { name, nameRange, ancestorTitles } = itBlock;
        const testName = name;
        const testRange = new vscode.Range(
          new vscode.Position(
            nameRange.start.line - 1,
            nameRange.start.column - 1
          ),
          new vscode.Position(nameRange.end.line - 1, nameRange.end.column)
        );
        const testLocation = new vscode.Location(testUri, testRange);
        const testCaseInfo: TestCaseInfo = {
          kind: TestInfoKind.TEST_CASE,
github jest-community / vscode-jest / src / TestParser.ts View on Github external
export function parseTest(filePath: string): IParseResults {
  return parse(filePath)
}

jest-editor-support

[![Build Status](https://github.com/jest-community/jest-editor-support/actions/workflows/node-ci.yml/badge.svg)](https://github.com/jest-community/jest-editor-support/actions) [![Coverage Status](https://coveralls.io/repos/github/jest-community/jest-edito

MIT
Latest version published 7 months ago

Package Health Score

58 / 100
Full package analysis

Similar packages