Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(watch): add on-change cli option #2577

Closed
wants to merge 1 commit into from
Closed

Conversation

dolsem
Copy link

@dolsem dolsem commented Sep 8, 2020

#1602 and #1366 described the use case for executing a piece of code before all tests. I have a similar use case where I need to wipe my test database each time the tests are run. This is more of a problem when AVA is in watch mode because I need to run my logic every time it detects a change. So I propose a CLI option to run a custom shell command every time the test are re-run.

@novemberborn
Copy link
Member

We've intentionally not added this for regular test runs. I don't think we should add it for watch mode either.

Something like #1366 would be a better fit — as in: you can load code in AVA's main process and it gets some lifecycle events allowing it to do stuff before tests run. #2478 lays the groundwork for that. It's pretty close to shipping experimentally actually. Maybe you could open an issue to explore that further?

Sorry to disappoint. I do understand where you're coming from, and thank you for figuring out how to make it work and opening a pull request. It's just a question of where to fit it into AVA.

FWIW, I write a lot of service integration tests which rely on Firestore. For that database the emulator has a neat trick: if you connect using a new project ID you get a clean database. So the execution of each test file is isolated from the others.

@dolsem
Copy link
Author

dolsem commented Sep 11, 2020

@novemberborn
Got it. #1366 seems like a much more complex way to solve this problem. In any case, is there anything I can do to help get #2478 done and merged? How soon do you think it will be finished?

@novemberborn
Copy link
Member

#2478 is close to shipping experimentally, and then we can figure out how to make it work with the run lifecycle.

I appreciate that all of this seems like more effort. Ultimately the goal is to enable many interesting use cases with code that can even be shared through the package registry.

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

Successfully merging this pull request may close these issues.

2 participants