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

tests are successful but process ends with error #2415

Closed
6 tasks done
kaminskypavel opened this issue Dec 2, 2022 · 12 comments
Closed
6 tasks done

tests are successful but process ends with error #2415

kaminskypavel opened this issue Dec 2, 2022 · 12 comments

Comments

@kaminskypavel
Copy link

Describe the bug

migrating prisma examples of integration tests to vitest.
running pnpm test - everything is passing, but the process ends with errors

image


I suspect it has something to do with the in-memory mongo I'm instantiating in vitest.setup.ts.
jest has --detectOpenHandles for this case, but I couldn't find anything related in vitest.

off-topic:

what is the recommended way to share env variable from vitest.setup.ts and the tests themselves?
as per documentation

WARNING
Beware that the global setup is run in a different global scope, so your tests don't have access to variables defined here.

Reproduction

  1. clone https://github.com/kaminskypavel/vitest-prisma-inmem-mongo
  2. pnpm i
  3. pnpm test

System Info

System:
    OS: Windows 10 10.0.22621
    CPU: (16) x64 Intel(R) Core(TM) i7-10870H CPU @ 2.20GHz
    Memory: 41.38 GB / 63.82 GB
  Binaries:
    Node: 18.12.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.15 - ~\.yarn\bin\yarn.CMD
    npm: 8.19.2 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.22621.819.0), Chromium (107.0.1418.62)
    Internet Explorer: 11.0.22621.1
  npmPackages:
    vite: ^3.2.4 => 3.2.4 
    vitest: ^0.25.3 => 0.25.3

Used Package Manager

pnpm

Validations

@sheremet-va
Copy link
Member

sheremet-va commented Dec 3, 2022

I don't think watch mode can ever end with 0? Because watch mode never ends. You either Ctrl+C it (which make status code 1), or something breaks, which also makes status code 1.

Did you mean to run it as vitest run? Don't forget that watch mode is enabled by default.

@kaminskypavel
Copy link
Author

kaminskypavel commented Dec 3, 2022

I don't think watch mode can ever end with 0? Because watch mode never ends. You either Ctrl+C it (which make status code 1), or something breaks, which also makes status code 1.

Did you mean to run it as vitest run? Don't forget that watch mode is enabled by default.

yeah, i did mean to vitest run. and so I did. now getting a segmentation fault.
happy to provide logs if needed.

 ✓ tests/prisma.test.ts (9)
   ✓ example test with Prisma Client (9)
     ✓ test query
     ✓ create user
     ✓ create a user with posts
     ✓ Find user based on user id
     ✓ Find user and related posts based on user id    
     ✓ Find posts based on author id
     ✓ Filter posts based on title
     ✓ Update posts - increment count
     ✓ Delete post

 Test Files  1 passed (1)
      Tests  9 passed (9)
   Start at  12:49:47
   Duration  3.54s (transform 825ms, setup 0ms, collect 174ms, tests 103ms)

Segmentation fault

@poyoho
Copy link
Member

poyoho commented Dec 3, 2022

image
😅

@kaminskypavel
Copy link
Author

😅😅😅
image

@poyoho
Copy link
Member

poyoho commented Dec 5, 2022

@kaminskypavel So this is no an error?

@kaminskypavel
Copy link
Author

is the Segmentation fault intended?

@poyoho
Copy link
Member

poyoho commented Dec 5, 2022

no. I mean is I can't to replay it. 🤦

@kaminskypavel
Copy link
Author

kaminskypavel commented Dec 5, 2022

I suggest someone else try to run it. Let's see if I'm the only one getting it.

Btw I'm using a beast PC (64gb of RAM), so I doubt it has to do with my specs.

@WorkAttackDev
Copy link

I'm also getting segmentation fault when running my test
my vitest version: v0.25.2
my node version: v18.12.1

My config
export default defineConfig({
plugins: [react()],
test: {
environment: "node",
testTimeout: 20000,
},
resolve: {
alias: {
"@server": path.resolve(__dirname, "./features/server"),
"@shared": path.resolve(__dirname, "./features/shared"),
},
},
});

Screenshot_20221206_014400

@colinparsonscom
Copy link

Running into the same Segmentation Fault issue with GitHub Actions, even when tests succesfully complete in GitHub Actions using vitest run.

@enzoferey
Copy link

Since this is appeared at the top of the Google search, I'm leaving the two things that were causing issues on my side:

  1. Not using it.each or test.each and just looping through an array creating it / test statements on the fly.
  2. My project is not using Vite and I did not have a vitest.config.ts, it seems to be one of the three possible options to configure Vitest. I find the get started docs not very clear about this, it should be mentioned right below the installation command if you ask me.

@sheremet-va
Copy link
Member

The recommended solution when working with Prisma is using the forks pool. Vitest 2.0 uses it by default instead of worker threads.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants