thrandre / ava-webpack

Quick and dirty implementation of a webpack-enabled AVA-runner
13 stars 6 forks source link

Watch mode? #3

Open wmertens opened 7 years ago

wmertens commented 7 years ago

Any ideas on how to implement watch mode? I tried adding -w to the ava call but that just hangs 😢

kristianmandrup commented 7 years ago

I think you might need to do -- -w or -- --watch. You can also try https://github.com/grncdr/npm-watch

wmertens commented 7 years ago

@kristianmandrup The problem is that webpack needs to be configured to watch the built files, and then somehow Ava needs to know about it too.

Since watch mode is the best feature about Ava, I am not currently using this project and instead made sure Ava can read the files directly with babel-plugin-webpack-alias. This means that I can't test code that uses webpack loaders, but luckily I've not had that problem yet.

thrandre commented 7 years ago

I'll might look into this in the future, @wmertens. This is currently not a priority of mine because the implementation will probably hurt both code- and performance wise. Watch-mode would require waiting for webpack (in watch-mode) to finish transpiling before firing up a new instance of ava with every change.

wmertens commented 7 years ago

I want to use watch mode because running the tests manually is much slower than watch mode… With watch mode, all the code is compiled and loaded, and if one of the tests or dependencies changes, it runs only the changed tests.

I suppose a cleaner way of doing this is to auto-generate a "test root" file that loads all test files, and then having webpack bundle that somewhere in watch mode, and then telling AVA to watch the output dir. Needs source map support loaded to know where errors are.