Skip to content

Commit 19184b0

Browse files
9aoyfi3ework
andauthored
feat: support test projects (#420)
Co-authored-by: Wei <[email protected]>
1 parent bed5097 commit 19184b0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1232
-422
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,4 @@ jobs:
112112

113113
- name: E2E Test
114114
if: steps.changes.outputs.changed == 'true'
115-
run: pnpm run e2e && pnpm run test:example
115+
run: pnpm run e2e

e2e/build/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe('test build config', () => {
2020
command: 'rstest',
2121
args: [
2222
'run',
23-
`fixtures/${name}/index.test.ts`,
23+
`fixtures/${name}`,
2424
'-c',
2525
`fixtures/${name}/rstest.config.ts`,
2626
],

e2e/dom/fixtures/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"scripts": {
55
"dev": "rsbuild dev --open",
66
"build": "rsbuild build",
7-
"preview": "rsbuild preview"
7+
"preview": "rsbuild preview",
8+
"test": "rstest run"
89
},
910
"dependencies": {
1011
"react": "^19.1.1",

e2e/dom/fixtures/rstest.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ import rsbuildConfig from './rsbuild.config';
44
export default defineConfig({
55
...(rsbuildConfig as RstestConfig),
66
setupFiles: ['./test/setup.ts'],
7+
testEnvironment: 'jsdom',
78
});

e2e/dom/fixtures/rstest.externals.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import rsbuildConfig from './rsbuild.config';
44
export default defineConfig({
55
...(rsbuildConfig as RstestConfig),
66
setupFiles: ['./test/setup.ts'],
7+
testEnvironment: 'jsdom',
78
output: {
89
externals: [/react/],
910
},
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "@rstest/tests-project-client",
3+
"private": true,
4+
"scripts": {
5+
"dev": "rsbuild dev --open",
6+
"build": "rsbuild build",
7+
"test": "rstest run",
8+
"preview": "rsbuild preview"
9+
},
10+
"dependencies": {
11+
"react": "^19.1.1",
12+
"react-dom": "^19.1.1"
13+
},
14+
"devDependencies": {
15+
"@rsbuild/core": "1.5.0-rc.0",
16+
"@rsbuild/plugin-react": "^1.3.5",
17+
"@testing-library/jest-dom": "^6.8.0",
18+
"@testing-library/dom": "^10.4.1",
19+
"@testing-library/react": "^16.3.0",
20+
"@types/react": "^19.1.10",
21+
"@types/react-dom": "^19.1.7",
22+
"jsdom": "^26.1.0",
23+
"typescript": "^5.9.2"
24+
}
25+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { defineConfig } from '@rsbuild/core';
2+
import { pluginReact } from '@rsbuild/plugin-react';
3+
4+
export default defineConfig({
5+
plugins: [pluginReact()],
6+
});
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { defineConfig, type RstestConfig } from '@rstest/core';
2+
import rsbuildConfig from './rsbuild.config';
3+
4+
export default defineConfig({
5+
...(rsbuildConfig as RstestConfig),
6+
testEnvironment: 'jsdom',
7+
setupFiles: ['./test/setup.ts'],
8+
});
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const App = () => {
2+
return (
3+
<div className="content">
4+
<h1>Rsbuild with React</h1>
5+
<p>Start building amazing things with Rsbuild.</p>
6+
</div>
7+
);
8+
};
9+
10+
export default App;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference types="@rsbuild/core/types" />

0 commit comments

Comments
 (0)