Skip to content

Commit

Permalink
fix: remove test command doc
Browse files Browse the repository at this point in the history
  • Loading branch information
caohuilin committed Jun 20, 2024
1 parent 7b733d0 commit 01b2776
Show file tree
Hide file tree
Showing 14 changed files with 9 additions and 112 deletions.
9 changes: 9 additions & 0 deletions .changeset/curvy-carrots-beam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@modern-js/module-generator': patch
'@modern-js/module-tools-docs': patch
'@modern-js/main-doc': patch
---

fix: remove test command doc

fix: 移除 test 命令相关文档
35 changes: 0 additions & 35 deletions packages/document/main-doc/docs/en/apis/app/commands.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -266,38 +266,3 @@ Options:
Normally, only the part of the code modified by this commit needs to be checked by `lint-staged` during the `git commit` phase.

- `--no-fix` close auto fix by lint.

## modern test

`modern test` command will automatically run the test cases.

```bash
Usage: modern test [options]

Options:
-u --updateSnapshot use this flag to re-record snapshots.
--watch watch files for changes and rerun tests related to changed files.
-h, --help show command help
```

:::tip
`modern test` command need to execute the `new` command in advance to enable the `unit test/integration test`.
:::

The effect is as follows:

```bash
$ npx modern test
PASS src/tests/index.test.ts
The add method
✓ should work fine. (2ms)

Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 0.994 s, estimated 1 s
```

:::info
Files match `*.test.(js|ts)` in `api/` or `src/` folders will be recognized as test cases by default.
:::
1 change: 0 additions & 1 deletion packages/document/main-doc/docs/en/configure/app/usage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ This function takes the following parameters:
- `env`: same as the value of `process.env.NODE_ENV`.
- When running `modern dev` or `modern start`, the value of `env` is `development`.
- When running `modern build` or `modern serve`, the value of `env` is `production`.
- When running `modern test`, the value of `env` is `test`.
- `command`: corresponds to the currently running command, such as `dev`, `start`, `build`, `serve`.

### Export Async Function
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ The current path prefix of the asset, which is a read-only environment variable.
The current execution environment and is a **read-only** environment variable whose have different values under different execution commands:

- `production`: Default value when running `modern build` or `modern serve`.
- `test`: Default value when running `modern test`.
- `development`: Default value when running `modern dev`, also the default value in other cases.

### MODERN_ENV
Expand Down
35 changes: 0 additions & 35 deletions packages/document/main-doc/docs/zh/apis/app/commands.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -268,38 +268,3 @@ Options:
通常情况下,我们只需要在 `git commit` 阶段通过 `lint-staged` 检查本次提交修改的部分代码。

- 设置 `--no-fix` 参数后可以关闭自动修复 lint 错误代码的能力。

## modern test

`modern test` 命令会自动运行项目下的测试用例。

```bash
Usage: modern test [options]

Options:
-u --updateSnapshot 使用此选项来更新快照
--watch 监视文件的变更并重新运行相关的测试
-h, --help 显示命令帮助
```

