Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[heft] Integrate with VSCode extension for Jest

未关闭
#5,483 1 条评论 2 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

这个 Issue 还没有评估数据。

描述

Summary

This issue relates to the conversation in the Rush stack Zulip forum: #heft > Jest extension in VSCode

When using the heft-jest-plugin, the Jest extension to VSCode cannot start, and thus Testing panel and Test Results window are inoperable.

Running tests via the command-line works as expected -- the actual Jest tests are executed and reported as expected.

Details

Navigate to the Testing pane, and run tests. The TestResults window shows an error:

Jest encountered an unexpected token

Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.

This is expected. The heft-jest-plugin documentation discusses the differences from ts-jest. The key point is that Jest expects to transform Typescript itself from the src folder, while heft-jest-plugin runs tests from transformed code, typically in the lib folder.

While expected, it is not the desired result.

The extension allows for changing the start command. I tried using the command npm run test (and the package.json entry is

"scripts": {
  "build": "heft build --clean",
  "test":"heft test-watch"
},

However, the Test results window now shows:

heft test-watch C:\Users\PAULSC~1\AppData\Local\Temp\jest_runner_heft_appconfig_plugin_paulschaeflein.json default c:\Users\PaulSchaeflein.vscode\extensions\orta.vscode-jest-6.4.4\out\reporter.js

usage: heft test-watch [-h] [-v] [--production] [--locales LOCALE] [--clean]
[--config RELATIVE_PATH] [--debug-heft-reporter]
[--detect-open-handles] [--disable-code-coverage]
[--find-related-tests SOURCE_FILE] [--log-heap-usage]
[--max-workers COUNT_OR_PERCENTAGE] [--silent]
[-t REGEXP] [--test-path-ignore-patterns REGEXP]
[--test-path-pattern REGEXP]
[--test-timeout-ms TIMEOUT] [-u] [--fix] [--serve]

heft test-watch: error: Unrecognized arguments: C:\Users\PAULSC~1\AppData\Local\Temp\jest_runner_heft_appconfig_plugin_paulschaeflein.json default c:\Users\PaulSchaeflein.vscode\extensions\orta.vscode-jest-6.4.4\out\reporter.js.

{
  "error": {
    "code": 1,
    "summary": "",
    "detail": ""
  }
}

The extension's start command is expected to receive a specific set of parameters that are passed to the Jest command. Those parameters are as follows:

--testLocationInResults --json --useStderr --outputFile "C:\\Users\\PAULSC~1\\AppData\\Local\\Temp\\jest_runner_heft_appconfig_plugin_paulschaeflein_2.json --no-coverage --reporters "default" --reporters "c:\\Users\\PaulSchaeflein\\.vscode\\extensions\\orta.vscode-jest-6.4.4\\out\\reporter.js --colors --watchAll=false

In the Zulip thread, @octogonz added the following (and requested this issue):

The main work item is just to expose those CLI parameters as equivalent Heft parameters, and then provide a small heft-jest script that discards irrelevant parameters and remaps any slightly renamed parameters, when invoking Heft.

The important parameters are: --testLocationInResults, --json, --useStderr, --outputFile, --no-coverage, --reporters

But we would probably consolidate them, something like:

  • Heft --testResultsFile (equilalent to Jest --json + --useStderr + --outputFile)
  • --testLocationInResults
  • --no-coverage
  • Heft --testReporter (equivalent to Jest --reporters, but without delusions of removing HeftJestReporter)

Standard questions

Please answer these questions to help us investigate your issue more quickly:

Question Answer
@rushstack/heft version? 1.1.6
Operating system? Windows
Would you consider contributing a PR? No (I am not talented enough to do that.)
Node.js version (node -v)? 22.16.0
主要语言
TypeScript
星标
6.5k
派生
708
平均合并
1 天 19 小时
30 天内合并 PR
43

环境准备

我们还没有检查这个项目的环境配置文件。先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

microsoft/rushstack 的其他 Issue

查看 microsoft/rushstack 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。