hydrogen icon indicating copy to clipboard operation
hydrogen copied to clipboard

[BUG] Tests fail in brand new Hydrogen starter

Open beppek opened this issue 3 years ago • 3 comments

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

beppek avatar Sep 05 '22 22:09 beppek

+1

harmjanluth avatar Sep 12 '22 18:09 harmjanluth

@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:

  1. Install the latest node v18
  2. 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

blittle avatar Sep 13 '22 13:09 blittle

Thanks @blittle that solves it for us.

beppek avatar Sep 15 '22 06:09 beppek