-
Notifications
You must be signed in to change notification settings - Fork 997
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
Run Jest tests in sequence #1447
Conversation
Jest will run all test files simultaneously by default. This means it's impossible to test services—any database records created in them can potentially be overwritten or wiped out by another file running at the same time. This PR adds the `--runInBand` flag that makes Jest run each file one after the other. It's too bad we can't do this just for the api side but I don't see any way to specify that only certain files should run in band and not others.
Reading this PR I had two thoughts
|
Ah, good catch... @Tobbe I would love to have in-memory database, but for now there are a few difficulties with it:
I think your suggestion for running the commands separately makes sense in CI to save some time, but I'm not sure if that would work in watch mode. Right now we make use of separate Jest configs for web and api, which are then run at the same time when going My hunch says no, but even if it does, my next hunch says that the web-side tests will also pick up the PS. I checked, and |
@peterp Did you experience this issue in your latest testing adventures? Should we just merge this? It's the easiest and quickest fix! |
@RobertBroersma Right now I only have 1 test file for services so I had not experienced this, this is good to know though :) |
I'm also not using await db.$queryRaw`TRUNCATE TABLE "User" CASCADE;` My gut feeling is that we shouldn't automatically delete data from the users test tables between tests. |
Jest will run all test files simultaneously by default. This means it's impossible to test services—any database records created in them can potentially be overwritten or wiped out by another file running at the same time.
This PR adds the
--runInBand
flag that makes Jest run each file one after the other. It's too bad we can't do this just for the api side but I don't see any way to specify that only certain files should run in band and not others.Strangely enough this actually makes the services tests feel faster since you see them running and completing in sequence, instead of nothing happening for a couple of seconds and then them all completing at the same time.