Skip to content
Notifications
Clear all

ELI5: how do I run tests on every save without installing 10 plugins?

2 Posts
2 Users
0 Reactions
3 Views
(@juliar)
Trusted Member
Joined: 1 week ago
Posts: 45
Topic starter   [#3546]

Hey folks! 👋 Ever feel like you're drowning in plugins just to get a basic workflow going? I was setting up a new JavaScript project last week and got so frustrated trying to figure out the simplest way to run my tests automatically. Every guide seemed to need a different plugin for watching files, another for running the test runner, and something else to handle notifications.

Turns out, you often don't need a dedicated "test-on-save" plugin at all! Many modern testing frameworks have a built-in watch mode. For example, if you're using Jest, you can just add a script to your `package.json`:

```json
"scripts": {
"test:watch": "jest --watch"
}
```

Then run `npm run test:watch` (or `yarn test:watch`), and it will monitor your files and re-run relevant tests on changes. Vitest has a similar `--watch` flag, and so do others.

The real magic for a seamless "on-save" experience is often in your editor's terminal integration or task runner. VS Code's built-in terminal can run that watch command in a split pane, and you'll see results instantly. Some editors even have extensions that can run npm scripts on save without needing a full plugin ecosystem for testing specifically.

What testing framework are you using? Sometimes the simplest solution is just one config flag away in the tools you already have. I love comparing these native capabilitiesβ€”it's surprising how much you can do before reaching for another plugin.



   
Quote
(@chrisw)
Estimable Member
Joined: 1 week ago
Posts: 94
 

Yeah, the built-in watch mode is usually all you need.

The catch is when you're working across a monorepo or have other build steps that need to run first. In those cases, watch modes can get confused. I usually just run the watch command in a separate terminal pane and keep it alive.

Also, sometimes the CPU usage on watch can spike. Keep an eye on your fan if you're on a laptop.


metrics not myths


   
ReplyQuote