withastro / astro

The web framework for content-driven websites. ⭐️ Star to support our work!
https://astro.build
Other
45.59k stars 2.39k forks source link

npm run test errors #4628

Closed jaeh closed 2 years ago

jaeh commented 2 years ago

What version of astro are you using?

1.1.5

Are you using an SSR adapter? If so, which one?

none

What package manager are you using?

npm, pnpm

What operating system are you using?

linux, debian

Describe the Bug

tests are failing on my machine:

node v18.3.0 
deno v1.25.1
pnpm v7.11.0
npm  v8.11.0

1. Part: npm run test

when running the tests they run fine until one of the test servers seems to close before the tests are done.

can not create a link to a working example.

reproduce (on my machine):

git clone https://github.com/withastro/astro
pnpm install
npm run test # not a typo, pnpm errors differently, see below

fails with:

astro:test:   499 passing (3m)
astro:test:   9 pending
astro:test:   137 failing
astro:test:
astro:test:   1) CSS
astro:test:        dev
astro:test:          "before all" hook for "resolves CSS in public/":
astro:test:      TypeError: fetch failed
astro:test:       at Object.processResponse (node:internal/deps/undici/undici:5536:34)
astro:test:       at node:internal/deps/undici/undici:5858:42
astro:test:       at node:internal/process/task_queues:140:7
astro:test:       at AsyncResource.runInAsyncScope (node:async_hooks:202:9)
astro:test:       at AsyncResource.runMicrotask (node:internal/process/task_queues:137:8)
astro:test:       at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

#... and here 136 more errors get logged, including the port of the server that closed:

astro:test:  FetchError: request to http://127.0.0.1:3003/ failed, reason: connect ECONNREFUSED 127.0.0.1:3003

# the complete log is too long to attach here, can provide if needed.

2. Part: pnpm run test

when creating this issue i figured "maybe i should run pnpm run test instead", so i did, this is the output:

j@m:~/dev/vendor/astro/astro$ pnpm run test

> root@0.0.0 test /home/j/dev/vendor/astro/astro
> turbo run test --output-logs=new-only --concurrency=1 --filter=astro --filter=create-astro --filter="@astrojs/*"

• Packages in scope: @astrojs/alpinejs, @astrojs/cloudflare, @astrojs/deno, @astrojs/image, @astrojs/lit, @astrojs/markdown-component, @astrojs/markdown-remark, @astrojs/mdx, @astrojs/netlify, @astrojs/node, @astrojs/partytown, @astrojs/preact, @astrojs/prefetch, @astrojs/prism, @astrojs/react, @astrojs/rss, @astrojs/sitemap, @astrojs/solid-js, @astrojs/svelte, @astrojs/tailwind, @astrojs/telemetry, @astrojs/turbolinks, @astrojs/vercel, @astrojs/vue, @astrojs/webapi, astro, create-astro
• Running test in 27 packages
@astrojs/node:test: cache miss, executing e21390501583f96f
@astrojs/node:test:
@astrojs/node:test: > @astrojs/node@1.0.1 test /home/j/dev/vendor/astro/astro/packages/integrations/node
@astrojs/node:test: > mocha --exit --timeout 20000 test/
@astrojs/node:test:
@astrojs/node:test:
@astrojs/node:test:
@astrojs/node:test:   API routes
@astrojs/node:test:     1) Can get the request body
@astrojs/node:test:     2) Can get binary data
@astrojs/node:test:
@astrojs/node:test:
@astrojs/node:test:   0 passing (1s)
@astrojs/node:test:   2 failing
@astrojs/node:test:
@astrojs/node:test:   1) API routes
@astrojs/node:test:        Can get the request body:
@astrojs/node:test:      TypeError: Cannot read properties of undefined (reading 'toString')
@astrojs/node:test:       at Context.<anonymous> (file:///home/j/dev/vendor/astro/astro/packages/integrations/node/test/api-route.test.js:30:32)
@astrojs/node:test:
@astrojs/node:test:   2) API routes
@astrojs/node:test:        Can get binary data:
@astrojs/node:test:      TypeError: Cannot read properties of undefined (reading 'buffer')
@astrojs/node:test:       at Context.<anonymous> (file:///home/j/dev/vendor/astro/astro/packages/integrations/node/test/api-route.test.js:47:43)
@astrojs/node:test:
@astrojs/node:test:
@astrojs/node:test:
@astrojs/node:test:  ELIFECYCLE  Test failed. See above for more details.
@astrojs/node:test: Error: command finished with error: command (packages/integrations/node) pnpm run test exited (1)
@astrojs/cloudflare:test: cache miss, executing c33ee4e91a7f8d5d
@astrojs/image:test: cache miss, executing 5026a1e850a1c9da
@astrojs/rss:test: cache miss, executing 9e5b412a45f333bf
@astrojs/vercel:test: cache miss, executing 4204d4d8cc05ada8
@astrojs/telemetry:test: cache miss, executing 7ed5a7301bf60a4e
@astrojs/lit:test: cache miss, executing e91fa4b85bec58a3
astro:test: cache miss, executing a187a962e31b7b28
create-astro:test: cache miss, executing 162add0faa4ffb24
@astrojs/mdx:test: cache miss, executing 47cf3e194d6acd16
@astrojs/markdown-remark:test: cache miss, executing 27d4064b7e1836ae
@astrojs/prefetch:test: cache miss, executing d3c7eabe6cec6d22
@astrojs/sitemap:test: cache miss, executing 25f15defe3837ad9
@astrojs/deno:test: cache miss, executing 6d4037e8da86cd00
@astrojs/markdown-component:test: cache miss, executing d3cc010d740af280
@astrojs/netlify:test: cache miss, executing 86ad82c82ad559cf
@astrojs/webapi:test: cache miss, executing d6c55fc7262dfb42
command (packages/integrations/node) pnpm run test exited (1)

 Tasks:    0 successful, 1 total
Cached:    0 cached, 1 total
  Time:    3.81s

 ELIFECYCLE  Test failed. See above for more details.

Link to Minimal Reproducible Example

not applicable

Participation

matthewp commented 2 years ago

Did you run the build before hand? pnpm run build

I don't normally run all tests at once as that takes a lot of time and is something that CI does for us. Unless CI is breaking or this specific test is failing them I'm not sure if there's anything actionable to do here. It might be flaky on your system. Would be curious if it passes when you run just that test.

matthewp commented 2 years ago

fwiw I just ran locally and all of the Astro tests passed. I think this is probably some flakiness or not knowing to run pnpm run build. As part of your workflow I recommend just running the tests you are working on in order to save time. You can do that like this: pnpm --filter astro run test:match API

Closing as I think there's nothing to be done about this.