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
510 changes: 291 additions & 219 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion rsbuild/react-rstest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"devDependencies": {
"@rsbuild/core": "2.0.0-rc.1",
"@rsbuild/plugin-react": "^2.0.0-rc.2",
"@rstest/core": "^0.9.6",
"@rstest/core": "^0.9.7",
"@testing-library/jest-dom": "^6.9.1",
"@testing-library/react": "^16.3.2",
"@types/react": "^19.2.10",
Expand Down
2 changes: 1 addition & 1 deletion rslib/node-rstest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"devDependencies": {
"@rslib/core": "^0.21.0",
"@rstest/adapter-rslib": "^0.2.2",
"@rstest/core": "^0.9.6",
"@rstest/core": "^0.9.7",
"@types/node": "^24.10.9",
"typescript": "^5.9.3"
}
Expand Down
2 changes: 1 addition & 1 deletion rslib/react-rstest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@rsbuild/plugin-react": "^2.0.0-rc.2",
"@rslib/core": "^0.21.0",
"@rstest/adapter-rslib": "^0.2.2",
"@rstest/core": "^0.9.6",
"@rstest/core": "^0.9.7",
"@testing-library/jest-dom": "^6.9.1",
"@testing-library/react": "^16.3.2",
"@types/react": "^19.2.10",
Expand Down
2 changes: 1 addition & 1 deletion rslib/vue-rstest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@rsbuild/plugin-vue": "^1.2.7",
"@rslib/core": "^0.21.0",
"@rstest/adapter-rslib": "^0.2.2",
"@rstest/core": "^0.9.6",
"@rstest/core": "^0.9.7",
"@testing-library/jest-dom": "^6.9.1",
"@testing-library/vue": "^8.1.0",
"@vue/test-utils": "^2.4.6",
Expand Down
6 changes: 3 additions & 3 deletions rstest/browser-locator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
"@rsbuild/core": "2.0.0-rc.1",
"@rsbuild/plugin-react": "^2.0.0-rc.2",
"@rstest/adapter-rsbuild": "^0.2.5",
"@rstest/browser": "^0.9.6",
"@rstest/browser-react": "^0.9.6",
"@rstest/core": "^0.9.6",
"@rstest/browser": "^0.9.7",
"@rstest/browser-react": "^0.9.7",
"@rstest/core": "^0.9.7",
"@types/react": "^19.2.10",
"@types/react-dom": "^19.2.3",
"playwright": "^1.58.1",
Expand Down
6 changes: 3 additions & 3 deletions rstest/browser-rsbuild-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
"@rsbuild/core": "2.0.0-rc.1",
"@rsbuild/plugin-react": "^2.0.0-rc.2",
"@rstest/adapter-rsbuild": "^0.2.5",
"@rstest/browser": "^0.9.6",
"@rstest/browser-react": "^0.9.6",
"@rstest/core": "^0.9.6",
"@rstest/browser": "^0.9.7",
"@rstest/browser-react": "^0.9.7",
"@rstest/core": "^0.9.7",
"@testing-library/dom": "^10.4.1",
"@testing-library/user-event": "^14.6.1",
"@types/react": "^19.2.10",
Expand Down
4 changes: 2 additions & 2 deletions rstest/browser-rsbuild-vanilla/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
},
"devDependencies": {
"@rsbuild/core": "2.0.0-rc.1",
"@rstest/browser": "^0.9.6",
"@rstest/core": "^0.9.6",
"@rstest/browser": "^0.9.7",
"@rstest/core": "^0.9.7",
"playwright": "^1.58.1",
"typescript": "^5.9.3"
}
Expand Down
2 changes: 1 addition & 1 deletion rstest/fake-timers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"test": "rstest run"
},
"devDependencies": {
"@rstest/core": "^0.9.6",
"@rstest/core": "^0.9.7",
"typescript": "^5.9.3"
}
}
2 changes: 1 addition & 1 deletion rstest/mocking/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"test": "rstest run"
},
"devDependencies": {
"@rstest/core": "^0.9.6",
"@rstest/core": "^0.9.7",
"typescript": "^5.9.3"
}
}
2 changes: 1 addition & 1 deletion rstest/rsbuild-adapter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"devDependencies": {
"@rsbuild/core": "2.0.0-rc.1",
"@rstest/adapter-rsbuild": "^0.2.5",
"@rstest/core": "^0.9.6",
"@rstest/core": "^0.9.7",
"happy-dom": "^20.4.0",
"typescript": "^5.9.3"
}
Expand Down
21 changes: 21 additions & 0 deletions rstest/rsbuild-preact/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "@rstest-example/rsbuild-preact",
"version": "1.0.0",
"private": true,
"type": "module",
"scripts": {
"build": "rsbuild build",
"dev": "rsbuild dev",
"test": "rstest run",
"test:watch": "rstest --watch"
},
"devDependencies": {
"@rsbuild/core": "2.0.0-rc.1",
"@rsbuild/plugin-preact": "^1.7.2",
"@rstest/adapter-rsbuild": "^0.2.5",
"@rstest/core": "^0.9.7",
"happy-dom": "^20.8.3",
"preact": "^10.29.1",
"typescript": "^5.9.3"
}
}
21 changes: 21 additions & 0 deletions rstest/rsbuild-preact/rsbuild.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import path from 'node:path';
import { defineConfig } from '@rsbuild/core';
import { pluginPreact } from '@rsbuild/plugin-preact';

