vow icon indicating copy to clipboard operation
vow copied to clipboard

--watch option

Open ignatevdev opened this issue 7 years ago • 5 comments

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

ignatevdev avatar Jan 16 '18 17:01 ignatevdev

You can use nodemon for that.

moltar avatar Mar 16 '18 15:03 moltar

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

loweoj avatar May 04 '18 12:05 loweoj

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.

alex996 avatar Nov 24 '18 02:11 alex996

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

thetutlage avatar Nov 26 '18 12:11 thetutlage

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!

sr2ds avatar Dec 04 '20 18:12 sr2ds