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
2 changes: 1 addition & 1 deletion website/docs/en/api/rstest/_meta.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["mockModules", "mockFunctions", "mockInstance", "fakeTimers", "utilities"]
["mock-modules", "mock-functions", "mock-instance", "fake-timers", "utilities"]
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,4 @@ Reset all mocks and restore original descriptors of spied-on objects.
## More

- [Mock Matchers](../test-api/expect#mock-matchers)
- [MockInstance API](./mockInstance)
- [MockInstance API](./mock-instance)
45 changes: 22 additions & 23 deletions website/docs/en/config/test/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,39 @@
"name",
"include",
"exclude",
"setupFiles",
"setup-files",
"projects",
"update",
"globals",
"passWithNoTests",
"includeSource",
"testNamePattern",
"pass-with-no-tests",
"include-source",
"test-name-pattern",

"env",
"bail",
"retry",
"testTimeout",
"hookTimeout",
"maxConcurrency",
"test-timeout",
"hook-timeout",
"max-concurrency",

"pool",
"isolate",
"testEnvironment",

"clearMocks",
"resetMocks",
"restoreMocks",
"unstubEnvs",
"unstubGlobals",
"test-environment",
"clear-mocks",
"reset-mocks",
"restore-mocks",
"unstub-envs",
"unstub-globals",

"coverage",
"reporters",
"logHeapUsage",
"hideSkippedTests",
"slowTestThreshold",
"snapshotFormat",
"chaiConfig",
"resolveSnapshotPath",
"printConsoleTrace",
"onConsoleLog",
"disableConsoleIntercept"
"log-heap-usage",
"hide-skipped-tests",
"slow-test-threshold",
"snapshot-format",
"chai-config",
"resolve-snapshot-path",
"print-console-trace",
"on-console-log",
"disable-console-intercept"
]
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

Automatically clear mock calls, instances, contexts and results before every test.

When `clearMocks` enabled, rstest will call [.clearAllMocks()](/api/rstest/mockFunctions#rstestclearallmocks) before each test.
When `clearMocks` enabled, rstest will call [.clearAllMocks()](/api/rstest/mock-functions#rstestclearallmocks) before each test.

import { Tab, Tabs } from '@theme';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ export default defineConfig({
</Tab>
</Tabs>

It should be noted that when you disable interception of console logs, the [onConsoleLog](/config/test/onConsoleLog) and [printConsoleTrace](/config/test/printConsoleTrace) configurations will not take effect.
It should be noted that when you disable interception of console logs, the [onConsoleLog](/config/test/on-console-log) and [printConsoleTrace](/config/test/print-console-trace) configurations will not take effect.
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ export default defineConfig({
```

:::note
When [disableConsoleIntercept](/config/test/disableConsoleIntercept) is set to `true`, `onConsoleLog` will be ignored.
When [disableConsoleIntercept](/config/test/disable-console-intercept) is set to `true`, `onConsoleLog` will be ignored.
:::
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ export default defineConfig({
</Tabs>

:::note
When [disableConsoleIntercept](/config/test/disableConsoleIntercept) is set to `true`, `printConsoleTrace` will be ignored.
When [disableConsoleIntercept](/config/test/disable-console-intercept) is set to `true`, `printConsoleTrace` will be ignored.
:::
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

Automatically reset mock state before every test.

When `resetMocks` enabled, rstest will call [.resetAllMocks()](/api/rstest/mockFunctions#rstestresetallmocks) before each test.
When `resetMocks` enabled, rstest will call [.resetAllMocks()](/api/rstest/mock-functions#rstestresetallmocks) before each test.

import { Tab, Tabs } from '@theme';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

Automatically reset mock state before every test.

When `restoreMocks` enabled, rstest will call [.restoreAllMocks()](/api/rstest/mockFunctions#rstestrestoreallmocks) before each test.
When `restoreMocks` enabled, rstest will call [.restoreAllMocks()](/api/rstest/mock-functions#rstestrestoreallmocks) before each test.

import { Tab, Tabs } from '@theme';

Expand Down
28 changes: 14 additions & 14 deletions website/docs/en/guide/basic/cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -117,23 +117,23 @@ Rstest CLI provides several common options that can be used with all commands:
| `--exclude <exclude>` | Exclude files from test, see [exclude](/config/test/exclude) |
| `-u, --update` | Update snapshot files, see [update](/config/test/update) |
| `--coverage` | Enable code coverage collection, see [coverage](/config/test/coverage) |
| `--passWithNoTests` | Allows the test suite to pass when no files are found, see [passWithNoTests](/config/test/passWithNoTests) |
| `--printConsoleTrace` | Print console traces when calling any console method, see [printConsoleTrace](/config/test/printConsoleTrace) |
| `--passWithNoTests` | Allows the test suite to pass when no files are found, see [passWithNoTests](/config/test/pass-with-no-tests) |
| `--printConsoleTrace` | Print console traces when calling any console method, see [printConsoleTrace](/config/test/print-console-trace) |
| `--project <name>` | Only run tests for the specified project, see [Filter by project name](/guide/basic/test-filter#filter-by-project-name) |
| `--disableConsoleIntercept` | Disable console intercept, see [disableConsoleIntercept](/config/test/disableConsoleIntercept) |
| `--slowTestThreshold <value>` | The number of milliseconds after which a test or suite is considered slow, see [slowTestThreshold](/config/test/slowTestThreshold) |
| `-t, --testNamePattern <value>` | Run only tests with a name that matches the regex, see [testNamePattern](/config/test/testNamePattern) |
| `--testEnvironment <name>` | The environment that will be used for testing, see [testEnvironment](/config/test/testEnvironment) |
| `--testTimeout <value>` | Timeout of a test in milliseconds, see [testTimeout](/config/test/testTimeout) |
| `--hookTimeout <value>` | Timeout of hook in milliseconds, see [hookTimeout](/config/test/hookTimeout) |
| `--disableConsoleIntercept` | Disable console intercept, see [disableConsoleIntercept](/config/test/disable-console-intercept) |
| `--slowTestThreshold <value>` | The number of milliseconds after which a test or suite is considered slow, see [slowTestThreshold](/config/test/slow-test-threshold) |
| `-t, --testNamePattern <value>` | Run only tests with a name that matches the regex, see [testNamePattern](/config/test/test-name-pattern) |
| `--testEnvironment <name>` | The environment that will be used for testing, see [testEnvironment](/config/test/test-environment) |
| `--testTimeout <value>` | Timeout of a test in milliseconds, see [testTimeout](/config/test/test-timeout) |
| `--hookTimeout <value>` | Timeout of hook in milliseconds, see [hookTimeout](/config/test/hook-timeout) |
| `--retry <retry>` | Number of times to retry a test if it fails, see [retry](/config/test/retry) |
| `--bail <number>` | Abort the test run after the specified number of test failures, see [bail](/config/test/bail) |
| `--maxConcurrency <value>` | Maximum number of concurrent tests, see [maxConcurrency](/config/test/maxConcurrency) |
| `--clearMocks` | Automatically clear mock calls, instances, contexts and results before every test, see [clearMocks](/config/test/clearMocks) |
| `--resetMocks` | Automatically reset mock state before every test, see [resetMocks](/config/test/resetMocks) |
| `--restoreMocks` | Automatically restore mock state and implementation before every test, see [restoreMocks](/config/test/restoreMocks) |
| `--unstubGlobals` | Restores all global variables that were changed with `rstest.stubGlobal` before every test, see [unstubGlobals](/config/test/unstubGlobals) |
| `--unstubEnvs` | Restores all `process.env` values that were changed with `rstest.stubEnv` before every test, see [unstubEnvs](/config/test/unstubEnvs) |
| `--maxConcurrency <value>` | Maximum number of concurrent tests, see [maxConcurrency](/config/test/max-concurrency) |
| `--clearMocks` | Automatically clear mock calls, instances, contexts and results before every test, see [clearMocks](/config/test/clear-mocks) |
| `--resetMocks` | Automatically reset mock state before every test, see [resetMocks](/config/test/reset-mocks) |
| `--restoreMocks` | Automatically restore mock state and implementation before every test, see [restoreMocks](/config/test/restore-mocks) |
| `--unstubGlobals` | Restores all global variables that were changed with `rstest.stubGlobal` before every test, see [unstubGlobals](/config/test/unstub-globals) |
| `--unstubEnvs` | Restores all `process.env` values that were changed with `rstest.stubEnv` before every test, see [unstubEnvs](/config/test/unstub-envs) |
| `-h, --help` | Display help for command |
| `-v, --version` | Display version |

Expand Down
2 changes: 1 addition & 1 deletion website/docs/en/guide/basic/test-filter.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ rstest --include test/a/*.test.ts --include test/b/*.test.ts

## Filter by test name

If you only want to run test cases whose names contain a specific keyword, you can use [testNamePattern](/config/test/testNamePattern).
If you only want to run test cases whose names contain a specific keyword, you can use [testNamePattern](/config/test/test-name-pattern).

For example, to only run test cases whose names contain "login":

Expand Down
2 changes: 1 addition & 1 deletion website/docs/en/guide/migration/jest.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Here are some common Jest configurations and their Rstest equivalents:
| `transformIgnorePatterns` | [`output.externals`](/config/build/output#outputexternals)、[`source.exclude`](/config/build/source#sourceexclude) |
| `displayName` | [`name`](/config/test/name) |
| `rootDir` | [`root`](/config/test/root) |
| `setupFilesAfterEnv` | [`setupFiles`](/config/test/setupFiles) |
| `setupFilesAfterEnv` | [`setupFiles`](/config/test/setup-files) |
| `verbose` | [`verbose-reporter`](/config/test/reporters#verbose-reporter) |
| `injectGlobals` | [`globals`](/config/test/globals) |
| `moduleNameMapper` | [`resolve.alias`](/config/build/resolve#resolvealias) |
Expand Down
4 changes: 2 additions & 2 deletions website/docs/en/guide/start/features.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Learn more about [Projects](/config/test/projects).

Rstest supports a Rust-like module testing style, allowing you to write test blocks directly inside source files. This approach is ideal for small utility functions and helpers, enabling quick verification and debugging.

Learn more about [In-source tests](/config/test/includeSource).
Learn more about [In-source tests](/config/test/include-source).

## Watch mode

Expand All @@ -32,7 +32,7 @@ When you modify a test file or one of its dependencies, Rstest analyzes the modu

Rstest supports simulating the DOM and browser APIs using jsdom and happy-dom. It provides solid support for frameworks such as React and Vue, and is compatible with Testing Library and CSS Modules.

Learn more about [DOM testing](/config/test/testEnvironment#dom-testing).
Learn more about [DOM testing](/config/test/test-environment#dom-testing).

## Code coverage

Expand Down
2 changes: 1 addition & 1 deletion website/docs/en/guide/start/quick-start.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Rstest has built-in commands such as `watch` and `run`, please refer to [CLI Too

## Writing tests

As a simple example, we have a `sayHi` method. To test it, you can create a test file called `index.test.ts` or use [In-Source test](/config/test/includeSource) similar to [Rust Test](https://doc.rust-lang.org/book/ch11-03-test-organization.html#the-tests-module-and-cfgtest).
As a simple example, we have a `sayHi` method. To test it, you can create a test file called `index.test.ts` or use [In-Source test](/config/test/include-source) similar to [Rust Test](https://doc.rust-lang.org/book/ch11-03-test-organization.html#the-tests-module-and-cfgtest).

```ts title=index.ts
export const sayHi = () => 'hi';
Expand Down
2 changes: 1 addition & 1 deletion website/docs/zh/api/rstest/_meta.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["mockModules", "mockFunctions", "mockInstance", "fakeTimers", "utilities"]
["mock-modules", "mock-functions", "mock-instance", "fake-timers", "utilities"]
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,4 @@ expect(spy).toHaveBeenCalled();
## 更多

- [Mock 匹配器](../test-api/expect#mock-matchers)
- [MockInstance API](./mockInstance)
- [MockInstance API](./mock-instance)
45 changes: 22 additions & 23 deletions website/docs/zh/config/test/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,39 @@
"name",
"include",
"exclude",
"setupFiles",
"setup-files",
"projects",
"update",
"globals",
"passWithNoTests",
"includeSource",
"testNamePattern",
"pass-with-no-tests",
"include-source",
"test-name-pattern",

"env",
"bail",
"retry",
"testTimeout",
"hookTimeout",
"maxConcurrency",
"test-timeout",
"hook-timeout",
"max-concurrency",

"pool",
"isolate",
"testEnvironment",

"clearMocks",
"resetMocks",
"restoreMocks",
"unstubEnvs",
"unstubGlobals",
"test-environment",
"clear-mocks",
"reset-mocks",
"restore-mocks",
"unstub-envs",
"unstub-globals",

"coverage",
"reporters",
"logHeapUsage",
"hideSkippedTests",
"slowTestThreshold",
"snapshotFormat",
"chaiConfig",
"resolveSnapshotPath",
"printConsoleTrace",
"onConsoleLog",
"disableConsoleIntercept"
"log-heap-usage",
"hide-skipped-tests",
"slow-test-threshold",
"snapshot-format",
"chai-config",
"resolve-snapshot-path",
"print-console-trace",
"on-console-log",
"disable-console-intercept"
]
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

清除所有 mock 的 `mock.calls`、`mock.instances`、`mock.contexts` 和 `mock.results` 属性。

当启用 `clearMocks` 时,rstest 将在每个测试用例执行之前调用 [.clearAllMocks()](/api/rstest/mockFunctions#rstestclearallmocks)。
当启用 `clearMocks` 时,rstest 将在每个测试用例执行之前调用 [.clearAllMocks()](/api/rstest/mock-functions#rstestclearallmocks)。

import { Tab, Tabs } from '@theme';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ export default defineConfig({
</Tab>
</Tabs>

如果你不想要 Rstest 对 console 日志做拦截,你可以将此配置设为 `true`。需要注意的是,当你禁用 console 日志的拦截时,[onConsoleLog](/config/test/onConsoleLog) 和 [printConsoleTrace](/config/test/printConsoleTrace) 配置将不会生效。
如果你不想要 Rstest 对 console 日志做拦截,你可以将此配置设为 `true`。需要注意的是,当你禁用 console 日志的拦截时,[onConsoleLog](/config/test/on-console-log) 和 [printConsoleTrace](/config/test/print-console-trace) 配置将不会生效。
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ export default defineConfig({
```

:::note
当 [disableConsoleIntercept](/config/test/disableConsoleIntercept) 为 `true` 时,`onConsoleLog` 将被忽略。
当 [disableConsoleIntercept](/config/test/disable-console-intercept) 为 `true` 时,`onConsoleLog` 将被忽略。
:::
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ export default defineConfig({
</Tabs>

:::note
当 [disableConsoleIntercept](/config/test/disableConsoleIntercept) 为 `true` 时,`printConsoleTrace` 将被忽略。
当 [disableConsoleIntercept](/config/test/disable-console-intercept) 为 `true` 时,`printConsoleTrace` 将被忽略。
:::
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

清除所有 mock 属性,并将每个 mock 的实现重置为其原始实现。

当启用 `resetMocks` 时,rstest 将在每个测试用例执行之前调用 [.resetAllMocks()](/api/rstest/mockFunctions#rstestresetallmocks)。
当启用 `resetMocks` 时,rstest 将在每个测试用例执行之前调用 [.resetAllMocks()](/api/rstest/mock-functions#rstestresetallmocks)。

import { Tab, Tabs } from '@theme';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

重置所有 mock,并恢复被 mock 的对象的原始描述符。

当启用 `restoreMocks` 时,rstest 将在每个测试用例执行之前调用 [.restoreAllMocks()](/api/rstest/mockFunctions#rstestrestoreallmocks)。
当启用 `restoreMocks` 时,rstest 将在每个测试用例执行之前调用 [.restoreAllMocks()](/api/rstest/mock-functions#rstestrestoreallmocks)。

import { Tab, Tabs } from '@theme';

Expand Down
Loading
Loading