diff --git a/website/docs/en/api/rstest/_meta.json b/website/docs/en/api/rstest/_meta.json index 98ce8f024..0f762af80 100644 --- a/website/docs/en/api/rstest/_meta.json +++ b/website/docs/en/api/rstest/_meta.json @@ -1 +1 @@ -["mockModules", "mockFunctions", "mockInstance", "fakeTimers", "utilities"] +["mock-modules", "mock-functions", "mock-instance", "fake-timers", "utilities"] diff --git a/website/docs/en/api/rstest/fakeTimers.mdx b/website/docs/en/api/rstest/fake-timers.mdx similarity index 100% rename from website/docs/en/api/rstest/fakeTimers.mdx rename to website/docs/en/api/rstest/fake-timers.mdx diff --git a/website/docs/en/api/rstest/mockFunctions.mdx b/website/docs/en/api/rstest/mock-functions.mdx similarity index 97% rename from website/docs/en/api/rstest/mockFunctions.mdx rename to website/docs/en/api/rstest/mock-functions.mdx index 3189d0de8..ee1f2bb6a 100644 --- a/website/docs/en/api/rstest/mockFunctions.mdx +++ b/website/docs/en/api/rstest/mock-functions.mdx @@ -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) diff --git a/website/docs/en/api/rstest/mockInstance.mdx b/website/docs/en/api/rstest/mock-instance.mdx similarity index 100% rename from website/docs/en/api/rstest/mockInstance.mdx rename to website/docs/en/api/rstest/mock-instance.mdx diff --git a/website/docs/en/api/rstest/mockModules.mdx b/website/docs/en/api/rstest/mock-modules.mdx similarity index 100% rename from website/docs/en/api/rstest/mockModules.mdx rename to website/docs/en/api/rstest/mock-modules.mdx diff --git a/website/docs/en/config/test/_meta.json b/website/docs/en/config/test/_meta.json index ff1541c31..6bb3a9a45 100644 --- a/website/docs/en/config/test/_meta.json +++ b/website/docs/en/config/test/_meta.json @@ -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" ] diff --git a/website/docs/en/config/test/chaiConfig.mdx b/website/docs/en/config/test/chai-config.mdx similarity index 100% rename from website/docs/en/config/test/chaiConfig.mdx rename to website/docs/en/config/test/chai-config.mdx diff --git a/website/docs/en/config/test/clearMocks.mdx b/website/docs/en/config/test/clear-mocks.mdx similarity index 89% rename from website/docs/en/config/test/clearMocks.mdx rename to website/docs/en/config/test/clear-mocks.mdx index 7102f7340..b5bb527b8 100644 --- a/website/docs/en/config/test/clearMocks.mdx +++ b/website/docs/en/config/test/clear-mocks.mdx @@ -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'; diff --git a/website/docs/en/config/test/disableConsoleIntercept.mdx b/website/docs/en/config/test/disable-console-intercept.mdx similarity index 82% rename from website/docs/en/config/test/disableConsoleIntercept.mdx rename to website/docs/en/config/test/disable-console-intercept.mdx index 390e9558f..388124090 100644 --- a/website/docs/en/config/test/disableConsoleIntercept.mdx +++ b/website/docs/en/config/test/disable-console-intercept.mdx @@ -27,4 +27,4 @@ export default defineConfig({ -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. diff --git a/website/docs/en/config/test/hideSkippedTests.mdx b/website/docs/en/config/test/hide-skipped-tests.mdx similarity index 100% rename from website/docs/en/config/test/hideSkippedTests.mdx rename to website/docs/en/config/test/hide-skipped-tests.mdx diff --git a/website/docs/en/config/test/hookTimeout.mdx b/website/docs/en/config/test/hook-timeout.mdx similarity index 100% rename from website/docs/en/config/test/hookTimeout.mdx rename to website/docs/en/config/test/hook-timeout.mdx diff --git a/website/docs/en/config/test/includeSource.mdx b/website/docs/en/config/test/include-source.mdx similarity index 100% rename from website/docs/en/config/test/includeSource.mdx rename to website/docs/en/config/test/include-source.mdx diff --git a/website/docs/en/config/test/logHeapUsage.mdx b/website/docs/en/config/test/log-heap-usage.mdx similarity index 100% rename from website/docs/en/config/test/logHeapUsage.mdx rename to website/docs/en/config/test/log-heap-usage.mdx diff --git a/website/docs/en/config/test/maxConcurrency.mdx b/website/docs/en/config/test/max-concurrency.mdx similarity index 100% rename from website/docs/en/config/test/maxConcurrency.mdx rename to website/docs/en/config/test/max-concurrency.mdx diff --git a/website/docs/en/config/test/onConsoleLog.mdx b/website/docs/en/config/test/on-console-log.mdx similarity index 78% rename from website/docs/en/config/test/onConsoleLog.mdx rename to website/docs/en/config/test/on-console-log.mdx index 8af777a54..8fa6baf22 100644 --- a/website/docs/en/config/test/onConsoleLog.mdx +++ b/website/docs/en/config/test/on-console-log.mdx @@ -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. ::: diff --git a/website/docs/en/config/test/passWithNoTests.mdx b/website/docs/en/config/test/pass-with-no-tests.mdx similarity index 100% rename from website/docs/en/config/test/passWithNoTests.mdx rename to website/docs/en/config/test/pass-with-no-tests.mdx diff --git a/website/docs/en/config/test/printConsoleTrace.mdx b/website/docs/en/config/test/print-console-trace.mdx similarity index 80% rename from website/docs/en/config/test/printConsoleTrace.mdx rename to website/docs/en/config/test/print-console-trace.mdx index 33db46d99..cb09f762b 100644 --- a/website/docs/en/config/test/printConsoleTrace.mdx +++ b/website/docs/en/config/test/print-console-trace.mdx @@ -26,5 +26,5 @@ export default defineConfig({ :::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. ::: diff --git a/website/docs/en/config/test/resetMocks.mdx b/website/docs/en/config/test/reset-mocks.mdx similarity index 88% rename from website/docs/en/config/test/resetMocks.mdx rename to website/docs/en/config/test/reset-mocks.mdx index 719999114..02eea0d02 100644 --- a/website/docs/en/config/test/resetMocks.mdx +++ b/website/docs/en/config/test/reset-mocks.mdx @@ -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'; diff --git a/website/docs/en/config/test/resolveSnapshotPath.mdx b/website/docs/en/config/test/resolve-snapshot-path.mdx similarity index 100% rename from website/docs/en/config/test/resolveSnapshotPath.mdx rename to website/docs/en/config/test/resolve-snapshot-path.mdx diff --git a/website/docs/en/config/test/restoreMocks.mdx b/website/docs/en/config/test/restore-mocks.mdx similarity index 87% rename from website/docs/en/config/test/restoreMocks.mdx rename to website/docs/en/config/test/restore-mocks.mdx index 48148776a..4e60062f8 100644 --- a/website/docs/en/config/test/restoreMocks.mdx +++ b/website/docs/en/config/test/restore-mocks.mdx @@ -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'; diff --git a/website/docs/en/config/test/setupFiles.mdx b/website/docs/en/config/test/setup-files.mdx similarity index 100% rename from website/docs/en/config/test/setupFiles.mdx rename to website/docs/en/config/test/setup-files.mdx diff --git a/website/docs/en/config/test/slowTestThreshold.mdx b/website/docs/en/config/test/slow-test-threshold.mdx similarity index 100% rename from website/docs/en/config/test/slowTestThreshold.mdx rename to website/docs/en/config/test/slow-test-threshold.mdx diff --git a/website/docs/en/config/test/snapshotFormat.mdx b/website/docs/en/config/test/snapshot-format.mdx similarity index 100% rename from website/docs/en/config/test/snapshotFormat.mdx rename to website/docs/en/config/test/snapshot-format.mdx diff --git a/website/docs/en/config/test/testEnvironment.mdx b/website/docs/en/config/test/test-environment.mdx similarity index 100% rename from website/docs/en/config/test/testEnvironment.mdx rename to website/docs/en/config/test/test-environment.mdx diff --git a/website/docs/en/config/test/testNamePattern.mdx b/website/docs/en/config/test/test-name-pattern.mdx similarity index 100% rename from website/docs/en/config/test/testNamePattern.mdx rename to website/docs/en/config/test/test-name-pattern.mdx diff --git a/website/docs/en/config/test/testTimeout.mdx b/website/docs/en/config/test/test-timeout.mdx similarity index 100% rename from website/docs/en/config/test/testTimeout.mdx rename to website/docs/en/config/test/test-timeout.mdx diff --git a/website/docs/en/config/test/unstubEnvs.mdx b/website/docs/en/config/test/unstub-envs.mdx similarity index 100% rename from website/docs/en/config/test/unstubEnvs.mdx rename to website/docs/en/config/test/unstub-envs.mdx diff --git a/website/docs/en/config/test/unstubGlobals.mdx b/website/docs/en/config/test/unstub-globals.mdx similarity index 100% rename from website/docs/en/config/test/unstubGlobals.mdx rename to website/docs/en/config/test/unstub-globals.mdx diff --git a/website/docs/en/guide/basic/cli.mdx b/website/docs/en/guide/basic/cli.mdx index e0aa04237..1a5a72310 100644 --- a/website/docs/en/guide/basic/cli.mdx +++ b/website/docs/en/guide/basic/cli.mdx @@ -117,23 +117,23 @@ Rstest CLI provides several common options that can be used with all commands: | `--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 ` | 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 ` | The number of milliseconds after which a test or suite is considered slow, see [slowTestThreshold](/config/test/slowTestThreshold) | -| `-t, --testNamePattern ` | Run only tests with a name that matches the regex, see [testNamePattern](/config/test/testNamePattern) | -| `--testEnvironment ` | The environment that will be used for testing, see [testEnvironment](/config/test/testEnvironment) | -| `--testTimeout ` | Timeout of a test in milliseconds, see [testTimeout](/config/test/testTimeout) | -| `--hookTimeout ` | Timeout of hook in milliseconds, see [hookTimeout](/config/test/hookTimeout) | +| `--disableConsoleIntercept` | Disable console intercept, see [disableConsoleIntercept](/config/test/disable-console-intercept) | +| `--slowTestThreshold ` | The number of milliseconds after which a test or suite is considered slow, see [slowTestThreshold](/config/test/slow-test-threshold) | +| `-t, --testNamePattern ` | Run only tests with a name that matches the regex, see [testNamePattern](/config/test/test-name-pattern) | +| `--testEnvironment ` | The environment that will be used for testing, see [testEnvironment](/config/test/test-environment) | +| `--testTimeout ` | Timeout of a test in milliseconds, see [testTimeout](/config/test/test-timeout) | +| `--hookTimeout ` | Timeout of hook in milliseconds, see [hookTimeout](/config/test/hook-timeout) | | `--retry ` | Number of times to retry a test if it fails, see [retry](/config/test/retry) | | `--bail ` | Abort the test run after the specified number of test failures, see [bail](/config/test/bail) | -| `--maxConcurrency ` | 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 ` | 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 | diff --git a/website/docs/en/guide/basic/test-filter.mdx b/website/docs/en/guide/basic/test-filter.mdx index 74848624a..a54ec8827 100644 --- a/website/docs/en/guide/basic/test-filter.mdx +++ b/website/docs/en/guide/basic/test-filter.mdx @@ -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": diff --git a/website/docs/en/guide/migration/jest.mdx b/website/docs/en/guide/migration/jest.mdx index e2bffb1c9..15146677c 100644 --- a/website/docs/en/guide/migration/jest.mdx +++ b/website/docs/en/guide/migration/jest.mdx @@ -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) | diff --git a/website/docs/en/guide/start/features.mdx b/website/docs/en/guide/start/features.mdx index f8da44fd2..7c687051c 100644 --- a/website/docs/en/guide/start/features.mdx +++ b/website/docs/en/guide/start/features.mdx @@ -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 @@ -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 diff --git a/website/docs/en/guide/start/quick-start.mdx b/website/docs/en/guide/start/quick-start.mdx index cb5422c05..da10064ff 100644 --- a/website/docs/en/guide/start/quick-start.mdx +++ b/website/docs/en/guide/start/quick-start.mdx @@ -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'; diff --git a/website/docs/zh/api/rstest/_meta.json b/website/docs/zh/api/rstest/_meta.json index 98ce8f024..0f762af80 100644 --- a/website/docs/zh/api/rstest/_meta.json +++ b/website/docs/zh/api/rstest/_meta.json @@ -1 +1 @@ -["mockModules", "mockFunctions", "mockInstance", "fakeTimers", "utilities"] +["mock-modules", "mock-functions", "mock-instance", "fake-timers", "utilities"] diff --git a/website/docs/zh/api/rstest/fakeTimers.mdx b/website/docs/zh/api/rstest/fake-timers.mdx similarity index 100% rename from website/docs/zh/api/rstest/fakeTimers.mdx rename to website/docs/zh/api/rstest/fake-timers.mdx diff --git a/website/docs/zh/api/rstest/mockFunctions.mdx b/website/docs/zh/api/rstest/mock-functions.mdx similarity index 97% rename from website/docs/zh/api/rstest/mockFunctions.mdx rename to website/docs/zh/api/rstest/mock-functions.mdx index f8f8df815..8cb7885ff 100644 --- a/website/docs/zh/api/rstest/mockFunctions.mdx +++ b/website/docs/zh/api/rstest/mock-functions.mdx @@ -90,4 +90,4 @@ expect(spy).toHaveBeenCalled(); ## 更多 - [Mock 匹配器](../test-api/expect#mock-matchers) -- [MockInstance API](./mockInstance) +- [MockInstance API](./mock-instance) diff --git a/website/docs/zh/api/rstest/mockInstance.mdx b/website/docs/zh/api/rstest/mock-instance.mdx similarity index 100% rename from website/docs/zh/api/rstest/mockInstance.mdx rename to website/docs/zh/api/rstest/mock-instance.mdx diff --git a/website/docs/zh/api/rstest/mockModules.mdx b/website/docs/zh/api/rstest/mock-modules.mdx similarity index 100% rename from website/docs/zh/api/rstest/mockModules.mdx rename to website/docs/zh/api/rstest/mock-modules.mdx diff --git a/website/docs/zh/config/test/_meta.json b/website/docs/zh/config/test/_meta.json index ff1541c31..6bb3a9a45 100644 --- a/website/docs/zh/config/test/_meta.json +++ b/website/docs/zh/config/test/_meta.json @@ -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" ] diff --git a/website/docs/zh/config/test/chaiConfig.mdx b/website/docs/zh/config/test/chai-config.mdx similarity index 100% rename from website/docs/zh/config/test/chaiConfig.mdx rename to website/docs/zh/config/test/chai-config.mdx diff --git a/website/docs/zh/config/test/clearMocks.mdx b/website/docs/zh/config/test/clear-mocks.mdx similarity index 87% rename from website/docs/zh/config/test/clearMocks.mdx rename to website/docs/zh/config/test/clear-mocks.mdx index df705436a..a52055d12 100644 --- a/website/docs/zh/config/test/clearMocks.mdx +++ b/website/docs/zh/config/test/clear-mocks.mdx @@ -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'; diff --git a/website/docs/zh/config/test/disableConsoleIntercept.mdx b/website/docs/zh/config/test/disable-console-intercept.mdx similarity index 82% rename from website/docs/zh/config/test/disableConsoleIntercept.mdx rename to website/docs/zh/config/test/disable-console-intercept.mdx index 481a2afee..c8b3d6500 100644 --- a/website/docs/zh/config/test/disableConsoleIntercept.mdx +++ b/website/docs/zh/config/test/disable-console-intercept.mdx @@ -25,4 +25,4 @@ export default defineConfig({ -如果你不想要 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) 配置将不会生效。 diff --git a/website/docs/zh/config/test/hideSkippedTests.mdx b/website/docs/zh/config/test/hide-skipped-tests.mdx similarity index 100% rename from website/docs/zh/config/test/hideSkippedTests.mdx rename to website/docs/zh/config/test/hide-skipped-tests.mdx diff --git a/website/docs/zh/config/test/hookTimeout.mdx b/website/docs/zh/config/test/hook-timeout.mdx similarity index 100% rename from website/docs/zh/config/test/hookTimeout.mdx rename to website/docs/zh/config/test/hook-timeout.mdx diff --git a/website/docs/zh/config/test/includeSource.mdx b/website/docs/zh/config/test/include-source.mdx similarity index 100% rename from website/docs/zh/config/test/includeSource.mdx rename to website/docs/zh/config/test/include-source.mdx diff --git a/website/docs/zh/config/test/logHeapUsage.mdx b/website/docs/zh/config/test/log-heap-usage.mdx similarity index 100% rename from website/docs/zh/config/test/logHeapUsage.mdx rename to website/docs/zh/config/test/log-heap-usage.mdx diff --git a/website/docs/zh/config/test/maxConcurrency.mdx b/website/docs/zh/config/test/max-concurrency.mdx similarity index 100% rename from website/docs/zh/config/test/maxConcurrency.mdx rename to website/docs/zh/config/test/max-concurrency.mdx diff --git a/website/docs/zh/config/test/onConsoleLog.mdx b/website/docs/zh/config/test/on-console-log.mdx similarity index 78% rename from website/docs/zh/config/test/onConsoleLog.mdx rename to website/docs/zh/config/test/on-console-log.mdx index c95d6538c..e8dce4f1a 100644 --- a/website/docs/zh/config/test/onConsoleLog.mdx +++ b/website/docs/zh/config/test/on-console-log.mdx @@ -16,5 +16,5 @@ export default defineConfig({ ``` :::note -当 [disableConsoleIntercept](/config/test/disableConsoleIntercept) 为 `true` 时,`onConsoleLog` 将被忽略。 +当 [disableConsoleIntercept](/config/test/disable-console-intercept) 为 `true` 时,`onConsoleLog` 将被忽略。 ::: diff --git a/website/docs/zh/config/test/passWithNoTests.mdx b/website/docs/zh/config/test/pass-with-no-tests.mdx similarity index 100% rename from website/docs/zh/config/test/passWithNoTests.mdx rename to website/docs/zh/config/test/pass-with-no-tests.mdx diff --git a/website/docs/zh/config/test/printConsoleTrace.mdx b/website/docs/zh/config/test/print-console-trace.mdx similarity index 80% rename from website/docs/zh/config/test/printConsoleTrace.mdx rename to website/docs/zh/config/test/print-console-trace.mdx index e3afdfe10..3a7f2a990 100644 --- a/website/docs/zh/config/test/printConsoleTrace.mdx +++ b/website/docs/zh/config/test/print-console-trace.mdx @@ -26,5 +26,5 @@ export default defineConfig({ :::note -当 [disableConsoleIntercept](/config/test/disableConsoleIntercept) 为 `true` 时,`printConsoleTrace` 将被忽略。 +当 [disableConsoleIntercept](/config/test/disable-console-intercept) 为 `true` 时,`printConsoleTrace` 将被忽略。 ::: diff --git a/website/docs/zh/config/test/resetMocks.mdx b/website/docs/zh/config/test/reset-mocks.mdx similarity index 86% rename from website/docs/zh/config/test/resetMocks.mdx rename to website/docs/zh/config/test/reset-mocks.mdx index 8ebbcc094..d63f375ec 100644 --- a/website/docs/zh/config/test/resetMocks.mdx +++ b/website/docs/zh/config/test/reset-mocks.mdx @@ -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'; diff --git a/website/docs/zh/config/test/resolveSnapshotPath.mdx b/website/docs/zh/config/test/resolve-snapshot-path.mdx similarity index 100% rename from website/docs/zh/config/test/resolveSnapshotPath.mdx rename to website/docs/zh/config/test/resolve-snapshot-path.mdx diff --git a/website/docs/zh/config/test/restoreMocks.mdx b/website/docs/zh/config/test/restore-mocks.mdx similarity index 85% rename from website/docs/zh/config/test/restoreMocks.mdx rename to website/docs/zh/config/test/restore-mocks.mdx index 51b97301e..920461930 100644 --- a/website/docs/zh/config/test/restoreMocks.mdx +++ b/website/docs/zh/config/test/restore-mocks.mdx @@ -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'; diff --git a/website/docs/zh/config/test/setupFiles.mdx b/website/docs/zh/config/test/setup-files.mdx similarity index 100% rename from website/docs/zh/config/test/setupFiles.mdx rename to website/docs/zh/config/test/setup-files.mdx diff --git a/website/docs/zh/config/test/slowTestThreshold.mdx b/website/docs/zh/config/test/slow-test-threshold.mdx similarity index 100% rename from website/docs/zh/config/test/slowTestThreshold.mdx rename to website/docs/zh/config/test/slow-test-threshold.mdx diff --git a/website/docs/zh/config/test/snapshotFormat.mdx b/website/docs/zh/config/test/snapshot-format.mdx similarity index 100% rename from website/docs/zh/config/test/snapshotFormat.mdx rename to website/docs/zh/config/test/snapshot-format.mdx diff --git a/website/docs/zh/config/test/testEnvironment.mdx b/website/docs/zh/config/test/test-environment.mdx similarity index 100% rename from website/docs/zh/config/test/testEnvironment.mdx rename to website/docs/zh/config/test/test-environment.mdx diff --git a/website/docs/zh/config/test/testNamePattern.mdx b/website/docs/zh/config/test/test-name-pattern.mdx similarity index 100% rename from website/docs/zh/config/test/testNamePattern.mdx rename to website/docs/zh/config/test/test-name-pattern.mdx diff --git a/website/docs/zh/config/test/testTimeout.mdx b/website/docs/zh/config/test/test-timeout.mdx similarity index 100% rename from website/docs/zh/config/test/testTimeout.mdx rename to website/docs/zh/config/test/test-timeout.mdx diff --git a/website/docs/zh/config/test/unstubEnvs.mdx b/website/docs/zh/config/test/unstub-envs.mdx similarity index 100% rename from website/docs/zh/config/test/unstubEnvs.mdx rename to website/docs/zh/config/test/unstub-envs.mdx diff --git a/website/docs/zh/config/test/unstubGlobals.mdx b/website/docs/zh/config/test/unstub-globals.mdx similarity index 100% rename from website/docs/zh/config/test/unstubGlobals.mdx rename to website/docs/zh/config/test/unstub-globals.mdx diff --git a/website/docs/zh/guide/basic/cli.mdx b/website/docs/zh/guide/basic/cli.mdx index 62c16156b..bc56e920a 100644 --- a/website/docs/zh/guide/basic/cli.mdx +++ b/website/docs/zh/guide/basic/cli.mdx @@ -116,24 +116,24 @@ Rstest CLI 支持以下常用参数,所有命令均可使用: | `--exclude ` | 排除指定文件,详见 [exclude](/config/test/exclude) | | `-u, --update` | 更新快照文件,详见 [update](/config/test/update) | | `--coverage` | 启用代码覆盖率收集,详见 [coverage](/config/test/coverage) | -| `--passWithNoTests` | 当未找到测试文件时允许测试通过,详见 [passWithNoTests](/config/test/passWithNoTests) | -| `--printConsoleTrace` | 调用 console 方法时打印调用栈,详见 [printConsoleTrace](/config/test/printConsoleTrace) | +| `--passWithNoTests` | 当未找到测试文件时允许测试通过,详见 [passWithNoTests](/config/test/pass-with-no-tests) | +| `--printConsoleTrace` | 调用 console 方法时打印调用栈,详见 [printConsoleTrace](/config/test/print-console-trace) | | `--project ` | 仅运行指定项目的测试,详见 [根据项目名称过滤](/guide/basic/test-filter#根据项目名称过滤) | -| `--disableConsoleIntercept` | 禁用 console 拦截,详见 [disableConsoleIntercept](/config/test/disableConsoleIntercept) | -| `--slowTestThreshold ` | 设置测试或套件被视为慢的阈值(毫秒),详见 [slowTestThreshold](/config/test/slowTestThreshold) | -| `-t, --testNamePattern ` | 仅运行名称匹配正则的测试,详见 [testNamePattern](/config/test/testNamePattern) | -| `--testEnvironment ` | 指定测试环境,详见 [testEnvironment](/config/test/testEnvironment) | -| `--testTimeout ` | 设置单个测试的超时时间(毫秒),详见 [testTimeout](/config/test/testTimeout) | -| `--hookTimeout ` | 设置单个测试 hook 的超时时间(毫秒),详见 [hookTimeout](/config/test/hookTimeout) | +| `--disableConsoleIntercept` | 禁用 console 拦截,详见 [disableConsoleIntercept](/config/test/disable-console-intercept) | +| `--slowTestThreshold ` | 设置测试或套件被视为慢的阈值(毫秒),详见 [slowTestThreshold](/config/test/slow-test-threshold) | +| `-t, --testNamePattern ` | 仅运行名称匹配正则的测试,详见 [testNamePattern](/config/test/test-name-pattern) | +| `--testEnvironment ` | 指定测试环境,详见 [testEnvironment](/config/test/test-environment) | +| `--testTimeout ` | 设置单个测试的超时时间(毫秒),详见 [testTimeout](/config/test/test-timeout) | +| `--hookTimeout ` | 设置单个测试 hook 的超时时间(毫秒),详见 [hookTimeout](/config/test/hook-timeout) | | `--retry ` | 测试失败时重试次数,详见 [retry](/config/test/retry) | | `--bail ` | 指定个数的测试失败后停止运行,详见 [bail](/config/test/bail) | | `--reporter ` | 指定测试报告器,详见 [reporters](/config/test/reporters) | -| `--maxConcurrency ` | 最大并发测试数,详见 [maxConcurrency](/config/test/maxConcurrency) | -| `--clearMocks` | 每个测试前自动清除 mock 调用、实例、上下文和结果,详见 [clearMocks](/config/test/clearMocks) | -| `--resetMocks` | 每个测试前自动重置 mock 状态,详见 [resetMocks](/config/test/resetMocks) | -| `--restoreMocks` | 每个测试前自动恢复 mock 状态和实现,详见 [restoreMocks](/config/test/restoreMocks) | -| `--unstubGlobals` | 每个测试前恢复被 `rstest.stubGlobal` 修改的全局变量,详见 [unstubGlobals](/config/test/unstubGlobals) | -| `--unstubEnvs` | 每个测试前恢复被 `rstest.stubEnv` 修改的 `process.env`,详见 [unstubEnvs](/config/test/unstubEnvs) | +| `--maxConcurrency ` | 最大并发测试数,详见 [maxConcurrency](/config/test/max-concurrency) | +| `--clearMocks` | 每个测试前自动清除 mock 调用、实例、上下文和结果,详见 [clearMocks](/config/test/clear-mocks) | +| `--resetMocks` | 每个测试前自动重置 mock 状态,详见 [resetMocks](/config/test/reset-mocks) | +| `--restoreMocks` | 每个测试前自动恢复 mock 状态和实现,详见 [restoreMocks](/config/test/restore-mocks) | +| `--unstubGlobals` | 每个测试前恢复被 `rstest.stubGlobal` 修改的全局变量,详见 [unstubGlobals](/config/test/unstub-globals) | +| `--unstubEnvs` | 每个测试前恢复被 `rstest.stubEnv` 修改的 `process.env`,详见 [unstubEnvs](/config/test/unstub-envs) | | `-h, --help` | 显示帮助信息 | | `-v, --version` | 显示版本号 | diff --git a/website/docs/zh/guide/basic/test-filter.mdx b/website/docs/zh/guide/basic/test-filter.mdx index 04395332c..9bd7b3bea 100644 --- a/website/docs/zh/guide/basic/test-filter.mdx +++ b/website/docs/zh/guide/basic/test-filter.mdx @@ -70,7 +70,7 @@ rstest --include test/a/*.test.ts --include test/b/*.test.ts ## 根据测试名称过滤 -如果你只想运行名称中包含特定关键字的测试用例,可以使用 [testNamePattern](/config/test/testNamePattern)。 +如果你只想运行名称中包含特定关键字的测试用例,可以使用 [testNamePattern](/config/test/test-name-pattern)。 如,只运行名称包含 "login" 的测试用例: diff --git a/website/docs/zh/guide/migration/jest.mdx b/website/docs/zh/guide/migration/jest.mdx index a626e9277..272fa802d 100644 --- a/website/docs/zh/guide/migration/jest.mdx +++ b/website/docs/zh/guide/migration/jest.mdx @@ -43,7 +43,7 @@ export default defineConfig({ | `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) | diff --git a/website/docs/zh/guide/start/features.mdx b/website/docs/zh/guide/start/features.mdx index 1d755c5e1..4270f5a9e 100644 --- a/website/docs/zh/guide/start/features.mdx +++ b/website/docs/zh/guide/start/features.mdx @@ -22,7 +22,7 @@ Rstest 提供了多项目测试的能力,支持在单个 Rstest 进程中并 Rstest 支持类 [Rust 的模块测试](https://doc.rust-lang.org/book/ch11-03-test-organization.html#the-tests-module-and-cfgtest)方式,可在源码文件内直接书写测试块。此方式适用于小型功能函数与工具方法,便于快速验证和调试。 -了解更多关于 [源码内联测试](/config/test/includeSource)。 +了解更多关于 [源码内联测试](/config/test/include-source)。 ## Watch 模式 @@ -32,7 +32,7 @@ Rstest 支持类 [Rust 的模块测试](https://doc.rust-lang.org/book/ch11-03-t Rstest 支持使用 jsdom 与 happy-dom 模拟 DOM 与浏览器 API,并对 React、Vue 等框架提供良好支持,兼容 Testing Library、CSS Modules 等。 -了解更多关于 [DOM 测试](/config/test/testEnvironment#dom-测试)。 +了解更多关于 [DOM 测试](/config/test/test-environment#dom-测试)。 ## 代码覆盖率 diff --git a/website/docs/zh/guide/start/quick-start.mdx b/website/docs/zh/guide/start/quick-start.mdx index d2633e6ad..2b5a63f2e 100644 --- a/website/docs/zh/guide/start/quick-start.mdx +++ b/website/docs/zh/guide/start/quick-start.mdx @@ -51,7 +51,7 @@ Rstest 内置了 `watch`、`run` 等命令,请参考 [CLI 工具](/guide/basic ## 编写测试 -作为一个简单的例子,我们有一个 `sayHi` 方法。为了对它进行测试,你可以创建一个名为 `index.test.ts` 的测试文件或使用与 [Rust 测试](https://doc.rust-lang.org/book/ch11-03-test-organization.html#the-tests-module-and-cfgtest) 类似的 [In-Source 测试](/config/test/includeSource)。 +作为一个简单的例子,我们有一个 `sayHi` 方法。为了对它进行测试,你可以创建一个名为 `index.test.ts` 的测试文件或使用与 [Rust 测试](https://doc.rust-lang.org/book/ch11-03-test-organization.html#the-tests-module-and-cfgtest) 类似的 [In-Source 测试](/config/test/include-source)。 ```ts title=index.ts export const sayHi = () => 'hi'; diff --git a/website/theme/components/ConfigOverview.tsx b/website/theme/components/ConfigOverview.tsx index 94bbeac9f..f0e048648 100644 --- a/website/theme/components/ConfigOverview.tsx +++ b/website/theme/components/ConfigOverview.tsx @@ -71,6 +71,10 @@ const OVERVIEW_GROUPS: BasicGroup[] = [ }, ]; +function camelToKebab(str: string) { + return str.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`); +} + export default function Overview() { const tUrl = useI18nUrl(); @@ -81,7 +85,7 @@ export default function Overview() { link: '', items: item.items?.map((item) => { return { - link: tUrl(`/config/test/${item}`), + link: tUrl(`/config/test/${camelToKebab(item)}`), text: item, }; }),