Skip to content

Commit 1adcaab

Browse files
committed
test(remix): Migrate to Vitest
1 parent ba4586f commit 1adcaab

File tree

7 files changed

+31
-29
lines changed

7 files changed

+31
-29
lines changed

packages/remix/jest.config.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

packages/remix/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@
101101
"test:integration:ci": "run-s test:integration:clean test:integration:prepare test:integration:client:ci test:integration:server",
102102
"test:integration:prepare": "(cd test/integration && yarn install)",
103103
"test:integration:clean": "(cd test/integration && rimraf .cache node_modules build)",
104-
"test:integration:client": "yarn playwright install-deps && yarn playwright test test/integration/test/client/ --project='chromium'",
104+
"test:integration:client": "yarn playwright install-deps && yarn playwright test test/integration/test/client/ --config vitest.config.integration.ts --project='chromium'",
105105
"test:integration:client:ci": "yarn test:integration:client",
106106
"test:integration:server": "export NODE_OPTIONS='--stack-trace-limit=25' && vitest run",
107-
"test:unit": "jest",
108-
"test:watch": "jest --watch",
107+
"test:unit": "vitest run --config vitest.config.unit.ts",
108+
"test:watch": "vitest --watch --config vitest.config.unit.ts",
109109
"yalc:publish": "yalc publish --push --sig"
110110
},
111111
"volta": {

packages/remix/test/index.client.test.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
import * as SentryReact from '@sentry/react';
2+
import { describe, vi, it, expect, afterEach, type Mock } from 'vitest';
23

34
import { init } from '../src/index.client';
45

5-
jest.mock('@sentry/react', () => {
6-
return {
7-
__esModule: true,
8-
...jest.requireActual('@sentry/react'),
9-
};
10-
});
6+
vi.mock('@sentry/react', {spy: true});
117

12-
const reactInit = jest.spyOn(SentryReact, 'init');
8+
const reactInit = SentryReact.init as Mock;
139

1410
describe('Client init()', () => {
1511
afterEach(() => {
16-
jest.clearAllMocks();
12+
vi.clearAllMocks();
1713

1814
SentryReact.getGlobalScope().clear();
1915
SentryReact.getIsolationScope().clear();

packages/remix/test/index.server.test.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
import * as SentryNode from '@sentry/node';
2+
import { describe, vi, it, expect, afterEach, type Mock } from 'vitest';
23

34
import { init } from '../src/index.server';
45

5-
jest.mock('@sentry/node', () => {
6-
return {
7-
__esModule: true,
8-
...jest.requireActual('@sentry/node'),
9-
};
10-
});
6+
vi.mock('@sentry/node', {spy: true});
117

12-
const nodeInit = jest.spyOn(SentryNode, 'init');
8+
const nodeInit = SentryNode.init as Mock;
139

1410
describe('Server init()', () => {
1511
afterEach(() => {
16-
jest.clearAllMocks();
12+
vi.clearAllMocks();
1713

1814
SentryNode.getGlobalScope().clear();
1915
SentryNode.getIsolationScope().clear();

packages/remix/tsconfig.test.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
{
22
"extends": "./tsconfig.json",
33

4-
"include": ["test/**/*", "vitest.config.ts"],
4+
"include": ["test/**/*", "vitest.config.integration.ts", "vitest.config.unit.ts"],
55

66
"compilerOptions": {
77
"lib": ["DOM", "ES2018"],
8-
"types": ["node", "jest"],
8+
"types": ["node"],
9+
// Required for top-level await in tests
10+
"module": "Node16",
11+
"target": "ES2017",
12+
913
"esModuleInterop": true
1014
}
1115
}
File renamed without changes.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { defineConfig } from 'vitest/config';
2+
3+
import baseConfig from '../../vite/vite.config';
4+
5+
export default defineConfig({
6+
...baseConfig,
7+
test: {
8+
...baseConfig.test,
9+
// disableConsoleIntercept: true,
10+
// silent: false,
11+
include: ['test/**/*.test.ts'],
12+
exclude: ['**/integration/**/*.test.ts'],
13+
},
14+
});

0 commit comments

Comments
 (0)