[heft] Integrate with VSCode extension for Jest
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
This issue has not been assessed yet.
Description
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,--reportersBut 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 |
- Dominant language
- TypeScript
- Stars
- 6.5k
- Forks
- 708
- Avg merge
- 4d 7h
- Merged PRs (30d)
- 61
Getting set up
We have not checked this project's setup files yet. Start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/rushstack
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
microsoft/rushstack#5971 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
microsoft/rushstack#5902 · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
microsoft/rushstack#5839 · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
microsoft/rushstack#5683 · 3 comments ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
Maintainers usually reply within 1 day
All issues in microsoft/rushstack
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
rohitg00/agentmemory#1428 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
boxlite-ai/boxlite#1729 ·
Maintainers usually reply within 1 day
-
detectors enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
SM260845/readme-gen#1 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
angular/angularfire#3774 ·
Maintainers usually reply within 2 days