epicweb-dev / rocket-rental

Rent Rockets from rocking awesome people
Other
277 stars 35 forks source link

Vitest process exit called with "1" #17

Closed ericchernuka closed 1 year ago

ericchernuka commented 1 year ago

I just cloned the repo and ran the tests, but Vitest ends up existing with many warnings from MSW regarding local files. Has anyone experienced this?

Running Node 18.16.0 (same as this repo's CI) on OSX 13.4.

➜  rocket-rental git:(main) ✗ npm test

> test
> vitest

 DEV  v0.30.0 /Users/ericchernuka/Code/_playground/rocket-rental

stderr | unknown test
[MSW] Warning: captured a request without a matching request handler:

  • GET http://localhost:3000/Users/ericchernuka/Code/_playground/rocket-rental/tests/vitest-utils.ts

If you still wish to intercept this unhandled request, please create a request handler for it.
Read more: https://mswjs.io/docs/getting-started/mocks
[MSW] Warning: captured a request without a matching request handler:

  • GET http://localhost:3000/Users/ericchernuka/Code/_playground/rocket-rental/app/utils/auth.server.ts

If you still wish to intercept this unhandled request, please create a request handler for it.
Read more: https://mswjs.io/docs/getting-started/mocks
[MSW] Warning: captured a request without a matching request handler:

  • GET http://localhost:3000/Users/ericchernuka/Code/_playground/rocket-rental/app/utils/session.server.ts

If you still wish to intercept this unhandled request, please create a request handler for it.
Read more: https://mswjs.io/docs/getting-started/mocks
[MSW] Warning: captured a request without a matching request handler:

  • GET file:///Users/ericchernuka/Code/_playground/rocket-rental/node_modules/tiny-invariant/dist/esm/tiny-invariant.js

If you still wish to intercept this unhandled request, please create a request handler for it.
Read more: https://mswjs.io/docs/getting-started/mocks

stderr | unknown test
[MSW] Warning: captured a request without a matching request handler:

  • GET http://localhost:3000/Users/ericchernuka/Code/_playground/rocket-rental/tests/vitest-utils.ts

If you still wish to intercept this unhandled request, please create a request handler for it.
Read more: https://mswjs.io/docs/getting-started/mocks
[MSW] Warning: captured a request without a matching request handler:

  • GET http://localhost:3000/Users/ericchernuka/Code/_playground/rocket-rental/app/utils/auth.server.ts

If you still wish to intercept this unhandled request, please create a request handler for it.
Read more: https://mswjs.io/docs/getting-started/mocks
[MSW] Warning: captured a request without a matching request handler:

  • GET http://localhost:3000/Users/ericchernuka/Code/_playground/rocket-rental/app/utils/session.server.ts

If you still wish to intercept this unhandled request, please create a request handler for it.
Read more: https://mswjs.io/docs/getting-started/mocks
[MSW] Warning: captured a request without a matching request handler:

  • GET file:///Users/ericchernuka/Code/_playground/rocket-rental/node_modules/tiny-invariant/dist/esm/tiny-invariant.js

If you still wish to intercept this unhandled request, please create a request handler for it.
Read more: https://mswjs.io/docs/getting-started/mocks

 ❯ app/routes/resources+/delete-image.test.tsx (0)
 ❯ app/routes/bookings+/$bookingId.test.tsx (0)
 ❯ app/routes/ships_+/$shipId.book.test.tsx (0)
 ✓ app/routes/users_+/__shared.basic-info.test.tsx (4)
 ✓ app/routes/resources+/city-combobox.test.tsx (1)

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unexpected Exit ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Error: process.exit called with "1"
 ❯ process.afterFirstError node_modules/close-with-grace/index.js:49:13
 ❯ process.emit node:events:525:3
onemen commented 1 year ago

did you change something in the config?

I see the something similar in Windows 11 when removing globals for me the failing tests are in app/routes/users_+/__shared.basic-info.test.tsx

stderr | app/routes/users_+/__shared.basic-info.test.tsx > Link to chat is links to login if user is not logged in
[MSW] Warning: captured a request without a matching request handler:

  • GET file:///C:/projects/kcd-apps/rocket-rental/node_modules/vitest/dist/entry.js

If you still wish to intercept this unhandled request, please create a request handler for it.
Read more: https://mswjs.io/docs/getting-started/mocks
[MSW] Warning: captured a request without a matching request handler:

  • GET file:///C:/projects/kcd-apps/rocket-rental/node_modules/@vitest/runner/dist/index.js

If you still wish to intercept this unhandled request, please create a request handler for it.
Read more: https://mswjs.io/docs/getting-started/mocks
[MSW] Warning: captured a request without a matching request handler:

  • GET c:///\projects\kcd-apps\rocket-rental\app\routes\users_+\__shared.basic-info.test.tsx

If you still wish to intercept this unhandled request, please create a request handler for it.
Read more: https://mswjs.io/docs/getting-started/mocks
[MSW] Warning: captured a request without a matching request handler:

  • GET c:///\projects\kcd-apps\rocket-rental\node_modules\@testing-library\dom\dist\query-helpers.js

If you still wish to intercept this unhandled request, please create a request handler for it.
Read more: https://mswjs.io/docs/getting-started/mocks
[MSW] Warning: captured a request without a matching request handler:

  • GET c:///\projects\kcd-apps\rocket-rental\node_modules\@testing-library\dom\dist\wait-for.js

If you still wish to intercept this unhandled request, please create a request handler for it.
Read more: https://mswjs.io/docs/getting-started/mocks

 ✓ app/utils/encryption.server.test.ts (3)
 ✓ app/routes/resources+/delete-image.test.tsx (4) 643ms
 ✓ app/routes/bookings+/$bookingId.test.tsx (6) 734ms
 ❯ app/routes/users_+/__shared.basic-info.test.tsx (4)
   ✓ Link to chat is a form if user is logged in, is not self, and no chat exists yet
   ✓ Link to chat is link to specific chat if logged in, not self, and there is a history
   ✓ Link to chat is link to all chats if viewing it myself along with edit profile link
   | Link to chat is links to login if user is not logged in
 ✓ app/routes/ships_+/$shipId.book.test.tsx (2)
 ✓ app/routes/resources+/city-combobox.test.tsx (1) 562ms
import tsconfigPaths from 'vite-tsconfig-paths'

export default defineConfig({
  plugins: [react(), tsconfigPaths()],
  test: {
    include: ['./app/**/*.test.{ts,tsx}'],
-    globals: true,
    environment: 'jsdom',
    setupFiles: ['./tests/setup/setup-test-env.ts'],
    globalSetup: ['./tests/setup/global-setup.ts'],
    coverage: {
      include: ['app/**/*.{ts,tsx}'],
      all: true,
onemen commented 1 year ago

@kentcdodds,

maybe we are missing GET handler in mocks\index.ts

kentcdodds commented 1 year ago

Is this now resolved for you?

ericchernuka commented 1 year ago

Not sure it was related, but the close-with-grace was masking the lack of an env variable on my side.

I also logged an issue in MSW for all the warnings for file system files, https://github.com/mswjs/msw/issues/1630.

In my testing, the warnings seem all related to the use of unstable_createRemixStub as we've seen in our organization's project also. The warnings only show up if something fails. In this case, if I didn't have the .env file, everything fails and MSW starts logging files.