-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Error: All tests and hooks must be declared synchronously in your test file, and cannot be nested within other tests or hooks. #1944
Comments
Could you give more context on how you're using this helper file? Are you putting it in the As long as you import the helper file, from the test file, it should still work. (Unless this is wrapped in a function which you're calling asynchronously.) However I think you're implying an expectation that these hooks were only run once per test run. That's definitely not the case. Even the (I'm closing this issue for housekeeping purposes, but let's keep the conversation going.) |
Okay so every file has its own |
No. But then ideally your test files are independent of each other, so that shouldn't matter. |
I agree but in this case I want all my tests to run simultaneously on the
same database since the real world database should handle similar scenarios.
But I can achieve that result by just running the tests on a local
database.
…On Mon, 1 Oct 2018, 13:30 Mark Wubben, ***@***.***> wrote:
Is it then possible to have all files use the same instance of
https://github.com/nodkz/mongodb-memory-server ?
No. But then ideally your test files are independent of each other, so
that shouldn't matter.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1944 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ADT4AxUSLFIOmi8d_oU4OJUmbOTwGGwkks5ugfzegaJpZM4XBCgn>
.
|
After the upgrade from
0.25.0
to1.0.0-beta8
I'm getting this error because I have abefore
andafter.always
hook in a helper file:But I'm getting this error
Error: All tests and hooks must be declared synchronously in your test file, and cannot be nested within other tests or hooks.
now.I used to import the above helper file in every test file.
I'm wondering what the proper approach is to set up a global before and after hook because I only want to init and destroy my database once... I don't want to do this per file because mongoose will be confused and I want all my tests to run in parallel on the same database since that is a real life scenario that I want to test.
How should I structure this?
The text was updated successfully, but these errors were encountered: