--watch option
Is there any way to watch for spec changes and re-run the tests automatically instead of running the command every time manually?
You can use nodemon for that.
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
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.
Yeah, but in that case we need to handle couple of things.
- Do not re-run migrations hooked into
runner.beforeandrunner.after - 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
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!