Skip to content

Commit 401d5c2

Browse files
authored
feat(create-rstack): add app template tests (#251)
1 parent d116f5f commit 401d5c2

47 files changed

Lines changed: 218 additions & 19 deletions

Some content is hidden

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

packages/create-rstack/template-app-react-js/AGENTS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55
- `{{ packageManager }} run dev` - Start the development server
66
- `{{ packageManager }} run build` - Build the app for production
77
- `{{ packageManager }} run preview` - Preview the production build locally
8+
- `{{ packageManager }} run test` - Run tests
9+
- `{{ packageManager }} run test:watch` - Run tests in watch mode
810

911
## Docs
1012

1113
- Rsbuild: https://rsbuild.rs/llms.txt
1214
- Rspack: https://rspack.rs/llms.txt
15+
- Rstest: https://rstest.rs/llms.txt

packages/create-rstack/template-app-react-js/package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,19 @@
99
"format": "rs fmt",
1010
"lint": "rs lint",
1111
"preview": "rs preview",
12-
"test": "rs test"
12+
"test": "rs test",
13+
"test:watch": "rs test --watch"
1314
},
1415
"dependencies": {
1516
"react": "^19.2.8",
1617
"react-dom": "^19.2.8"
1718
},
1819
"devDependencies": {
1920
"@rsbuild/plugin-react": "^2.1.0",
21+
"@testing-library/dom": "^10.4.1",
22+
"@testing-library/jest-dom": "^7.0.0",
23+
"@testing-library/react": "^16.3.2",
24+
"happy-dom": "^20.11.1",
2025
"rstack": "^0.3.5"
2126
}
2227
}

packages/create-rstack/template-app-react-js/rstack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ define.app(async () => {
1111
});
1212

1313
define.test({
14-
// Configure Rstest
14+
setupFiles: ['./tests/rstest.setup.js'],
1515
});
1616

1717
define.lint(async () => {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { expect, test } from 'rstack/test';
2+
import { render, screen } from '@testing-library/react';
3+
import App from '../src/App';
4+
5+
test('renders the main page', () => {
6+
render(<App />);
7+
expect(screen.getByText('Rstack with React')).toBeInTheDocument();
8+
});
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { expect } from 'rstack/test';
2+
import * as jestDomMatchers from '@testing-library/jest-dom/matchers';
3+
4+
expect.extend(jestDomMatchers);

packages/create-rstack/template-app-react-ts/AGENTS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55
- `{{ packageManager }} run dev` - Start the development server
66
- `{{ packageManager }} run build` - Build the app for production
77
- `{{ packageManager }} run preview` - Preview the production build locally
8+
- `{{ packageManager }} run test` - Run tests
9+
- `{{ packageManager }} run test:watch` - Run tests in watch mode
810

911
## Docs
1012

1113
- Rsbuild: https://rsbuild.rs/llms.txt
1214
- Rspack: https://rspack.rs/llms.txt
15+
- Rstest: https://rstest.rs/llms.txt

packages/create-rstack/template-app-react-ts/package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,22 @@
99
"format": "rs fmt",
1010
"lint": "rs lint",
1111
"preview": "rs preview",
12-
"test": "rs test"
12+
"test": "rs test",
13+
"test:watch": "rs test --watch"
1314
},
1415
"dependencies": {
1516
"react": "^19.2.8",
1617
"react-dom": "^19.2.8"
1718
},
1819
"devDependencies": {
1920
"@rsbuild/plugin-react": "^2.1.0",
21+
"@testing-library/dom": "^10.4.1",
22+
"@testing-library/jest-dom": "^7.0.0",
23+
"@testing-library/react": "^16.3.2",
2024
"@types/node": "^24.13.3",
2125
"@types/react": "^19.2.18",
2226
"@types/react-dom": "^19.2.4",
27+
"happy-dom": "^20.11.1",
2328
"rstack": "^0.3.5",
2429
"typescript": "^7.0.2"
2530
}

packages/create-rstack/template-app-react-ts/rstack.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ define.app(async () => {
1010
});
1111

1212
define.test({
13-
// Configure Rstest
13+
setupFiles: ['./tests/rstest.setup.ts'],
1414
});
1515

1616
define.lint(async () => {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { expect, test } from 'rstack/test';
2+
import { render, screen } from '@testing-library/react';
3+
import App from '../src/App';
4+
5+
test('renders the main page', () => {
6+
render(<App />);
7+
expect(screen.getByText('Rstack with React')).toBeInTheDocument();
8+
});
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { expect } from 'rstack/test';
2+
import * as jestDomMatchers from '@testing-library/jest-dom/matchers';
3+
4+
expect.extend(jestDomMatchers);

0 commit comments

Comments
 (0)