Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
973 changes: 775 additions & 198 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions rsbuild/react-rstest/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Local
.DS_Store
*.local
*.log*

# Dist
node_modules
dist/

# IDE
.vscode/*
!.vscode/extensions.json
.idea
35 changes: 35 additions & 0 deletions rsbuild/react-rstest/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Rsbuild Project

## Setup

Install the dependencies:

```bash
pnpm install
```

## Get Started

Start the dev server:

```bash
pnpm dev
```

Build the app for production:

```bash
pnpm build
```

Preview the production build locally:

```bash
pnpm preview
```

Run unit tests via Rstest:

```bash
pnpm test
```
26 changes: 26 additions & 0 deletions rsbuild/react-rstest/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "rsbuild-react-rstest",
"version": "1.0.0",
"private": true,
"scripts": {
"build": "rsbuild build",
"dev": "rsbuild dev --open",
"preview": "rsbuild preview",
"test": "rstest run"
},
"dependencies": {
"react": "^19.1.0",
"react-dom": "^19.1.0"
},
"devDependencies": {
"@rsbuild/core": "^1.4.8",
"@rsbuild/plugin-react": "^1.1.1",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.2.0",
"@types/react": "^19.0.12",
"@types/react-dom": "^19.0.4",
"@rstest/core": "0.0.10",
"ts-node": "^10.9.2",
"typescript": "^5.8.2"
}
}
6 changes: 6 additions & 0 deletions rsbuild/react-rstest/rsbuild.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { defineConfig } from '@rsbuild/core';
import { pluginReact } from '@rsbuild/plugin-react';

export default defineConfig({
plugins: [pluginReact()],
});
9 changes: 9 additions & 0 deletions rsbuild/react-rstest/rstest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { defineConfig } from '@rstest/core';
import rsbuildConfig from './rsbuild.config';

export default defineConfig({
...rsbuildConfig,
testEnvironment: 'jsdom',
globals: true,
setupFiles: ['./rstest.setup.ts'],
});
1 change: 1 addition & 0 deletions rsbuild/react-rstest/rstest.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import '@testing-library/jest-dom';
26 changes: 26 additions & 0 deletions rsbuild/react-rstest/src/App.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
body {
margin: 0;
color: #fff;
font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
background-image: linear-gradient(to bottom, #020917, #101725);
}

.content {
display: flex;
min-height: 100vh;
line-height: 1.1;
text-align: center;
flex-direction: column;
justify-content: center;
}

.content h1 {
font-size: 3.6rem;
font-weight: 700;
}

.content p {
font-size: 1.2rem;
font-weight: 400;
opacity: 0.5;
}
12 changes: 12 additions & 0 deletions rsbuild/react-rstest/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import './App.css';

const App = () => {
return (
<div className="content">
<h1>Rsbuild with React</h1>
<p>Start building amazing things with Rsbuild.</p>
</div>
);
};

export default App;
1 change: 1 addition & 0 deletions rsbuild/react-rstest/src/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="@rsbuild/core/types" />
10 changes: 10 additions & 0 deletions rsbuild/react-rstest/src/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App';

const root = ReactDOM.createRoot(document.getElementById('root')!);
root.render(
<React.StrictMode>
<App />
</React.StrictMode>,
);
8 changes: 8 additions & 0 deletions rsbuild/react-rstest/tests/App.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { render, screen } from '@testing-library/react';
import App from '../src/App';

test('Renders the main page', () => {
const testMessage = 'Rsbuild with React';
render(<App />);
expect(screen.getByText(testMessage)).toBeInTheDocument();
});
7 changes: 7 additions & 0 deletions rsbuild/react-rstest/tests/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"types": ["@testing-library/jest-dom"]
},
"include": ["./"]
}
15 changes: 15 additions & 0 deletions rsbuild/react-rstest/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"compilerOptions": {
"target": "ES2020",
"lib": ["DOM", "ES2020"],
"module": "ESNext",
"jsx": "react-jsx",
"strict": true,
"skipLibCheck": true,
"isolatedModules": true,
"resolveJsonModule": true,
"moduleResolution": "bundler",
"useDefineForClassFields": true
},
"include": ["src"]
}