Skip to content

Commit

Permalink
test: ESM edition of msw does not work in ESM environment, so import …
Browse files Browse the repository at this point in the history
…CJS edition

- ref: mswjs/msw#1399
  • Loading branch information
mizdra committed Sep 18, 2022
1 parent eac6ece commit 50d5456
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/test/msw.ts
@@ -1,4 +1,11 @@
import { createRequire } from 'node:module';
import type { SetupServerApi } from 'msw/node';
import { setupServer } from 'msw/node';

const require = createRequire(import.meta.url);

// NOTE: ESM edition of msw does not work in ESM environment, so import CJS edition
// ref: https://github.com/mswjs/msw/pull/1399
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
const { setupServer } = require('msw/node') as typeof import('msw/node');

export const server: SetupServerApi = setupServer();

0 comments on commit 50d5456

Please sign in to comment.