How to use jest-editor-support - 10 common examples

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 Raathigesh / majestic / app / src / renderer / stores / Runner.ts View on Github external
initializeRunner({ testFileNamePattern, testNamePattern }) {
    // @ts-ignore
    this.runner = new Runner(
      {
        rootPath: this.rootPath,
        pathToJest: this.pathToJest,
        localJestMajorVersion: this.localJestMajorVersion,
        pathToConfig: getConfigFilePath(this.rootPath)
      },
      {
        testFileNamePattern,
        testNamePattern,
        createProcess
      }
    );

    this.runner
      .on("executableJSON", (data: JestTotalResults) => {
        const results = this.reconciler.updateFileWithJestStatus(data);
github jest-community / vscode-jest / src / extensionManager.ts View on Github external
register(workspaceFolder: vscode.WorkspaceFolder) {
    if (!this.shouldStart(workspaceFolder.name)) {
      return
    }
    const pluginSettings = getExtensionResourceSettings(workspaceFolder.uri)
    const jestPath = pathToJest(pluginSettings)
    const configPath = pathToConfig(pluginSettings)
    const currentJestVersion = 20
    const debugMode = pluginSettings.debugMode
    const instanceSettings = {
      multirootEnv: vscode.workspace.workspaceFolders.length > 1,
    }
    const jestWorkspace = new ProjectWorkspace(
      pluginSettings.rootPath,
      jestPath,
      configPath,
      currentJestVersion,
      workspaceFolder.name,
      null,
      debugMode
    )

    // Create our own console
    const channel = vscode.window.createOutputChannel(`Jest (${workspaceFolder.name})`)

    const failDiagnostics = vscode.languages.createDiagnosticCollection(`Jest (${workspaceFolder.name})`)

    this.extByWorkspace.set(
      workspaceFolder.name,
github jest-community / vscode-jest / src / extension.ts View on Github external
export function activate(context: vscode.ExtensionContext) {
  // To make us VS Code agnostic outside of this file
  const pluginSettings = getExtensionSettings()
  const jestPath = pathToJest(pluginSettings)
  const configPath = pathToConfig(pluginSettings)
  const currentJestVersion = 20
  const debugMode = pluginSettings.debugMode
  const workspace = new ProjectWorkspace(
    pluginSettings.rootPath,
    jestPath,
    configPath,
    currentJestVersion,
    null,
    debugMode
  )

  // Create our own console
  const channel = vscode.window.createOutputChannel('Jest')

  // We need a singleton to represent the extension
  extensionInstance = new JestExt(context, workspace, channel, pluginSettings)

  const languages = [
    { language: 'javascript' },
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,

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 2 months ago

Package Health Score

72 / 100
Full package analysis

Similar packages