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.

docs: how to run tests in watch mode

See original GitHub issue

How to run tests in watch mode? I assume nodemon or watch is the answer ? Would love to see it included in examples as well.

cheers!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
lukeedcommented, Jul 14, 2020

Ok. I have created watchlist, which is my first pass at a CLI watcher. I will need some feedback in order to bring this to 1.0 – I know there are inconsistencies with Windows right now, but it’s late for me and I don’t currently have access to a Windows machine.

The watchlist usage is exactly as described earlier:

$ watchlist src tests -- npm test

The -- is important – it’s what separates watchlist from the command you want to run. It’s also what makes it possible to pass option flags to your command (uvu in this case):

$ watchlist src tests -- uvu tests -r esm -i fixtures

I will add a /docs item tomorrow for this.

6reactions
lukeedcommented, Jul 13, 2020

Right now I’d use something like watchexec – which would look like this:

$ watchexec -w src -w tests npm test

This (recursively) watches all files within the src and tests directories, rerunning npm test whenever there’s a change.

Although I might make my own watch CLI, which would look something like:

$ watch src tests -- npm test

It was suggested that uvu --watch exists, which I can’t say i’m 100% against, however, my hesitation with that (and it applies to my own watch CLI too) is that I still have to either (a) include all of chokidar; or (b) become familiar with the bugs/edge cases that chokidar solves & apply them to my own solution; © just rely on native fs.FSWatcher and hope for the best.

The benefit of a separate watch CLI is that those solutions/problems are contained to that module. If uvu --watch exists and proves to be buggy, then everyone inherits that code and it becomes a problem or it becomes big & burly. And there will be users (myself included) that never reach for that feature and it’s just there taking up space.

Sorry I’m ranting now – but to wrap up: I think all-in-one solutions can sometimes be nice, but especially in the JS community, I think we forget that CLIs are meant to be piped into and chained together. A CLI should do one thing well and be flexible enough to work with other CLIs – or at least self-contained so that it doesn’t matter how it gets invoked. Because of this, I’m definitely leaning towards a separate watch CLI, although I do understand the appeal of a uvu builtin.


Related: There was a little Twitter thread about this

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jest CLI Options
Watch mode also enables to specify the name or path to a file to focus on a specific set of tests. Using with...
Read more >
Running Tests | Create React App
You can also press a in the watch mode to force Jest to run all tests. Jest will always run all tests on...
Read more >
Run Tests | Basic Guides | Guides | Docs - TestCafe
There are two ways to launch TestCafe tests. The simplest option is to use the testcafe shell command. Alternatively, you can launch tests...
Read more >
Watching Files for Changes - Node Tap
When developing a projects, it's useful to run tap in watch mode. In this mode, tap will watch your project for changes to...
Read more >
Test an Editor Add-on | Apps Script - Google Developers
Under Saved Tests, select the radio button next to the saved test deployment you want to run and click Execute. The test document...
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