nithinpeter / jest-run-it Goto Github PK
View Code? Open in Web Editor NEWJest test runner for VS Code
Jest test runner for VS Code
I have this error when trying to run in windows
node_modules/.bin/jest 'c:\Users\<path-to-project>\src\some-file-name.spec.js' -t 'should get the right indexes for the add'
'node_modules' is not recognized as an internal or external command,
operable program or batch file.
Performance
jestRunIt
0.4.0
Darwin x64 19.6.0
1.48.0
/Users/v0k00fp/vespa-dev-works.jestRunIt-unresponsive.cpuprofile.txt
vespa-dev-works.jestRunIt-unresponsive.cpuprofile.txt
Find more details here: https://github.com/microsoft/vscode/wiki/Explain-extension-causes-high-cpu-load
Would be nice to have a dedicated button/icon for a --watch
action when you want to focus testing on a specific test.
Can be done with the cli options but you loose the ability to not watch this way.
The marketplace has 2 similar extensions: firsttris.vscode-jest-runner and jest-community/vscode-jest.
It will be good if you will add to the extension description in Marketplace and in GitHub repo readme high level comparison , what are advantages (and disadvantages) of your extension.
It will help users to choose the right tool.
My folder structure is:
projectroot
--services
---serviceA
------unit-tests
--------handler.test.js
---serviceB
------unit-tests
--------handler.test.js
I am on windows and have enabled double quotes config.
When I try to run the debugger I get:
Debugger attached.
No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
In C:\Users\SIKAU\projectroot
107 files checked.
testMatch: **/__tests__/**/*.[jt]s?(x), **/?(*.)+(spec|test).[tj]s?(x) - 9 matches
testPathIgnorePatterns: \\node_modules\\ - 107 matches
testRegex: - 0 matches
Pattern: c:\Users\SIK\projectroot\serviceA\tenant-service\unit-tests\handler.test.js - 0 matches
Waiting for the debugger to disconnect...
I tried adding different patterns in settings.json for testMatchPatterns but it has not changed anything
Just wondering if anyone has tested this ext installed remotely via SSH: Remote?
I can't seem to get it to show me anything in the output
panel, or anywhere else even when I configure it "correctly".
Looks cool though, nice project!
Is there a way to set an environment variables for tests?
NODE_ENV=testing
Tried to run a single test and got the following:
node_modules\.bin\jest : File C:\Users\krzys\...\node_modules\.bin\jest.ps1 cannot be loaded because running scripts is disabled on this system. For more
information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ node_modules\.bin\jest "c:/Users/krzys/Documents/...
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
If you create a new file. And add some tests. The code lenses are not activated.
Can you add quote ?
Line 10 in 2e4aaa8
Hi, I like your runner the best, but I never see the option to run with -u available through a click. Can I enable it somehow?
When I install the extension I get this:
Activating extension 'vespa-dev-works.jestRunIt' failed: Cannot find module './jestDoItCodeLensProvider'
Require stack:
- /home/capaj/.vscode/extensions/vespa-dev-works.jestrunit-0.4.0/out/extension.js
- /snap/code/48/usr/share/code/resources/app/out/vs/loader.js
- /snap/code/48/usr/share/code/resources/app/out/bootstrap-amd.js
- /snap/code/48/usr/share/code/resources/app/out/bootstrap-fork.js.
I am installing version v0.4.0
When a file is ending with .integration-spec.xx (xx can be ts or js), the shortcut no longer work.
Maybe there is a config I can tweak to allow more than just .spec.xx files so the Run | Debug shortcut can work properly in VS Code?
Also is this the same plugin that already been integrated into VS Code?
It could be useful to let users adding Jest run options (https://jestjs.io/docs/en/cli.html#options) in Jest Run It extension settings. Users could customize their use of Jest Run It.
❯ /usr/bin/env 'NODE_OPTIONS=--require "/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/extensions/ms-vscode.js-debug/src/bootloader.bundle.js" --inspect-publish-uid=http' 'VSCODE_INSPECTOR_OPTIONS={"inspectorIpc":"/var/folders/nw/0tjfp_vs1zd25vgqgp0_7sww0000gn/T/node-cdp.59092-1.sock","deferredMode":false,"waitForDebugger":"","execPath":"/opt/homebrew/bin/node","onlyEntrypoint":false,"autoAttachMode":"always","fileCallback":"/var/folders/nw/0tjfp_vs1zd25vgqgp0_7sww0000gn/T/node-debug-callback-5926a02bc4546813"}' /opt/homebrew/bin/node ./node_modules/.bin/jest /Users/jahv/Documents/Projects/oak/identity-strategy-server/server/socket/ChecksumUtils.test.ts -t "shoud validateRequest\\(\\)" --runInBand
Debugger attached.
Waiting for the debugger to disconnect...
/Users/jahv/Documents/Projects/oak/identity-strategy-server/node_modules/.bin/jest:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
^^^^^^^
SyntaxError: missing ) after argument list
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1031:15)
at Module._compile (node:internal/modules/cjs/loader:1065:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)
at node:internal/main/run_main_module:17:47
./node_modules/.bin/jest content:
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -z "$NODE_PATH" ]; then
export NODE_PATH="/Users/jahv/Documents/Projects/oak/identity-strategy-server/node_modules/.pnpm/[email protected][email protected]/node_modules/jest/bin/node_modules:/Users/jahv/Documents/Projects/oak/identity-strategy-server/node_modules/.pnpm/[email protected][email protected]/node_modules/jest/node_modules:/Users/jahv/Documents/Projects/oak/identity-strategy-server/node_modules/.pnpm/[email protected][email protected]/node_modules:/Users/jahv/Documents/Projects/oak/identity-strategy-server/node_modules/.pnpm/node_modules:/Users/jahv/Documents/Projects/oak/identity-strategy-server/node_modules:/Users/jahv/Documents/Projects/oak/node_modules:/Users/jahv/Documents/Projects/node_modules:/Users/jahv/Documents/node_modules:/Users/jahv/node_modules:/Users/node_modules:/node_modules:/Users/jahv/Documents/Projects/oak/identity-strategy-server/node_modules/jest/bin/node_modules:/Users/jahv/Documents/Projects/oak/identity-strategy-server/node_modules/jest/node_modules"
else
export NODE_PATH="$NODE_PATH:/Users/jahv/Documents/Projects/oak/identity-strategy-server/node_modules/.pnpm/[email protected][email protected]/node_modules/jest/bin/node_modules:/Users/jahv/Documents/Projects/oak/identity-strategy-server/node_modules/.pnpm/[email protected][email protected]/node_modules/jest/node_modules:/Users/jahv/Documents/Projects/oak/identity-strategy-server/node_modules/.pnpm/[email protected][email protected]/node_modules:/Users/jahv/Documents/Projects/oak/identity-strategy-server/node_modules/.pnpm/node_modules:/Users/jahv/Documents/Projects/oak/identity-strategy-server/node_modules:/Users/jahv/Documents/Projects/oak/node_modules:/Users/jahv/Documents/Projects/node_modules:/Users/jahv/Documents/node_modules:/Users/jahv/node_modules:/Users/node_modules:/node_modules:/Users/jahv/Documents/Projects/oak/identity-strategy-server/node_modules/jest/bin/node_modules:/Users/jahv/Documents/Projects/oak/identity-strategy-server/node_modules/jest/node_modules"
fi
if [ -x "$basedir/node" ]; then
exec "$basedir/node" "$basedir/../jest/bin/jest.js" "$@"
else
exec node "$basedir/../jest/bin/jest.js" "$@"
fi
I had test a test like it("Can't decode", () => {
and when I try to run I see this in terminal
$ node_modules/.bin/jest '/Users/safareli/dev/project/test/codec\.spec\.ts' -t 'Can\'t decode'
quote>
If you have such a test
it(`should ${'foo'}`, () => {
});
it will be skipped
The issue has apparently been fixed in jest-editor-support but the fix hasn't landed here. I guess it's just a matter of updating the dependency to the latest version and releasing a new version, is that correct?
Hello,
This works fine
describe('Method1', () => {
test('xxxx', () => {
....
});
});
describe('Method2', () => {
test('yyyy', () => {
.....
});
test('zzzzzz', () => {
...
});
});
But if I add a surronding describe for the class name, the buttons to launch the tests disapear (above each describe and each test)
describe('ClassName', () => {
describe('Method1', () => {
test('xxxx', () => {
....
});
});
describe('Method2', () => {
test('yyyy', () => {
.....
});
test('zzzzzz', () => {
...
});
});
});
The debugging command does not work because the -t
option adds up a pair of escaped quotes for the test name. So instead of launching:
node_modules/jest/bin/jest.js mytestFile.test.js -t "mytest" -c ....
the debug command is launched using this:
node_modules/jest/bin/jest.js mytestFile.test.js -t "\'mytest\'" -c ....
When the test is defined this way:
test('mytest', () =>{ ... })
And the test is skipped.
I need add node option --max_old_space_size=4096. How to set it by settings?
Thanks for providing this extension. I really like that you've made the UI customizable (e.g. allowing for users to use their own labels).
Can you add an option to clear the terminal before running the next test ...or as a more reusable option, allow users to send CLI commands before the main logic runs?
Something like terminal.sendText(`${preCommand}; ${command}`);
That way we can do things like clear; jest...
Hi!
I'm trying to debug my jest tests on Windows using your plugin. As explained in your Troubleshooting section, there is argumentQuotesToUse option to use double-quotes. But this option works only for run-mode, not for debug-mode.
May you fix it, please?
Hi,
How to enable the icons run for test.each jest?
VS Code was complaining with the extension, because it couldn't find the file:
.vscode-server/extensions/vespa-dev-works.jestrunit-0.4.0/out/jestDoItCodeLensProvider.js
I took a look and actually the file was on upperCase! JestDoItCodeLensProvider.js. I fixed it by just changing the name to lowerCase.
version 0.6.0
Could you please put a license on your project?
Question- how do you get debug working with create-react-app repos?
I've got the Run
command working by setting the Jest Run It: Jest Path to node_modules/.bin/react-scripts test
, but this only works for Run, not Debug.
Debug outputs this error:
Debugger listening on ws://127.0.0.1:52155/67198ca8-c598-45d0-9f63-25dd372716a6
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
Waiting for the debugger to disconnect...
internal/modules/cjs/loader.js:1032
throw err;
^
Error: Cannot find module '/Users/cathrync/gitlab/my-project/node_modules/.bin/react-scripts test'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1029:15)
at Function.Module._load (internal/modules/cjs/loader.js:898:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
I am using nvm so I need to be able to at least specify the node path.
Just wondering if we can add --watch
flag when running the test?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.