From 6adf89b04bdd13493405760a8bbb367485600b53 Mon Sep 17 00:00:00 2001 From: neverland Date: Fri, 10 Jul 2026 16:18:16 +0800 Subject: [PATCH 1/2] chore: migrate tests to Rstest --- package.json | 5 +-- pnpm-lock.yaml | 70 +++++++++++++++++++++++++++++++++------- pnpm-workspace.yaml | 1 + rstest.config.ts | 10 ++++++ test/basic/index.test.ts | 2 +- 5 files changed, 73 insertions(+), 15 deletions(-) create mode 100644 rstest.config.ts diff --git a/package.json b/package.json index 1807e26..0262306 100644 --- a/package.json +++ b/package.json @@ -30,17 +30,18 @@ "lint": "rslint && prettier -c .", "lint:write": "rslint --fix && prettier -w .", "prepare": "simple-git-hooks", - "test": "playwright test", + "test": "rstest", "bump": "npx bumpp" }, "simple-git-hooks": { "pre-commit": "pnpm run lint:write" }, "devDependencies": { - "@playwright/test": "^1.60.0", "@rsbuild/core": "^2.0.9", "@rslib/core": "^0.23.2", "@rslint/core": "^0.6.1", + "@rstest/core": "^0.11.1", + "@rstest/playwright": "^0.11.1", "@types/node": "^24.12.4", "playwright": "^1.60.0", "prettier": "^3.8.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 05c4742..f3f569f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,9 +8,6 @@ importers: .: devDependencies: - '@playwright/test': - specifier: ^1.60.0 - version: 1.60.0 '@rsbuild/core': specifier: ^2.0.9 version: 2.0.9 @@ -20,6 +17,12 @@ importers: '@rslint/core': specifier: ^0.6.1 version: 0.6.1 + '@rstest/core': + specifier: ^0.11.1 + version: 0.11.1 + '@rstest/playwright': + specifier: ^0.11.1 + version: 0.11.1(@rstest/core@0.11.1)(playwright@1.60.0) '@types/node': specifier: ^24.12.4 version: 24.12.4 @@ -135,11 +138,6 @@ packages: '@emnapi/core': ^1.7.1 '@emnapi/runtime': ^1.7.1 - '@playwright/test@1.60.0': - resolution: {integrity: sha512-O71yZIbAh/PxDMNGns37GHBIfrVkEVyn+AXyIa5dOTfb4/xNvRWV+Vv/NMbNCtODB/pO7vLlF2OTmMVLhmr7Ag==} - engines: {node: '>=18'} - hasBin: true - '@rsbuild/core@2.0.9': resolution: {integrity: sha512-lK2bMNuwh3TuLXLskS7nG3fnQk+6eaLeeZiquJWcna4JZx9iaI59JSd+iLcg5TeZLjEVygkwn/HcE+yuYDQRAw==} engines: {node: ^20.19.0 || >=22.12.0} @@ -377,6 +375,26 @@ packages: '@swc/helpers': optional: true + '@rstest/core@0.11.1': + resolution: {integrity: sha512-9iJnDrM/zYuHyk1//CMr/Jer2XughgN3fYagGb1YWpMLUke+E+WXlUPgACwf7OkmIB47/TttbLFK+4zwGDNOFg==} + engines: {node: ^20.19.0 || >=22.12.0} + hasBin: true + peerDependencies: + happy-dom: ^20.8.3 + jsdom: '*' + peerDependenciesMeta: + happy-dom: + optional: true + jsdom: + optional: true + + '@rstest/playwright@0.11.1': + resolution: {integrity: sha512-VhA5SvfYTdC9nJ572Q5NfR8OqcHWr9Agd9zWrkSCBC3sQDwuWLiZTTX4wAv8hMwRtDGzNG0otUPTDrCQ1r0hWQ==} + engines: {node: ^20.19.0 || >=22.12.0} + peerDependencies: + '@rstest/core': workspace:^ + playwright: ^1.49.1 + '@swc/helpers@0.5.23': resolution: {integrity: sha512-5lSsMOTXURePglDfvuAQUqkGek9Hg2kksOYay2m0+XR++b2NWYL/4sWyuvVBIs8oKnJaxkdi9whaL/sqN13afw==} @@ -386,6 +404,12 @@ packages: '@tybys/wasm-util@0.10.3': resolution: {integrity: sha512-F3fo1MYrRJYL3zER0OUOmkutjr1Vp23m7OsSgp7nq4SP6OqX6C/56XFIPAl5bt3zaBRjmW7SGz3u/6LwFpYcOg==} + '@types/chai@5.2.3': + resolution: {integrity: sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==} + + '@types/deep-eql@4.0.2': + resolution: {integrity: sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==} + '@types/node@24.12.4': resolution: {integrity: sha512-GUUEShf+PBCGW2KaXwcIt3Yk+e3pkKwWKb9GSyM9WQVE+ep2jzmHdGsHzu4wgcZy5fN9FBdVzjpBQsYlpfpgLA==} @@ -509,6 +533,10 @@ packages: cpu: [x64] os: [win32] + assertion-error@2.0.1: + resolution: {integrity: sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==} + engines: {node: '>=12'} + fsevents@2.3.2: resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==} engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} @@ -651,10 +679,6 @@ snapshots: '@tybys/wasm-util': 0.10.3 optional: true - '@playwright/test@1.60.0': - dependencies: - playwright: 1.60.0 - '@rsbuild/core@2.0.9': dependencies: '@rspack/core': 2.0.5(@swc/helpers@0.5.23) @@ -843,6 +867,19 @@ snapshots: optionalDependencies: '@swc/helpers': 0.5.23 + '@rstest/core@0.11.1': + dependencies: + '@rsbuild/core': 2.1.5 + '@types/chai': 5.2.3 + transitivePeerDependencies: + - '@module-federation/runtime-tools' + - core-js + + '@rstest/playwright@0.11.1(@rstest/core@0.11.1)(playwright@1.60.0)': + dependencies: + '@rstest/core': 0.11.1 + playwright: 1.60.0 + '@swc/helpers@0.5.23': dependencies: tslib: 2.8.1 @@ -857,6 +894,13 @@ snapshots: tslib: 2.8.1 optional: true + '@types/chai@5.2.3': + dependencies: + '@types/deep-eql': 4.0.2 + assertion-error: 2.0.1 + + '@types/deep-eql@4.0.2': {} + '@types/node@24.12.4': dependencies: undici-types: 7.16.0 @@ -921,6 +965,8 @@ snapshots: '@typescript/typescript-win32-x64@7.0.2': optional: true + assertion-error@2.0.1: {} + fsevents@2.3.2: optional: true diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index d20cc17..eb86c50 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -8,3 +8,4 @@ allowBuilds: minimumReleaseAgeExclude: - typescript - '@typescript/*' + - '@rstest/*' diff --git a/rstest.config.ts b/rstest.config.ts new file mode 100644 index 0000000..70f9593 --- /dev/null +++ b/rstest.config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from '@rstest/core'; + +export default defineConfig({ + env: { + // Let Rsbuild choose the mode based on the command. + NODE_ENV: undefined, + }, + isolate: false, + testTimeout: 30_000, +}); diff --git a/test/basic/index.test.ts b/test/basic/index.test.ts index 4698b7c..52a75b7 100644 --- a/test/basic/index.test.ts +++ b/test/basic/index.test.ts @@ -1,7 +1,7 @@ import { readdir, readFile, writeFile } from 'node:fs/promises'; import { dirname, join } from 'node:path'; import { fileURLToPath } from 'node:url'; -import { expect, test } from '@playwright/test'; +import { expect, test } from '@rstest/playwright'; import { createRsbuild } from '@rsbuild/core'; import { pluginVirtualModule } from 'rsbuild-plugin-virtual-module'; import { getRandomPort } from '../helper'; From 4561a0a51c174c219842adcdc8e67aec2ffe9f0c Mon Sep 17 00:00:00 2001 From: neverland Date: Fri, 10 Jul 2026 16:41:21 +0800 Subject: [PATCH 2/2] chore: remove global test timeout --- rstest.config.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/rstest.config.ts b/rstest.config.ts index 70f9593..b68293b 100644 --- a/rstest.config.ts +++ b/rstest.config.ts @@ -6,5 +6,4 @@ export default defineConfig({ NODE_ENV: undefined, }, isolate: false, - testTimeout: 30_000, });