Giter Club home page Giter Club logo

vscode-jest-runner's Introduction

vscode-jest-runner

Looking for collaborators to help me maintain the project. Please contact me at [email protected]

Visual Studio Code Marketplace

VisualStudio Marketplace Open VSX Registry

Comparison with vscode-jest

vscode-jest-runner is focused on running or debugging a specific test or test-suite, while vscode-jest is running your current test-suite everytime you change it.

Features

Simple way to run or debug a specific test As it is possible in IntelliJ / Webstorm

Run & Debug your Jest Tests from

  • Context-Menu
  • CodeLens
  • Command Palette (strg+shift+p)

Supports

  • yarn & vscode workspaces (monorepo)
  • dynamic jest config resolution
  • yarn 2 pnp
  • CRA & and similar abstractions

Extension Example

Usage with CRA or similar abstractions

add the following command to settings:

"jestrunner.jestCommand": "npm run test --",
"jestrunner.debugOptions": {
    "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/react-scripts",
    "runtimeArgs": [
      "test",
      "${fileBasename}",
      "--runInBand",
      "--no-cache",
      "--watchAll=false",
      "--color"
    ]
},

Extension Settings

Jest Runner will work out of the box, with a valid Jest config. If you have a custom setup use the following options to customize Jest Runner:

Command Description
jestrunner.configPath Jest config path (relative to ${workspaceFolder} e.g. jest-config.json)
jestrunner.jestPath Absolute path to jest bin file (e.g. /usr/lib/node_modules/jest/bin/jest.js)
jestrunner.debugOptions Add or overwrite vscode debug configurations (only in debug mode) (e.g. "jestrunner.debugOptions": { "args": ["--no-cache"] })
jestrunner.runOptions Add CLI Options to the Jest Command (e.g. "jestrunner.runOptions": ["--coverage", "--colors"]) https://jestjs.io/docs/en/cli
jestrunner.jestCommand Define an alternative Jest command (e.g. for Create React App and similar abstractions)
jestrunner.disableCodeLens Disable CodeLens feature
jestrunner.codeLensSelector CodeLens will be shown on files matching this pattern (default **/*.{test,spec}.{js,jsx,ts,tsx})
jestrunner.codeLens Choose which CodeLens to enable, default to ["run", "debug"]
jestrunner.enableYarnPnpSupport Enable if you are using Yarn 2 with Plug'n'Play
jestrunner.yarnPnpCommand Command for debugging with Plug'n'Play defaults to yarn-*.*js
jestrunner.projectPath Absolute path to project directory (e.g. /home/me/project/sub-folder), or relative path to workspace root (e.g. ./sub-folder)
jestrunner.changeDirectoryToWorkspaceRoot Changes directory before execution. The order is:
  1. jestrunner.projectPath
  2. the nearest package.json
  3. ${workspaceFolder}
jestrunner.preserveEditorFocus Preserve focus on your editor instead of focusing the terminal on test run
jestrunner.runInExternalNativeTerminal run in external terminal (requires: npm install ttab -g)

Shortcuts

Command Pallette -> Preferences: Open Keyboard Shortcuts (JSON) the json config file will open add this:

{
  "key": "alt+1",
  "command": "extension.runJest"
},
{
  "key": "alt+2",
  "command": "extension.debugJest"
},
{
  "key": "alt+3",
  "command": "extension.watchJest"
},
{
  "key": "alt+4",
  "command": "extension.runPrevJest"
}

Want to start contributing features?

Check some open topics get you started

Steps to run Extension in development mode

  • Clone Repo
  • npm install
  • Go to Menu "Run" => "Start Debugging"

Another vscode instance will open with the just compiled extension installed.

vscode-jest-runner's People

Contributors

adi518 avatar alexkuc avatar alexsotocx avatar alonrbar avatar bibobibo avatar dependabot[bot] avatar domoritz avatar domsleee avatar estefaniaguardado avatar firsttris avatar gregoryzh avatar jenspalmqvist avatar juhq avatar keroxp avatar lvoliveira avatar mitchelst avatar mjeanroy avatar morrislaptop avatar nirgilboa avatar pbug90 avatar pierreandreis avatar progfay avatar robthefivenine avatar shaman-apprentice avatar staff0rd avatar threedaymonk avatar tlbdk avatar viciteufel avatar vlechemin avatar wh1t3cat1k avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

vscode-jest-runner's Issues

Nested describes result in wrong jest command

Hi,

When a test is nested inside more than one describe, the resulting jest command include a "-t" using a starts with regex "^" but using the text from the describe closest to the test. This make jest skips all the tests because the regex doesnt match anything.

Here is an example:

describe('test1', () => {
  describe('test2', () => {
    it('should run this test', () => {
      expect(true).toBe(true);
    });
  });
});

and the resulting command has the following options

-t '^test2 should run this test$'

but it should be

-t '^test1 test2 should run this test$'

Great extension by the way!

Resolving to jest debug defaults to first folder in current workspace | automatically detect workspace subproject to find jest debug

Probably related to #23

When using a workspace with multiple projects, the debug runner executes jest from the first folder in the current workspace if no explicit jest executable path had been configured, probably missing a call to slash() ?

program: getJestPath(),

Is there any way to change that so it detects the correct workspace project that the file of the currently executed test resides in?

Debugging fails if test name contains `(`, `)`, possibly more

We have a test that is specified as follows:

it("(true)", () => {
   // ... test implementation
}

When using Debug Jest to run this, the extension falls over with the following error message:

syntax error near unexpected token `('

This could probably be fixed by always surrounding value for the -t parameter with single quotes. Instead of

... --inspect-brk=35753 node_modules/.bin/jest -i /lambda/src/parser/parser.micro.ts -t (true)

this would work:

... --inspect-brk=35753 node_modules/.bin/jest -i /lambda/src/parser/parser.micro.ts -t '(true)'

While at the moment we observe this for parenthesis only, it is possible that other special characters may cause a similar problem.

Note that we can run jest normally, so we believe this is a problem with how this extension crafts the command line for jest. Also choosing Run Jest surrounds that parameter value with single quotes, e.g.

node '/lambda/node_modules/.bin/jest' '/lambda/src/parser/parser.micro.ts' -t '(true)'

Our setup:

  • VS Code version 1.36.1
  • vscode-jest-runner version 0.3.6

Run with coverage as a separate command

I know that we can specify the --coverage in the run options, but in my usual workflow, I write/run a bunch of tests one by one for a file, and when I'm done, I want to run the whole file with coverage to see if I missed something. So adding the --coverage in the options runs it every time, which slows things down so it's a no go.

If I had a "Run with coverage" command, I could set a separate keybinding for it and run it easily after I'm done with a test file. The workaround for now is to run the test for the whole file, and then edit the command in the terminal to add --coverage.

Move menu options to its own category

Menu options are marked as category "navigation", when in fact they are not related to navigation. It seems as a hack to get it on first in the list.

"editor/context": [
{
"command": "extension.runJest",
"group": "navigation"
},
{
"command": "extension.runJestFile",
"group": "navigation"
},
{
"command": "extension.debugJest",
"group": "navigation"
}
]
}

This messes with my configuration as I personally prefer to have navigation on top of the menu list and there is no way to remove this extension options from there without affecting the navigations items
https://code.visualstudio.com/api/references/contribution-points#Sorting-of-groups

image

Test name detection fails when we use a function to construct the test

I'm using

it("script-empty", assertSchema("script-empty", "MyType", `No root type "MyType" found`));

Which runs

node '/Users/domoritz/Developer/UW/ts-json-schema-generator/node_modules/.bin/jest' '/Users/domoritz/Developer/UW/ts-json-schema-generator/test/invalid-data.test.ts' -t 'it("script-empty", assertSchema("script-empty", "MyType", `No root type "MyType" found`));'

But instead it should run

node '/Users/domoritz/Developer/UW/ts-json-schema-generator/node_modules/.bin/jest' '/Users/domoritz/Developer/UW/ts-json-schema-generator/test/invalid-data.test.ts' -t 'script-empty'

Fails to debug with `\` in test name

We have a test specified like this:

it("1000 > \$blah", () => {
   // ...
}

Choosing Debug Jest from the context menu on "it" results in the following command line:

cd /lambda ; /usr/local/bin/node --inspect-brk=47749 node_modules/.bin/jest --no-cache -i /lambda/src/parser/parser.micro.ts -t "1000 > \\$blah" -i /lambda/src/parser/parser.micro.ts -t "1000 > blah" -i /lambda/src/parser/parser.micro.ts -t "1000 > \\$blah" -i /lambda/src/parser/parser.micro.ts -t "1000 > \\$blah"

Note how the -i flag is provided multiple times instead of only once. -i in this case should be specified only once.

The test fails with the following error message:

SyntaxError: Invalid regular expression: /1000 > \,1000 > blah,1000 > \,1000 > \/: \ at end of pattern
    at new RegExp (<anonymous>)

Environment:

  • VS Code, version 1.36.1
  • Jest Runner, version 0.3.6
  • Node JS, version 10.16.0
  • Debian Linux, version 9.9

Test cases with overlapping names are run accidentally

Say I have three test cases,

it('renders'),
it('renders errors')
it('sometimes renders')

If I want to run the first test, the plugin produces the command line parameter -t renders, which runs all three tests.

This is because the argument to -t is a regular expression that is matched against the full test name (which is obtained from concatenating all describes and the test name, separated by spaces).

Codelens option to start Tests

Abstract:
From my understanding a codelens option is a clickable link in your code, which could enable you to start jest in run or debug mode.

Resolving to jest executable defaults to first folder in current workspace | automatically detect workspace subproject to find jest executable

When using a workspace with multiple projects, the test runner executes jest from the first folder in the current workspace if no explicit jest executable path had been configured:

return join(vscode.workspace.workspaceFolders[0].uri.fsPath, jestDirectoy);

Is there any way to change that so it detects the correct workspace project that the file of the currently executed test resides in?

[Feature Request] Shortcuts

Please add shortcut support, so we can map "run test" and "debug test"? Any default would be okay.

I would use:
alt-1 for run test
alt-2 for debug test

And once this feature request is added, I would use:
alt-3 for repeat last run test
alt-4 for repeat last debug test

These shortcuts are available in Visual Studio, one of the few things I miss about it!

Undefined error starting test where cursor is

Following the #49 fix, I now get an error message "Cannot read property 'replace' of undefined" when I place my cursor inside a test and try to run. If I place my cursor in the test name (the string inside the it(...)), it works, but with the cursor on any line inside the test, I get the error.

My version is 0.4.9

Breakpoints are disabled during debug

I have 4 breakpoints that show up as red dots, then I say debug, the become outlines (not part of the code being debugged) then the test completes and they become red again....

~/dev/react-table $ cd /Users/mark/dev/react-table ; /Users/mark/.nvm/versions/node/v10.18.1/bin/node --inspect-brk=41327 node_modules/.bin/jest --no-cache /Users/mark/dev/react-table/src/plugin-hooks/tests/useFiltersAndRowSelect.test.js -t "Select/Clear All while filtered only affects visible rows" --runInBand 
Debugger listening on ws://127.0.0.1:41327/ce7dc66c-8906-4daa-baec-0962dca706fd
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
  ... console.log stuff that doesn't add to this description ...
FAIL unit src/plugin-hooks/tests/useFiltersAndRowSelect.test.js
  ✕ Select/Clear All while filtered only affects visible rows (197ms)

  ● Select/Clear All while filtered only affects visible rows

    expect(received).toBe(expected) // Object.is equality

    Expected: "12"
    Received: "6"

      221 | 
      222 |   fireEvent.click(getByLabelText('Select All'))
    > 223 |   expect(selectedCount.textContent).toBe('12') // But "Select All" adds 6 to the count
          |                                     ^
      224 | 
      225 |   fireEvent.click(getByLabelText('Select All'))
      226 |   expect(selectedCount.textContent).toBe('6') // Clearing all should leave the original 6 selected

      at Object.<anonymous> (src/plugin-hooks/tests/useFiltersAndRowSelect.test.js:223:37)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        6.148s
Ran all test suites matching /\/Users\/mark\/dev\/react-table\/src\/plugin-hooks\/tests\/useFiltersAndRowSelect.test.js/i with tests matching "Select/Clear All while filtered only affects visible rows".
Waiting for the debugger to disconnect...
Killed: 9

I added this to my settings.json

 "jestrunner.debugOptions": {
        "args": ["--no-cache"],
        "sourcemaps": "inline",
        "disableOptimisiticBPs": true
    }

Test name detection fails when using an type alias of 'it' or 'describe' such as 'test'

Hey @firsttris, you got me thinking when you said I don't need to select the test name to run it. In my experience, not selecting it resulted in a -t "" argument, so ALL tests run. Selecting the name and right clicking 'Run Test' was my workaround for this.

Having just looked into it, I now see the issue. Without a selection the regex below is used to parse for the test name:

const TEST_NAME_REGEX = /(describe|it)\(('|"|`)(.*)('|"|`)/;

This regex will only find the test name if its in a 'describe' or 'it' call. But looking at Jest type definitions, theres a bunch of aliases (below) and in my project we are using 'test' instead of 'it'.
image

I'm guessing you can just OR in those other alies to cover these.

Something like this?
const TEST_NAME_REGEX = /(describe|fdescribe|xdescribe|it|fit|xit|test|xtest)\(('|"|)(.*)('|"|)/;

I'd make a PR, but I've never setup to debug an extension. If I have time I will try to setup and test this.

No tests found on Windows 10 using VS Code 1.31.1

On Windows, regexForTestFiles jest parameter is generated with an absolute path that uses backslashes \. This causes no matching test files to be found. Changing the backslashes to forward slashes / causes it to work.

This behavior is new and it might coincide with the latest update to VS Code (1.31.1). Has there been a change to the way that VS Code returns the file path? Or perhaps it's related this jest issue: jestjs/jest#6546?

Having trouble configuring for lerna monorepo

When I run test file I get --> Error: Cannot find module 'c:\Users\grosskue\Documents\apps\VCRM\node_modules\jest\bin\jest.js'

Truied adding -->

"jestrunner.configPath": "/client/jest.config.js",
"jestrunner.jestPath": "${workspaceRoot}/client/node_modules/jest/bin/jest",
"jestrunner.debugOptions": {
    "args": [
        "--no-cache"
    ],
    "sourcemaps": "inline",
    "disableOptimisticBPs": true,
 }

Error: Cannot find module 'C:\Program Files\Git\client\node_modules\jest\bin\jest'

I need to set:
configPath with the rootdir/jest.config.js

and

jestPath --> configPath with the rootdir/node_modules/jest/bin/jest

for each package and when I right click a file it picks up where I am and set the paths accordingly.

Can this be done?

Runs as VSCode project root, NOT working directory

Hi,
I have a setup with directories e.g.:
/tests
/func/func1

From func/func1 if I run "jest" in terminal the test runs fine, but when I run via. jest-runner it uses the project root scope, which means relative paths are broken (e.g. file loads).

I've tried the following:

  • adding jest-config.json to the local folder
  • adding jest config section to package.json in the local folder
  • using VSCode settings variables in the jestrunner config path setting, e.g.: /${relativeFileDirname}/jest-config.json (they appear to be all blank at runtime)

Any advice on how to run as the open directory?

Attribute 'program' does not exist.

Trying to debug a test pops the following alert on vs code. I have been using this feature before, somehow its broken now.

Attribute 'program' does not exist.('/path/to/bin/jest')

Run jest option works fine, Debug jest pops the above alert.

'run jest' does nothing

Right clicking anywhere within a test and selecting 'run jest' does nothing.
If I select the test name and right click > 'run jest' it will work in most cases.

Expected behaviour: that it runs just that test.

Version: 0.4.11
vscode: 1.41.1
os: popos/ubuntu 18

The run command fails because a space...

Hello, I like your extension but is only working half of it.
I can run debug command but can't make it run the test.
It crashes with this message:

jest.js -t 'can load instance'
module.js:549
throw err;
^

Error: Cannot find module 'c:\Users\mdelg\Documents\Visual'
at Function.Module._resolveFilename (module.js:547:15)

The problem is that I'm in Visual Studio 2017 because the backend resides in a project there.

I tried to configure in package.json this jestrunner.jestPath and jestrunner.configPath parameters with ho success...
Any ideas on what to do?

Thanks in advance...

Multi-root VS Code workspace

This doesn't seem to work in a multi-root VS Code workspace.

node --inspect-brk ${workspaceRoot}/node_modules/.bin/jest -i "-t sendMessageTest"
➜  functions git:(task-notifications) ✗ node --inspect-brk ${workspaceRoot}/node_modules/.bin/jest -i "-t sendMessageTest"
Debugger listening on ws://127.0.0.1:9229/a8018417-3540-46de-b81e-25c8a7090175
For help see https://nodejs.org/en/docs/inspector
Debugger attached.
module.js:538
    throw err;
    ^

Error: Cannot find module '/node_modules/.bin/jest'
    at Function.Module._resolveFilename (module.js:536:15)
    at Function.Module._load (module.js:466:25)
    at Function.Module.runMain (module.js:676:10)
    at startup (bootstrap_node.js:187:16)
    at bootstrap_node.js:608:3

Can't work with two test suites

I have 2 test suites: unit-tests & e2e-tests. The first one is defined in the package.json and it works by default with Jest Runner. The second has a separate config file and therefore Jest Runner can't find it. So when I set the "jestrunner.configPath" parameter the second test suite start working, but the first one stops.

Is it possible to make both test suites work without changing the configuration file path every time?

Debug test does not work with fish shell

Similar to #53

$ cd /Users/dominik/Code/vega-lite ; /Users/dominik/.config/nvm/13.3.0/bin/node --inspect-brk=22357 node_modules/.bin/jest /Users/dominik/Code/vega-lite/test/util.test.ts -t "^util accessPathWithDatum should support escaped brackets$" --runInBand 
fish: Expected a variable name after this $.
cd /Users/dominik/Code/vega-lite ; /Users/dominik/.config/nvm/13.3.0/bin/node --inspect-brk=22357 node_modules/.bin/jest /Users/dominik/Code/vega-lite/test/util.test.ts -t "^util accessPathWithDatum should support escaped brackets$" --runInBand 

Add context menu to file tree

It would be nice to be able to click 'src', 'tests', or 'Mytest.spec.js' to run all tests in the directory or file.

Improvement: add test location to jest call

To improve the execution speed and ignore errors in other files one could add the path of the current test file to the jest call.

Jest only looks in this particular file and does not search for tests in all files.

E.g.

// Now:
jest -t "test name pattern"

// Better use:
jest -t "test name pattern" path/to/file.test.js

Running a describe skips all the tests

Let's take this example:

describe('test1', () => {
    it('should run this test', () => {
      expect(true).toBe(true);
    });
});

If I place my cursor on "test1", the describe statement, and run jest, it will run with -t '^test1$' which I think is wrong since it doesnt match any test, because of the $. No tests are ending with "test1". Maybe you should only add the $ when the cursor is on a specific test and not on a describe.

How to use it with yarn workspaces and ts-jest

Hi,
I've tried your extension, but I can't get it working in VS Code having yarn workspaces and ts-jest (my project is written in TypeScript).
I have an app structured as follows:

Main folder

  • package.json (containing workspaces definition)
  • tsconfig.json (containing general config)
  • module1
    • package.json (containing own module dependencies)
    • tsconfig.json
  • module2
    • package.json (containing own module dependencies)
    • tsconfig.json
  • app
    • package.json (containing own module dependencies)
    • tsconfig.json

In each of the modules, I have ts jest tests.

When I try to debug one test with your tool, I get the following message:

c:\repos\Main>cd c:\repos\Main && "C:\Program Files\nodejs\node.exe" --inspect-brk=11419 node_modules\jest\bin\jest.js -i """c:/repos/Main/module1/src/utils/tests/myTests.spec.ts""" -t """getText"""
Debugger listening on ws://127.0.0.1:11419/aa7023ee-f5dd-4430-80d6-fe70be4e098b
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
No tests found
In C:\repos\Main
54 files checked.
testMatch: /tests//.js?(x),**/?(.)+(spec|test).js?(x) - 0 matches
testPathIgnorePatterns: \node_modules\ - 54 matches
Pattern: "c:\repos\Main\module1\src\utils\tests\myTests.spec.ts" - 0 matches
Waiting for the debugger to disconnect...

Any help would be great, thanks in advance

Support node_modules being in a different directory than {WorkspaceFolder}/

In some setups (like my teams), the React app (containing the necessary node packages) is located in a subdir like {workspaceFolder}/webApp. It would be nice if there was a way that we could run tests with this extension without having to shift the {workspaceFolder}.

ie: If you were to add "jestrunner.jestCommand": "cd webApp && npm test", this would work but would need to cd.. afterwards.

Note: This issue may only be particular to when a custom "jestrunner.jestCommand" is used.

Ability to pass along command line arguments

For some reason passing --coverage to jest was breaking our tests. I really wanted to this while debugging. So I had to fork and make my own hacky version of this extension.

Unfortunately I dont know enough about vscode extensions to be able to submit a pull request. But it seems not too hard have another setting where users can add their own command line arguments and the extension would just append them at the end.

Thanks for the extension. I use it every day

failed to run tests in Create-React-App

I'm having problems running my tests with Jest Runner. I think this happens because the tests are written in TypeScript and the test files have .ts and .tsx extensions instead of .js and .jsx.

args not added in Run Jest Mode

Hello,
I'm trying to use --watch arg in jestrunner.runOptions but this not works, my test ran a single time and stop.

This is config that I use in my VSCode settings.json

"jestrunner.runOptions": {
   "args": [
     "--no-cache",
     "--watch",
     "--watch-all"
   ],
   "sourcemaps": "inline",
   "disableOptimisticBPs": true,
 },

With VS code version 1.21 debug is not working

I have installed February upadte of vscode version 1.21 and Debugger stopped to owrk
with version 1.20.1 debugger command is this:
& 'node' '--inspect-brk=7001' '--inspect-brk' 'some root path/node_modules/jest/bin/jest.js' '-i' '-t' ' get descri'

with 1.21 it adds ${workspaceRoot} in 'some root path/${workspaceRoot}/node_modules/jest/bin/jest.js'

and error says that jest.js cannot be found on this path

however running tests works fine.

I have downgraded to 1.20.1 it start to work again

"Run Jest" and "Debug Jest" now do nothing if you don't select the line where the test start

Since the last update, the "Run Jest" and "Debug Jest" commands no longer do anything if the line your cursor is on isn't the one declaring the test.

Previously you could put your cursor at pretty much any location within the test function and it would work. This worked really well, and now it's a bit of a pain to use.

Is there anyway to revert to the previous behavior?

Thanks.

Jest encountered an unexpected token

Debugger listening on ws://127.0.0.1:49216/5a661e2d-693d-4408-8d80-4a18b3054beb
For help see https://nodejs.org/en/docs/inspector
Debugger attached.
FAIL src/Components/Grid/Grid.test.js
● Test suite failed to run

Jest encountered an unexpected token

This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.

By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".

Here's what you can do:
 • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
 • If you need a custom transformation specify a "transform" option in your config.
 • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

You'll find more details and examples of these config options in the docs:
https://jestjs.io/docs/en/configuration.html

Details:

SyntaxError: C:\Users\shibathethinker\Documents\GitHub\pwa_with_react_reactapp\src\Components\Grid\Grid.test.js: Unexpected token (26:22)

  24 |
  25 | test('Grid renders',()=>{
> 26 | const wrapper=shallow(<Grid headerList={['Id','Name','Stock']} prodList={items}/>)

Not skipping other test suites when running/debugging one test

I am selecting a test, like in the how to gif and clicking 'Run Test'. This generates the following (so far so good);
image

Expected: One test runs, other tests and suites are skipped.
image

Actual: One test runs, other tests skip, but other test suites try to run and fail:
image

Each failed test suite reports this:
image

The test I selected to run, may have had a duplicate name. So I named it uniquely, no other test in any other suite has the same name. Same results.

Clicking 'Debug Test' seems to do the same sort of thing, breakpoints in tests which should skip are hit.

I'm running VSCode 1.25.1 on Windows 10
image

I'm using Jest 23.1.0.

individual test will not run if title contains comma

Selecting the test name submits the form, via email verification, as expected and right clicking > 'Run jest' silently fails. Nothing appears to happen.
If I remove the commas, making the test name submits the form via email verification as expected then it runs just that test as expected.

Version: 0.4.11
vscode: 1.41.1
os: popos/ubuntu 18

Run Debug Jest fails for CMD and GIT bash

Hello,
thanks for this VSCode extension, I find it really useful.

Unfortunately, I cannot make Debug Jest command work.

I can fire Run Jest on my test and it works fine.
It produces this output:

node "d:/DEV/SDP/sales_portal_master/node_modules/jest/bin/jest.js" "d:/DEV/SDP/sales_portal_master/sales_sdp_gui/fx/services/fx-drafts-chain-store.spec.ts" -t "subscribe: no draft yet, empty one is given"

But if I fire Debug Jest, it fails with this output:

$ "C:\\Program Files\\nodejs\\node.exe" --inspect-brk=7972 node_modules\\jest\\bin\\jest.js -i \"d:/DEV/SDP/sales_portal_master/sales_sdp_gui/fx/services/fx-drafts-chain-store.spec.ts\" -t "subscribe: no draft yet, empty one is given"
Debugger listening on ws://127.0.0.1:7972/41c4a8e8-153d-4010-bc8f-4991de6e7343
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
jest-haste-map: duplicate manual mock found: fx-mocks
  The following files share their name; please delete one of them:
    * <rootDir>\sales_sdp_gui\__tests__\__mocks__\fx-mocks.ts
    * <rootDir>\target\js\sales_sdp_gui\__tests__\__mocks__\fx-mocks.js
 
jest-haste-map: duplicate manual mock found: gui-state-stub
  The following files share their name; please delete one of them:
    * <rootDir>\sales_sdp_gui\__tests__\__mocks__\gui-state-stub.ts
    * <rootDir>\target\js\sales_sdp_gui\__tests__\__mocks__\gui-state-stub.js

No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
In D:\DEV\SDP\sales_portal_master
  2847 files checked.
  testMatch: **/?(*.)(spec|test).ts?(x) - 151 matches
  testPathIgnorePatterns: \\node_modules\\ - 2847 matches
  testRegex:  - 0 matches
Pattern: "d:\\DEV\\SDP\\sales_portal_master\\sales_sdp_gui\\fx\\services\\fx-drafts-chain-store.spec.ts" - 0 matches
Waiting for the debugger to disconnect...

Here is my jest.config.js file

 const path = require("path");
 
 module.exports = {
     preset: "ts-jest",
     setupFiles: ["<rootDir>/tests_gui/global-test-setup.ts"],
     testEnvironment: "jsdom",
     testURL: "http://localhost",
     rootDir: "./",
     transform: {
         ".(ts|tsx)$": "ts-jest",
         ".mail$": "jest-raw-loader"
     },
     testMatch: ["**/?(*.)(spec|test).ts?(x)"],
     snapshotSerializers: ["enzyme-to-json/serializer"],
     moduleNameMapper: {
         "^.+\\.(css|less|scss|html)$": "identity-obj-proxy",
         "ionweb-react": path.join(__dirname, "./src/mocks/ionweb-react")
     },
     globals: {
         "ts-jest": {
             // diagnostics: {
             //     ignoreCodes: [2531, 2532, 2722, 2743, 7005, 7006, 7008]
             // },
             diagnostics: true
         }
     }
 };

Here is my VSCode about:

Version: 1.37.1 (user setup)
 Commit: f06011ac164ae4dc8e753a3fe7f9549844d15e35
 Date: 2019-08-15T16:17:55.855Z
 Electron: 4.2.7
 Chrome: 69.0.3497.128
 Node.js: 10.11.0
 V8: 6.9.427.31-electron.0
 OS: Windows_NT x64 10.0.17763

I tried also to run debug manually by trying different arguments (removing the double quotes from test file path, for instance), but not luck.

Thanks for your support!

command 'extension.runJestFile' not found

First up, thanks for this amazing extension! My Jest workflow is so smooth with it.

It seems that all versions since 0.4.3 when I try and "Run Jest" or "Run Jest file" I get the following message:

command 'extension.runJestFile' not found

In the console I see the following error:

Activating extension 'firsttris.vscode-jest-runner' failed: Cannot find module 'escape-string-regexp'
Require stack:
- /Users/andypearson/.vscode/extensions/firsttris.vscode-jest-runner-0.4.5/out/jestRunner.js
- /Users/andypearson/.vscode/extensions/firsttris.vscode-jest-runner-0.4.5/out/extension.js
- /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/loader.js
- /Applications/Visual Studio Code.app/Contents/Resources/app/out/bootstrap-amd.js
- /Applications/Visual Studio Code.app/Contents/Resources/app/out/bootstrap-fork.js.

Rolling back to 0.4.2 fixes the problem and makes the commands work again.

Also, a small thing I noticed is that the recent entries in the change log are listed as happening in 2017, which confused me for a second :)

Jest Debug: ENOENT: `/${workspaceRoot}/node_modules/jest/bin/package.json

Hi there,

So, I can "Run Jest" for any test block with these configurations (and it works... tests pass):

{
  "jestrunner.configPath": "jest.config.js",
  "jestrunner.jestPath": "./node_modules/.bin/jest",
  "jestrunner.runOptions": {
    "args": ["--runInBand"]
  }
}

Screen Shot 2019-08-07 at 2 57 50 PM

However, when I try to "Debug Jest", the error message appears:

Attribute 'program' is not absolute ('./node_modules/.bin/jest'); consider adding '${workspaceFolder}/' as a prefix to make it absolute.

Screen Shot 2019-08-07 at 3 00 11 PM

Screen Shot 2019-08-07 at 3 02 04 PM

So, when I update my config to the recommended path prefix:

"jestrunner.jestPath": "${workspaceFolder}/node_modules/.bin/jest",

...the script crashes because it can't find package.json in node_modules/jest/bin/package.json

Am I doing something wrong here?

Doesn't work with cmd on windows 10

Right clicking on a test name and selecting "Run Jest" doesn't work with windows 10 and cmd as default shell.

following error message appears:

E:\dev\EM Cloud\cloud-portal\backend>cd "e:\dev\EM Cloud\cloud-portal\backend"; node "e:/dev/EM Cloud/cloud-portal/backend/node_modules/jest/bin/jest.js" "e:/dev/EM Cloud/cloud-portal/backend/tests/login.test.ts" -t "Register new user successful"
Die Syntax für den Dateinamen, Verzeichnisnamen oder die Datenträgerbezeichnung ist falsch.

It works using Powershell or Git bash as default shell.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.