:::tip
在使用 `modern test` 命令前,需要先通过 [`new`](/apis/app/commands#modern-new) 命令启用「单元测试 / 集成测试」功能。
:::

效果如下:

```bash
$ npx modern test
PASS src/tests/index.test.ts
The add method
✓ should work fine. (2ms)

Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 0.994 s, estimated 1 s
```

:::info
`src``api` 目录下面的 `*.test.(js|ts)` 文件都会被识别为测试用例。
:::
1 change: 0 additions & 1 deletion packages/document/main-doc/docs/zh/configure/app/usage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ export default defineConfig(({ env, command }) => ({
- `env`:对应 `process.env.NODE_ENV` 的值。
- 当运行 `modern dev``modern start` 时,`env` 的值为 `development`
- 当运行 `modern build``modern serve` 时,`env` 的值为 `production`
- 当运行 `modern test` 时,`env` 的值为 `test`
- `command`:对应当前运行的命令,如 `dev``start``build``serve`

### 导出异步函数
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ Modern.js 提供了对环境变量的支持,包含内置的环境变量和自
表示当前的执行环境,是**只读的**的环境变量,其值在不同的执行命令下具有不同的值:

- `production`:执行 `modern build``modern serve` 命令时的默认值。
- `test`:执行 `modern test` 命令时的默认值。
- `development`:执行 `modern dev` 命令时的默认值,同时也是其他所有情况下的默认值。

### MODERN_ENV
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,6 @@ The Modern.js Module provides the ability to use debugging tools, which can be s

The officially supported debugging tool is [Rspress](https://rspress.dev/), so you can run `modern dev` or `modern dev doc` to execute it after you run `modern new` to enable it.

## `modern test`

```bash
Usage: modern test [options]

Options:
-u --updateSnapshot use this flag to re-record snapshots.
--watch watch files for changes and rerun tests related to changed files.
-h, --help show command help
```

You need to execute `modern new` to turn on the test function before you can execute the `modern test` command.
The `modern test` command will automatically run the `src/tests/*.test.(js|ts|jsx|tsx)` file as a test case.

## `modern lint`

```bash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ If you are planning to develop a project of the npm package type, then you came
- **Code formatting**: In Modern.js Module, you can execute `modern lint` to format the code. The initialized module project includes the [ESLint](https://eslint.org/docs/latest/user-guide/core-concepts#what-is-eslint) ruleset for Modern.js for most scenarios.
- **Comprehensive build capabilities and faster builds**: Modern.js Module provides high-performance build capabilities based on [esbuild](https://esbuild.github.io/getting-started/) and [SWC](https://swc.rs/), and provides rich configurations for different build scenarios.
- **Storybook debugging tools**: Modern.js Module provides [Storybook](https://storybook.js.org/) debugging tools for debugging module projects. After installing the Storybook plugin for Modern.js Module, you can start it with the `storybook dev` command. You can use Storybook not only for debugging components, but also for other types of modules.
- **Testing capabilities with Jest**: When you need to test a module, you can use the `modern test` command of Modern.js Module, which not only integrates with [Jest](https://jestjs.io/), but also provides an API for configuring [Jest](https://jestjs.io/docs/configuration).
- **Versioning based on Changesets**: When you need to record changes to a project, you can use the `modern change` command to generate a Markdown file containing the changes; when you need to upgrade a project, you can use the `modern bump` command to analyze and upgrade the version through the Markdown file; when you need to release a project, you can use the `modern release` command to release the project; Modern.js Module implements these commands based on [Changesets](https://github.com/changesets/changesets).
- **Extensible plugin mechanism**: Want to integrate additional debugging tools for your project? Or maybe you want to do some extra processing during the build process, Modern.js Module provides a plugin mechanism and plugin hooks that cover both the `dev` command and the `build` command process. You can use them to extend the capabilities of your project.
- **Lots more!** Modern.js Module will continue to optimize its build and debug features in the future. If there are important issues to be solved in module project building, or if a mainstream module project debugging tool or pattern emerges, then they will probably be supported by Modern.js Module.
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,6 @@ Modern.js Module 提供了使用调试工具的能力,可以通过 `modern dev

目前官方支持的调试工具有 [Rspress](https://rspress.dev/),因此在你执行 `modern new` 命令开启它后,就可以执行 `modern dev` 或者 `modern dev doc` 执行它。

## `modern test`

```bash
Usage: modern test [options]

Options:
-u --updateSnapshot 使用此选项来更新快照
--watch 监视文件的变更并重新运行相关的测试
-h, --help 显示命令帮助
```

需要先执行 `modern new` 开启测试功能,然后才可以执行 `modern test` 命令。
`modern test` 命令会自动将 `tests/*.test.(js|ts|jsx|tsx)` 文件当做测试用例运行。

## `modern lint`

```bash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ Modern.js Module 是 Modern.js 的模块工程解决方案,同时也是核心
- **代码格式化**:在模块工程项目中,你可以执行 `modern lint` 来对代码进行格式化。同时初始化的模块工程项目里包含了 Modern.js 的 [ESLint](https://eslint.org/docs/latest/user-guide/core-concepts#what-is-eslint) 规则集,可以满足大部分场景下的需求。
- **全面的构建能力和更快的构建速度**:Modern.js Module 基于 [esbuild](https://esbuild.github.io/getting-started/)[SWC](https://swc.rs/) 提供了高性能的构建能力,并且为不同构建模块的场景提供了丰富的配置。
- **Storybook 调试工具**:Modern.js Module 为调试模块项目提供了 [Storybook](https://storybook.js.org/) 调试工具。在安装了 Modern.js Module 的 Storybook 插件后,你可以使用 `storybook dev` 命令来启动它。你不仅可以使用 Storybook 对组件进行调试,也可以使用在其他类型的模块上。
- **集成 Jest 的测试能力**:在需要对模块测试的时候,可以使用 Modern.js Module 的 `modern test` 命令。Modern.js Module 不仅集成了 [Jest](https://jestjs.io/),同时也提供了配置 [Jest](https://jestjs.io/docs/configuration) 的 API。
- **基于 Changesets 实现的版本管理**:当需要对项目记录变更内容的时候,可以使用 `modern change` 命令生成包含变更内容的 Markdown 文件;当需要对项目进行版本升级的时候,可以使用 `modern bump` 命令通过 Markdown 文件分析并升级版本;当需要发布项目的时候,可以使用 `modern release` 命令对项目进行发布。Modern.js Module 基于 [Changesets](https://github.com/changesets/changesets) 实现了这些命令。
- **可扩展性的插件机制**:想要为项目集成其他的调试工具?又或者是想要在构建过程中做一些额外处理?Modern.js Module 提供了插件机制和插件钩子,插件钩子覆盖了 `dev` 命令和 `build` 命令两个流程。你可以通过它们为项目进行能力的扩展。
- **还有更多**:Modern.js Module 在未来还会不断地在构建、调试功能上进行优化。如果在模块项目构建上存在需要解决的重要问题,又或者是某个主流的模块项目调试工具、模式出现的时候,那么它们很可能成为 Modern.js Module 将要支持功能。
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ export const EN_LOCALE = {
{packageManager} change # Add a new changeset
{packageManager} bump # Update version and changelog via changeset
{packageManager} new # Enable optional features
{packageManager} test # Run test cases
{packageManager} release # Release the package`,
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ export const ZH_LOCALE = {
{packageManager} change # 新增 changeset 变更
{packageManager} bump # 基于 changeset 更新版本号和 changelog
{packageManager} new # 启用可选功能
{packageManager} test # 运行测试用例
{packageManager} release # 发布当前 npm 包`,
};
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ Run and debug the module:
{{packageManager}} dev
```

Run test cases:

```bash
{{packageManager}} test
```

Build the module for production:

```bash
Expand Down

0 comments on commit 01b2776

Please sign in to comment.