diff --git a/package.json b/package.json index de64587d8..18627bad3 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "test:unit": "vitest", "test:node": "vitest run --config=./test/node/vitest.config.ts", "test:browser": "playwright test -c ./test/browser/playwright.config.ts", - "test:modules:node": "jest --config=./test/modules/node/jest.config.js", + "test:modules:node": "vitest run --config=./test/modules/node/vitest.config.ts", "test:modules:browser": "playwright test -c ./test/modules/browser/playwright.config.ts", "test:ts": "ts-node test/typings/run.ts", "prepare": "pnpm simple-git-hooks init", diff --git a/test/jest.config.js b/test/jest.config.js deleted file mode 100644 index 1f8692b34..000000000 --- a/test/jest.config.js +++ /dev/null @@ -1,29 +0,0 @@ -/** @type {import('jest').Config} */ -module.exports = { - rootDir: './node', - transform: { - '^.+\\.ts$': '@swc/jest', - }, - // Limit the concurrency because some tests recompile the library, - // creating a moment of time when it has no "lib" files. - maxWorkers: 1, - moduleNameMapper: { - '^msw(.*)': '/../..$1', - }, - testEnvironmentOptions: { - // Force JSDOM to use the Node module resolution because we're still in Node.js. - // Using browser resolution won't work by design because JSDOM is not a browser - // and doesn't ship with 100% compatibility with the browser APIs. - // In tests, using browser resolution will result in "ClientRequest" imports - // from "@mswjs/interceptors" to not be found because they are not exported - // by the browser bundle of that library. - customExportConditions: [''], - }, - globals: { - fetch, - Request, - Response, - TextEncoder, - TextDecoder, - }, -} diff --git a/test/modules/node/node-esm-tests/package.json b/test/modules/node/node-esm-tests/package.json deleted file mode 100644 index 3dbc1ca59..000000000 --- a/test/modules/node/node-esm-tests/package.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "type": "module" -} diff --git a/test/modules/node/tsconfig.json b/test/modules/node/tsconfig.json new file mode 100644 index 000000000..34fee733a --- /dev/null +++ b/test/modules/node/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "types": ["vitest/globals"] + }, + "include": ["./**/*.test.ts"] +} diff --git a/test/modules/node/vitest.config.ts b/test/modules/node/vitest.config.ts new file mode 100644 index 000000000..a4b93d7ca --- /dev/null +++ b/test/modules/node/vitest.config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from 'vitest/config' + +export default defineConfig({ + test: { + globals: true, + dir: __dirname, + environment: 'node', + testTimeout: 60_000, + }, +})