Skip to content

Vitest tests fail with error "Cannot find package 'graphql' imported" in v2.4.0 #2248

Description

@am-ma

Prerequisites

Environment check

  • I'm using the latest msw version
  • I'm using Node.js version 18 or higher

Node.js version

v20.10.0

Reproduction repository

https://github.com/am-ma/msw2.4.0-examples-for-issue/tree/main/examples/with-vitest

Reproduction steps

  1. Upgrade nsw to v2.4.0
  2. Run tests <- error occurred

Current behavior

All tests fail.

 FAIL  example-jsdom.test.ts [ example-jsdom.test.ts ]
 FAIL  example.test.ts [ example.test.ts ]
Error: Cannot find package 'graphql' imported from {userDir}/msw2.4.0-examples-for-issue/examples/with-vitest/node_modules/msw/lib/core/utils/internal/parseGraphQLRequest.mjs

Expected behavior

Tests succeed without error.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingneeds:triageIssues that have not been investigated yet.scope:nodeRelated to MSW running in Node

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions