-
Notifications
You must be signed in to change notification settings - Fork 84
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
Tests running in a GH action sharing a nuxt server a bit faster #925
Comments
That's an interesting observation; thanks for sharing! Unfortunately, I am not able to set up your project to run locally (Prisma related). It would be great if you could set up a minimal reproduction. On the other hand, I suggest you could try the following two approaches:
|
I wasnt able to get globalSetup working, here is what I tried:
...
test: {
globalSetup: './test/globalSetup.ts',
... in import { setup as nuxtSetup } from '@nuxt/test-utils'
export default async function setup() {
await nuxtSetup()
} (i tried both named and default) and I get
|
When I do this I get prisma errors which I believe are when they are trying to create the same user at the exact same time:
to avoid this in the action or locally, i have to set this in vitest:
...
test: {
poolOptions: {
forks: {
minForks: 1,
maxForks: 1,
},
},
... Created an issue in more detail here |
UPDATE I was able to swap out the The entire action now runs in 2m 11s - name: Build and start server in the background
run: pnpm run build:test:start:bg here is
notice i had to use Updated action found here |
Describe the feature
In my current Nuxt project I have 6 test files each testing about 8-10 endpoints, each file currently spins up its own nuxt instance making the entire action require about 10 minutes to run, and vitest itself taking 8m 46s
So I tweaked my GH action to instead run a nuxt server in an action in the background, and then sleep for 10 seconds to make sure it completes its run
Now instead of vitest taking 8 minutes 46 seconds, it finished in 18 seconds.
You can find the entire action file here
I found this pretty amazing so I thought I'd share starting with an issue with the questions:
Very happy to provide a PR anywhere to help share this strategy
BTW shot out to @tobiasdiez for Making this possible
Additional information
Final checks
The text was updated successfully, but these errors were encountered: