Closed flixman closed 5 days ago
Looks like the extension is running the default react-native test script. But if your project works with npx jest
, you can try to set "jest.jestCommandLine": "npx jest"
in your settings, instructing the extension to use the exact same command to run your tests.
@connectdotz Thank you for the hint! I have added that, and added "frontend" to jest.rootPath (otherwise the tests were not found). Now they are found, but if I try do start them in debug mode I am getting the following error:
/usr/bin/env 'NODE_OPTIONS= --require "/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/ms-vscode.js-debug/src/bootloader.js" --inspect-publis
h-uid=http' 'VSCODE_INSPECTOR_OPTIONS=:::{"inspectorIpc":"/var/folders/m0/t7ptrvrn5_n3qv9vhlmdwzk00000gq/T/node-cdp.20172-f7e2f3e9-1.sock","deferredMode":false,"waitForDebugger":"","execPath":"/Users/user/
.nvm/versions/node/v20.16.0/bin/node","onlyEntrypoint":false,"autoAttachMode":"always","fileCallback":"/var/folders/m0/t7ptrvrn5_n3qv9vhlmdwzk00000gq/T/node-debug-callback-bcab349f7d01314d"}' /Users/user/.
nvm/versions/node/v20.16.0/bin/node ./npx jest --runInBand --watchAll=false --testNamePattern CreateInfrastructure\ Submit\ Dev\ VM\$ --runTestsByPath /Users/user/repositories/myproject/frontend/s
rc/pages/infrastructure/__tests__/CreateInfrastructure.test.tsx
Debugger attached.
Waiting for the debugger to disconnect...
node:internal/modules/cjs/loader:1148
throw err;
^
Error: Cannot find module '/Users/user/repositories/myproject/frontend/npx'
at Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)
at Module._load (node:internal/modules/cjs/loader:986:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
at node:internal/main/run_main_module:28:49 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Node.js v20.16.0
Any idea on what might be wrong, here?
UPDATE: Do not bother: If instead of pointing to npx jest I set the parameter to node_modules/.bin/jest, both the runs and the debug mode works. Why?
This looks like the vscode debugger is not able to find npx via the default debug config the extension generated. This is not unusual since vscode provids different mechanisms for debugging vs. running tests. The way to customize the debugger behavior is to customize vscode debug config, see instruction.
A good baseline is to use the extension generated debug config (can be seen in jest terminal when you debug). Chances are you will need to use a separate "runtimeExecutable": "full-path-npx"
in your customized debug config.
If you have any issues setting it up, feel free to copy/paste your debug config, and we can help you further.
thank you! All seems to work now. Regards!
Describe the bug I have a project for react, typescript, in which I have dependencies coming as ecm modules. I am running the tests on the CLI by running
npx jest <test file>
and this works flawlessly. However, if I attempt to run the test through the jest plugin in vscode, I get the following error:Expected behavior Test run on the plugin as successfully as is doing on CLI
Screenshots If applicable, add screenshots to help explain your problem.
Environment (please complete the following information):
node -v
: 20.16.0npm -v
oryarn --version
: npm 10.8.1Prerequisite
Additional context Add any other context about the problem here.