adonisjs / vow

Test Runner For AdonisJs
MIT License
56 stars 18 forks source link

--watch option #14

Open ignatevdev opened 6 years ago

ignatevdev commented 6 years ago

Is there any way to watch for spec changes and re-run the tests automatically instead of running the command every time manually?

moltar commented 6 years ago

You can use nodemon for that.

loweoj commented 6 years ago

Could you show us how we could use nodemon? I'm not sure which command to execute with nodemon - nodemon adonis test doesn't work. (Sorry, I'm very new to Adonis/Node!)

EDIT: Found the option I was looking for -x nodemon -x adonis test

alex996 commented 5 years ago

nodemon is only included with @adonisjs/cli, so it'd be nice to add a new Ace command there. adonis test:watch' or adonis test -w would make sense.

thetutlage commented 5 years ago

Yeah, but in that case we need to handle couple of things.

  1. Do not re-run migrations hooked into runner.before and runner.after
  2. Only re-run the test you are editing (I believe, that's how Karma watcher does it)

Feel free to share any more insights you have

sr2ds commented 3 years ago

Is there any way to watch for spec changes and re-run the tests automatically instead of running the command every time manually?

Hello @ignatevdev

Perhaps this can help you, a simple implementation with onchange, unfortunately requires the installation of the package but, if it is just a development dependency, I believe that it is still viable.

Install the onchange package:

 npm i onchange --save-dev

Create the script line in your package.json:

"scripts": {
    ....
    "test:watch": "onchange 'app/**/*.js' 'test/**/*.js' -- node ace test"`
    ....
}

Run npm run test:watch and finish.

Although the topic is old, it can help someone.

Programming with tests in real time is really great!