export default defineConfig({
plugins: [pluginPreact()],
source: {
entry: {
index: './src/index.tsx',
},
define: {
__APP_VERSION__: JSON.stringify('1.0.0'),
},
},
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
'@components': path.resolve(__dirname, 'src/components'),
},
},
});
7 changes: 7 additions & 0 deletions rstest/rsbuild-preact/rstest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { withRsbuildConfig } from '@rstest/adapter-rsbuild';
import { defineConfig } from '@rstest/core';

export default defineConfig({
extends: withRsbuildConfig(),
testEnvironment: 'happy-dom',
});
34 changes: 34 additions & 0 deletions rstest/rsbuild-preact/src/components/Counter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { useState } from 'preact/hooks';
import { getDefaultStep } from '@/utils/step';

export interface CounterProps {
initialValue?: number;
step?: number;
}

export function Counter({ initialValue = 0, step = getDefaultStep() }: CounterProps) {
const [count, setCount] = useState(initialValue);

return (
<div data-testid="counter">
<button
type="button"
onClick={() => setCount((value) => value - step)}
data-testid="decrement-btn"
>
-
</button>
<span data-testid="counter-value">{count}</span>
<button
type="button"
onClick={() => setCount((value) => value + step)}
data-testid="increment-btn"
>
+
</button>
<button type="button" onClick={() => setCount(initialValue)} data-testid="reset-btn">
Reset
</button>
</div>
);
}
8 changes: 8 additions & 0 deletions rstest/rsbuild-preact/src/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { render } from 'preact';
import { Counter } from './components/Counter';

const root =
document.getElementById('root') ?? document.body.appendChild(document.createElement('div'));
root.id = 'root';

render(<Counter initialValue={1} />, root);
3 changes: 3 additions & 0 deletions rstest/rsbuild-preact/src/utils/step.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function getDefaultStep() {
return 1;
}
35 changes: 35 additions & 0 deletions rstest/rsbuild-preact/tests/adapter.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Counter } from '@components/Counter';
import { afterEach, beforeEach, describe, expect, it } from '@rstest/core';
import { render } from 'preact';

declare const __APP_VERSION__: string;

describe('withRsbuildConfig - pluginPreact support', () => {
let container: HTMLDivElement;

beforeEach(() => {
container = document.createElement('div');
document.body.appendChild(container);
});

afterEach(() => {
render(null, container);
container.remove();
});

it('should resolve @components alias from rsbuild.config.ts', () => {
render(<Counter initialValue={5} />, container);

expect(container.querySelector('[data-testid="counter-value"]')?.textContent).toBe('5');
});

it('should resolve @/ alias from rsbuild.config.ts', async () => {
const { getDefaultStep } = await import('@/utils/step');

expect(getDefaultStep()).toBe(1);
});

it('should inherit __APP_VERSION__ from rsbuild.config.ts', () => {
expect(__APP_VERSION__).toBe('1.0.0');
});
});
35 changes: 35 additions & 0 deletions rstest/rsbuild-preact/tests/counter.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { afterEach, beforeEach, describe, expect, it } from '@rstest/core';
import { render } from 'preact';
import { Counter } from '../src/components/Counter';

