Skip to content
This repository has been archived by the owner on Feb 27, 2022. It is now read-only.

--watch option #14

Open
ignatevdev opened this issue Jan 16, 2018 · 5 comments
Open

--watch option #14

ignatevdev opened this issue Jan 16, 2018 · 5 comments

Comments

@ignatevdev
Copy link

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

@moltar
Copy link

moltar commented Mar 16, 2018

You can use nodemon for that.

@loweoj
Copy link

loweoj commented May 4, 2018

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
Copy link

alex996 commented Nov 24, 2018

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
Copy link
Member

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
Copy link

sr2ds commented Dec 4, 2020

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!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants