Skip to content

Commit 47abe2c

Browse files
authored
chore: update react example with @testing-library/jest-dom (#510)
1 parent 7f5ece4 commit 47abe2c

File tree

6 files changed

+19
-2
lines changed

6 files changed

+19
-2
lines changed

examples/react/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"@rsbuild/core": "1.5.0-rc.0",
1717
"@rsbuild/plugin-react": "^1.3.5",
1818
"@testing-library/dom": "^10.4.1",
19+
"@testing-library/jest-dom": "^6.8.0",
1920
"@testing-library/react": "^16.3.0",
2021
"@types/react": "^19.1.10",
2122
"@types/react-dom": "^19.1.7",

examples/react/rstest.config.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import { pluginReact } from '@rsbuild/plugin-react';
12
import { defineConfig } from '@rstest/core';
2-
import rsbuildConfig from './rsbuild.config';
33

44
export default defineConfig({
5-
...rsbuildConfig,
5+
plugins: [pluginReact()],
66
testEnvironment: 'jsdom',
7+
setupFiles: ['./rstest.setup.ts'],
78
});

examples/react/rstest.setup.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { expect } from '@rstest/core';
2+
import * as jestDomMatchers from '@testing-library/jest-dom/matchers';
3+
4+
expect.extend(jestDomMatchers);

examples/react/test/App.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ test('should render App correctly', async () => {
88
const element = screen.getByText('Rsbuild with React');
99

1010
expect(element.tagName).toBe('H1');
11+
expect(element).toBeInTheDocument();
1112
});

examples/react/test/tsconfig.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"compilerOptions": {
4+
"types": ["@testing-library/jest-dom"]
5+
},
6+
"include": ["./"]
7+
}

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)