describe('pluginPreact - component rendering', () => {
let container: HTMLDivElement;

beforeEach(() => {
container = document.createElement('div');
document.body.appendChild(container);
});

afterEach(() => {
render(null, container);
container.remove();
});

it('should render with initial value', () => {
render(<Counter initialValue={10} />, container);

expect(container.querySelector('[data-testid="counter-value"]')?.textContent).toBe('10');
});

it('should increment on button click', async () => {
render(<Counter />, container);

const incrementButton = container.querySelector(
'[data-testid="increment-btn"]',
) as HTMLButtonElement;
incrementButton.click();
await Promise.resolve();

expect(container.querySelector('[data-testid="counter-value"]')?.textContent).toBe('1');
});
});
19 changes: 19 additions & 0 deletions rstest/rsbuild-preact/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"target": "ES2020",
"module": "ESNext",
"moduleResolution": "bundler",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"jsx": "react-jsx",
"jsxImportSource": "preact",
"types": ["@rstest/core"],
"baseUrl": ".",
"paths": {
"@/*": ["src/*"],
"@components/*": ["src/components/*"]
}
},
"include": ["src", "tests", "rstest.config.ts", "rsbuild.config.ts"]
}
22 changes: 22 additions & 0 deletions rstest/rsbuild-solid/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "@rstest-example/rsbuild-solid",
"version": "1.0.0",
"private": true,
"type": "module",
"scripts": {
"build": "rsbuild build",
"dev": "rsbuild dev",
"test": "rstest run",
"test:watch": "rstest --watch"
},
"devDependencies": {
"@rsbuild/core": "2.0.0-rc.1",
"@rsbuild/plugin-babel": "^1.1.2",
"@rsbuild/plugin-solid": "^1.1.1",
"@rstest/adapter-rsbuild": "^0.2.5",
"@rstest/core": "^0.9.7",
"happy-dom": "^20.8.3",
"solid-js": "^1.9.12",
"typescript": "^5.9.3"
}
}
28 changes: 28 additions & 0 deletions rstest/rsbuild-solid/rsbuild.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import path from 'node:path';
import { defineConfig } from '@rsbuild/core';
import { pluginBabel } from '@rsbuild/plugin-babel';
import { pluginSolid } from '@rsbuild/plugin-solid';

export default defineConfig({
plugins: [
pluginBabel({
include: /\.(?:jsx|tsx)$/,
exclude: /[\\/]node_modules[\\/]/,
}),
pluginSolid(),
],
source: {
entry: {
index: './src/index.tsx',
},
define: {
__APP_VERSION__: JSON.stringify('1.0.0'),
},
},
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
'@components': path.resolve(__dirname, 'src/components'),
},
},
});
6 changes: 6 additions & 0 deletions rstest/rsbuild-solid/rstest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { withRsbuildConfig } from '@rstest/adapter-rsbuild';
import { defineConfig } from '@rstest/core';

export default defineConfig({
extends: withRsbuildConfig(),
});
36 changes: 36 additions & 0 deletions rstest/rsbuild-solid/src/components/Counter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { createSignal } from 'solid-js';
import { getDefaultStep } from '@/utils/step';

export interface CounterProps {
initialValue?: number;
step?: number;
}

export function Counter(props: CounterProps) {
const initialValue = props.initialValue ?? 0;
const step = props.step ?? getDefaultStep();
const [count, setCount] = createSignal(initialValue);

return (
<div data-testid="counter">
<button
type="button"
onClick={() => setCount((value) => value - step)}
data-testid="decrement-btn"
>
-
</button>
<span data-testid="counter-value">{count()}</span>
<button
type="button"
onClick={() => setCount((value) => value + step)}
data-testid="increment-btn"
>
+
</button>
<button type="button" onClick={() => setCount(initialValue)} data-testid="reset-btn">
Reset
</button>
</div>
);
}
8 changes: 8 additions & 0 deletions rstest/rsbuild-solid/src/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { render } from 'solid-js/web';
import { Counter } from './components/Counter';

const root =
document.getElementById('root') ?? document.body.appendChild(document.createElement('div'));
root.id = 'root';

render(() => <Counter initialValue={1} />, root);
Loading
Loading