[BUG] Tests fail in brand new Hydrogen starter
Describe the bug
Running npm test or npm run test:ci in a brand new Hydrogen starter template, the tests fail with the following error
TypeError: Class extends value undefined is not a constructor or null
❯ node_modules/@shopify/hydrogen/dist/esnext/foundation/fetchSync/ResponseSync.js:3:35
1| import { parseJSON } from '../../utilities/parse.js';
2| import { log } from '../../utilities/log/index.js';
3| export class ResponseSync extends Response {
| ^
4| bodyUsed = true;
5| #text;
To Reproduce
- StackBlitz sandbox reproducing the issue, though any hydrogen.new should have the same problem.
Run the tests and see.
Expected behaviour Tests in the Hydrogen starter shouldn't fail from the onset.
Additional context
- Hydrogen version: 1.3.1
- Node version: v16.14.2
+1
@beppek I've been trying to track this down. It looks to be an odd bug in either npm or node. A temporary workaround is to:
- Install the latest node v18
- Use yarn instead of npm
Separately to this the tests through vitest seem to be unstable when they run in parallel. Running them sequentially fixes that as well. See this PR on how to change your vite config file: https://github.com/Shopify/hydrogen/pull/2006
Thanks @blittle that solves it for us.