Skip to content
Draft
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
2 changes: 1 addition & 1 deletion .github/workflows/test-Windows.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test (vitest & playwright - Windows)
name: Test (Windows)

concurrency:
group: windows-test-${{ github.head_ref }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-macOS.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test (vitest & playwright - macOS)
name: Test (macOS)

concurrency:
group: macos-test-${{ github.head_ref }}
Expand Down
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

## Testing guidelines

- Unit: `vitest`; E2E: `@playwright/test`.
- Unit: `rstest`; E2E: `@playwright/test`.
- Naming: `*.test.ts`/`*.test.tsx`; snapshots in `__snapshots__/`.
- Placement: unit under `packages/*/tests`; e2e under `e2e/`.

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"preview:website": "cd website && npm run preview",
"test": "pnpm test:unit && pnpm test:e2e",
"test:e2e": "playwright test",
"test:unit": "vitest run",
"test:unit": "rstest run",
"update:rsbuild": "npx taze minor --include /rsbuild/ -w -r -l"
},
"lint-staged": {
Expand All @@ -35,6 +35,7 @@
"@changesets/cli": "^2.29.7",
"@playwright/test": "1.56.1",
"@rspress/config": "workspace:*",
"@rstest/core": "https://pkg.pr.new/web-infra-dev/rstest/@rstest/core@375186a",
"@types/cross-spawn": "^6.0.6",
"@types/node": "^22.8.1",
"check-dependency-version-consistency": "^5.0.1",
Expand All @@ -52,7 +53,6 @@
"prettier": "3.6.2",
"prettier-plugin-packagejson": "^2.5.19",
"tree-kill": "^1.2.2",
"vitest": "2.1.9",
"zx": "^8.8.5"
},
"packageManager": "[email protected]",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/node/auto-nav-sidebar/locales.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from 'node:path';
import { describe, expect, it } from 'vitest';
import { describe, expect, it } from '@rstest/core';
import {
getRoutePathParts,
normalizeRoutePath,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/node/auto-nav-sidebar/walk.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from 'node:path';
import { DEFAULT_PAGE_EXTENSIONS } from '@rspress/shared/constants';
import { describe, expect, it } from 'vitest';
import { describe, expect, it } from '@rstest/core';
import {
getRoutePathParts,
normalizeRoutePath,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
// Rstest Snapshot v1

exports[`rehypeHeadAnchor > basic 1`] = `
"/*prettier-ignore-start*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, expect, it } from 'vitest';
import { describe, expect, it } from '@rstest/core';
import { compile } from '../processor';

describe('rehypeHeadAnchor', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
// Rstest Snapshot v1

exports[`remark-container > Has space before ::: 1`] = `
"import {jsx as _jsx} from "react/jsx-runtime";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
// Rstest Snapshot v1

exports[`remarkFileCodeBlock > basic 1`] = `
"import {Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs} from "react/jsx-runtime";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
// Rstest Snapshot v1

exports[`mdx > basic 1`] = `
"import {Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs} from "react/jsx-runtime";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
// Rstest Snapshot v1

exports[`mdx > basic 1`] = `
"/*jsx link will not be transformed*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, expect, test } from 'vitest';
import { describe, expect, test } from '@rstest/core';
import { compile } from '../processor';

describe('remark-container', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { describe, expect, it, rs } from '@rstest/core';
import { fs, vol } from 'memfs';

import { describe, expect, it, vi } from 'vitest';
import { compile } from '../processor';

vi.mock('node:fs/promises', () => {
rs.mock('node:fs/promises', () => {
return { readFile: fs.promises.readFile };
});

Expand All @@ -25,7 +24,7 @@ describe('remarkFileCodeBlock', () => {
filepath: '/usr/rspress-project/docs/index.mdx',
config: null,
pluginDriver: null,
routeService: null,
routeSerrsce: null,
});
expect(result).toMatchSnapshot();
});
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/node/mdx/remarkPlugins/image.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, expect, it } from 'vitest';
import { describe, expect, it } from '@rstest/core';
import { compile } from '../processor';

describe('mdx', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/node/mdx/remarkPlugins/link.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, expect, it } from 'vitest';
import { describe, expect, it } from '@rstest/core';
import { compile } from '../processor';

describe('mdx', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/node/route/RouteService.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from 'node:path';
import type { UserConfig } from '@rspress/shared';
import { describe, expect, it } from 'vitest';
import { describe, expect, it } from '@rstest/core';
import { RouteService } from './RouteService';

const BASIC_DIR = path.join(__dirname, 'fixtures', 'basic');
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/node/route/extractPageData.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { join } from 'node:path';
import { describe, expect, it } from 'vitest';
import { describe, expect, it } from '@rstest/core';
import { extractPageData, getPageIndexInfoByRoute } from './extractPageData';
import type { RouteService } from './RouteService';

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/node/route/normalizeRoutePath.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, test } from 'vitest';
import { expect, test } from '@rstest/core';
import { getRoutePathParts, normalizeRoutePath } from './normalizeRoutePath';

test('getRoutePathParts', () => {
Expand Down
16 changes: 8 additions & 8 deletions packages/core/src/node/utils/checkLanguageParity.test.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import type { UserConfig } from '@rspress/shared';
import { logger } from '@rspress/shared/logger';
import { beforeEach, describe, expect, it, rs } from '@rstest/core';
import { fs, vol } from 'memfs';
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { checkLanguageParity } from './checkLanguageParity';

vi.mock('node:fs/promises', () => {
rs.mock('node:fs/promises', () => {
return { default: fs.promises };
});
vi.mock('@rspress/shared/logger', () => ({
rs.mock('@rspress/shared/logger', () => ({
logger: {
info: vi.fn(),
warn: vi.fn(),
error: vi.fn(),
success: vi.fn(),
info: rs.fn(),
warn: rs.fn(),
error: rs.fn(),
success: rs.fn(),
},
}));

describe('checkLanguageParity', () => {
beforeEach(() => {
vol.reset();
vi.clearAllMocks();
rs.clearAllMocks();
});

// base config
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/node/utils/flattenMdxContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export async function flattenMdxContent(
let result = content;

try {
ast = processor.parse(content);
ast = processor.parse(content) as Root;
} catch (e) {
// Fallback: if mdx parse failed, just return the content
logger.debug('flattenMdxContent parse failed: \n', e);
Expand Down
14 changes: 7 additions & 7 deletions packages/core/tests/cli/hint.test.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { logger } from '@rspress/shared/logger';
import { describe, expect, it, rs } from '@rstest/core';
import { fs, vol } from 'memfs';
import { describe, expect, it, vi } from 'vitest';
import { hintThemeBreakingChange } from '../../src/node/logger/hint';

vi.mock('node:fs/promises', () => {
rs.mock('node:fs/promises', () => {
return { default: fs.promises, ...fs.promises };
});
vi.mock('@rspress/shared/logger', () => ({
rs.mock('@rspress/shared/logger', () => ({
logger: {
info: vi.fn(),
warn: vi.fn(),
error: vi.fn(),
success: vi.fn(),
info: rs.fn(),
warn: rs.fn(),
error: rs.fn(),
success: rs.fn(),
},
}));

Expand Down
2 changes: 1 addition & 1 deletion packages/core/tests/config/config-basic.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from 'node:path';
import { describe, expect, test } from 'vitest';
import { describe, expect, test } from '@rstest/core';
import { loadConfigFile } from '../../src/cli/config/loadConfigFile';
import { normalizePath } from '../../src/node/utils/normalizePath';

Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-algolia/tests/locales.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, expect, test } from 'vitest';
import { describe, expect, test } from '@rstest/core';
import { ZH_LOCALES } from '../src/runtime/locales';

describe('Docsearch v4 Locales', () => {
Expand Down
8 changes: 4 additions & 4 deletions packages/runtime/src/getSidebarDataGroup.test.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { describe, expect, it, vi } from 'vitest';
import { describe, expect, it, rs } from '@rstest/core';
import { getSidebarDataGroup } from './hooks/useSidebar';
import { isActive } from './route';

vi.mock('virtual-i18n-text', () => {
rs.mock('virtual-i18n-text', () => {
return { default: {} };
});

vi.mock('virtual-site-data', () => {
rs.mock('virtual-site-data', () => {
return {
default: {
base: '/',
},
};
});

vi.mock('virtual-routes', () => {
rs.mock('virtual-routes', () => {
return { routes: [] };
});

Expand Down
6 changes: 3 additions & 3 deletions packages/runtime/src/route.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { describe, expect, it, vi } from 'vitest';
import { describe, expect, it, rs } from '@rstest/core';
import { isActive, matchPath, pathnameToRouteService } from './route';

vi.mock('virtual-routes', () => {
const element = vi.fn();
rs.mock('virtual-routes', () => {
const element = rs.fn();
const routes = [
{
path: '/api/config',
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/runtime-utils/utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, expect, test } from 'vitest';
import { describe, expect, test } from '@rstest/core';
import {
normalizeHref,
normalizePosixPath,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Header } from '@rspress/shared';
import { describe, expect, test } from 'vitest';
import { describe, expect, test } from '@rstest/core';
import { backTrackHeaders } from './util';

describe('utils logic', () => {
Expand Down
Loading
Loading