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

Proposal: the delay option #2061

Closed
Fmajor opened this issue Mar 6, 2019 · 8 comments
Closed

Proposal: the delay option #2061

Fmajor opened this issue Mar 6, 2019 · 8 comments

Comments

@Fmajor
Copy link

Fmajor commented Mar 6, 2019

I build a website with Nuxt.js, i have complicated backend models and it will take several seconds before the database is initialized and ready to work.
I run ava with the --watch option and will failed each time i update the source code (because the tests start immediately after i modify the source code before the database is ready)

Can we have a delay option to control the delay time after the source file are updated when we use the --watch option?

i want a CLI option --delay 5000 and the package.json config:

ava: {
  delay: 5000
}

to have a 5.0s delay time.

@sindresorhus
Copy link
Member

sindresorhus commented Mar 6, 2019

I think a better and less fragile solution is for your code to wait for the database to be ready (detect it somehow).

@novemberborn
Copy link
Member

You could do that detection in an asynchronous test.before(async () => { await startup() }) hook.

(I'm closing this issue for housekeeping purposes, but let's keep the conversation going.)

@Fmajor
Copy link
Author

Fmajor commented Mar 7, 2019

thanks, i have write anoter functiontestInitDone and put it into the before hook

anyway, i saw the delay option in other packages with the watch feature, maybe there are conditions that people must use this feature

@novemberborn
Copy link
Member

I can see it being useful if the watcher picks up on files written by another process, and those files are written more slowly than it currently allows for. I don't recall anybody reporting such problems, though.

@jakobrosenberg
Copy link

A delay option like Rollup's buildDelay, could help prevent multiple triggers when multiple files are output to a dist folder.

@novemberborn
Copy link
Member

@jakobrosenberg is this a problem you're encountering?

@jakobrosenberg
Copy link

@novemberborn, yes. especially for projects where dist files are written by different async functions.

An even better option would be something like, diskIdle: 200. This would take into account async file writes and sequential build steps like recreating a serviceworker manifest from the content of a dist folder.

@novemberborn
Copy link
Member

@jakobrosenberg let's discuss here: #2702

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

No branches or pull requests

4 participants