question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Running jest in watch mode with an invalid file pattern causes jest to throw an exception.

See original GitHub issue

šŸ› Bug Report

Running Jest in watch mode and providing an invalid file pattern causes Jest to error and the process freezes. You have to send the process a SIGINT to kill the process, basically control + c

To Reproduce

Steps to reproduce the behavior:

Run jest in watch mode and filter by file name (Press P). Provide * as a pattern and the following is observed.

Do this.

image

And this is what happens

image

Only way to kill jest is to press control + c.

Expected behavior

Jest is known for its pleasant developer experience. This exception should return a developer friendly error and not cause Jest to hang with the only way of stopping it is to do a control + c;

Link to repl or repo (highly encouraged)

Not needed as it is easy to replicate.

Run npx envinfo --preset jest

Paste the results here:


npx: installed 1 in 3.086s

  System:
    OS: macOS High Sierra 10.13.6
    CPU: (4) x64 Intel(R) Core(TM) i5-7267U CPU @ 3.10GHz
  Binaries:
    Node: 8.11.3 - ~/.nvm/versions/node/v8.11.3/bin/node
    Yarn: 1.9.4 - /usr/local/bin/yarn
    npm: 6.4.1 - /usr/local/bin/npm
  npmPackages:
    jest: ^23.6.0 => 23.6.0

Note: I can make a PR for this if this behaviour is indeed not the desired behaviour.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:25 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
bcansecocommented, Nov 28, 2018

I’m getting the same error on 24.0.0-alpha.6 when running npm test (which runs jest with no arguments). My config is empty. Removing node_modules and re-installing did not fix the issue for me.

$ npx envinfo --preset jest
npx: installed 1 in 1.477s
Path must be a string. Received undefined
npx: installed 1 in 1.483s
C:\Users\b\AppData\Roaming\npm-cache\_npx\15536\node_modules\envinfo\dist\cli.js

  System:
    OS: Windows 10
    CPU: (12) x64 Intel(R) Core(TM) i7-6800K CPU @ 3.40GHz
  Binaries:
    Yarn: 1.10.1 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 6.4.1 - C:\Program Files\nodejs\npm.CMD
1reaction
captain-yossariancommented, Nov 27, 2018

@rickhanlonii after removing node_modules (rm rf), and installing it again, it works as expected. I don’t know why. I did it previously, but it wasn’t work

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jest CLI Options
Run only the tests that were specified with a pattern or filename: ... Watch mode also enables to specify the name or path...
Read more >
@salesforce/sfdx-lwc-jest - npm
To run tests, press F5 or select Debug > Start Debugging. Watch mode. Watch mode causes Jest to monitor files for changes and...
Read more >
Running Tests | Create React App
When you run npm test , Jest will launch in watch mode*. Every time you save a file, it will re-run the tests,...
Read more >
How to test the type of a thrown exception in Jest
In Jest you have to pass a function into expect(function).toThrow(<blank or type of error>) . Example: test("Test description", () => { const tĀ ......
Read more >
Configuring Jest compiled - w3resource
Always remember that the resulting configuration must be JSON-serializable. When you are using the --config option, the JSON file should notĀ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found