@wwkit/harness 1.0.31 → 1.0.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wwkit/harness",
3
- "version": "1.0.31",
3
+ "version": "1.0.32",
4
4
  "author": "bluesliu <langcai163@163.com>",
5
5
  "description": "WebWork abilities for opencode",
6
6
  "type": "module",
@@ -24,6 +24,7 @@
24
24
  "moduleNameMapper": {},
25
25
  "testMatch": [
26
26
  "**/tests/unit/**/*.test.js",
27
+ "**/tests/integration/**/*.test.js",
27
28
  "**/tests/e2e/**/*.test.cjs"
28
29
  ],
29
30
  "setupFiles": [
@@ -49,17 +50,17 @@
49
50
  "ajv": "^8.17.0",
50
51
  "cheerio": "^1.0.0",
51
52
  "json5": "^2.2.3",
52
- "@wwkit/shared": "1.0.27"
53
+ "@wwkit/shared": "1.0.28"
53
54
  },
54
55
  "devDependencies": {
55
56
  "jest": "^29.7.0"
56
57
  },
57
58
  "scripts": {
58
59
  "postinstall": "node scripts/postinstall.js",
59
- "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --no-cache",
60
- "test:all": "node --experimental-vm-modules node_modules/jest/bin/jest.js --no-cache tests/unit",
61
- "e2e": "node --experimental-vm-modules node_modules/jest/bin/jest.js --no-cache",
62
- "e2e:all": "node --experimental-vm-modules node_modules/jest/bin/jest.js --no-cache tests/e2e",
60
+ "ut": "node ../../scripts/run-tests.js unit",
61
+ "it": "node ../../scripts/run-tests.js integration",
62
+ "e2e": "node ../../scripts/run-tests.js e2e",
63
+ "test": "pnpm run ut",
63
64
  "release": "node ../../packages/shared/bin/release-pkg.js",
64
65
  "opencode": "OPENCODE_CONFIG_DIR=$(pwd) opencode"
65
66
  }
package/readme/publish.md CHANGED
@@ -18,7 +18,7 @@ pnpm version patch
18
18
  # //registry.npmjs.org/:_authToken=npm_xxxxx
19
19
  # 若账号开启了 2FA,token 需在创建时勾选 "Bypass 2FA",否则发布时需加 --otp=<动态码>
20
20
 
21
- # 4. 发布(自动先跑 pnpm run test:all)
21
+ # 4. 发布(自动先跑 pnpm run ut)
22
22
  pnpm publish
23
23
 
24
24
  # 5. 验证
package/readme/testing.md CHANGED
@@ -2,29 +2,37 @@
2
2
 
3
3
  Jest 需要 `--experimental-vm-modules` 和 `--no-cache`。请使用 pnpm 脚本,不要直接跑裸 `jest`。本包位于 `wwkit` monorepo 的 `packages/harness`,以下命令需在该目录下执行(或在仓库根用 `pnpm --filter harness run ...`)。
4
4
 
5
+ ## 测试目录规范
6
+
7
+ `tests/` 下先按分类分目录(`unit/` / `integration/` / `e2e/`),分类内镜像源码目录结构(含源码根前缀),如 `tests/unit/skills/extract/references/build-xpath.test.js` ↔ `skills/extract/references/build-xpath.js`。
8
+
5
9
  ## 单元测试(tests/unit/)
6
10
 
7
11
  ```bash
8
12
  # pnpm 命令
9
- pnpm test -- tests/unit/build-xpath.test.js # 指定单个测试文件
10
- pnpm run test:all # 整个 tests/unit/ 目录
13
+ pnpm run ut -- tests/unit/skills/extract/references/build-xpath.test.js # 指定单个测试文件
14
+ pnpm run ut # 整个 tests/unit/ 目录(pnpm test 为其别名)
11
15
 
12
16
  # 直接使用 jest(需 ESM 支持标志;pnpm 下 jest bin 是 shell shim,须指向实际 JS 入口)
13
- node --experimental-vm-modules node_modules/jest/bin/jest.js tests/unit/build-xpath.test.js --no-cache # 单个文件
17
+ node --experimental-vm-modules node_modules/jest/bin/jest.js tests/unit/skills/extract/references/build-xpath.test.js --no-cache # 单个文件
14
18
  node --experimental-vm-modules node_modules/jest/bin/jest.js tests/unit --no-cache # 整个目录
15
19
  ```
16
20
 
17
21
  单元测试为 ESM(`.js`),直接 import `skills/*/references/*.js` 的导出函数。
18
22
 
23
+ ## 集成测试(tests/integration/)
24
+
25
+ 真实拉起 CLI 子进程(`execSync node bin/index.js`)。`pnpm run it` 执行(注意:必须 `pnpm run it`,裸 `pnpm it` 是 pnpm 内置 install-test 别名)。
26
+
19
27
  ## E2E 测试(tests/e2e/,调用 opencode run 实际执行)
20
28
 
21
29
  ```bash
22
30
  # pnpm 命令
23
- pnpm run e2e -- tests/e2e/query/print.test.cjs # 指定单个测试文件
24
- pnpm run e2e:all # 整个 tests/e2e/ 目录
31
+ pnpm run e2e -- tests/e2e/skills/query/print.test.cjs # 指定单个测试文件
32
+ pnpm run e2e # 整个 tests/e2e/ 目录
25
33
 
26
34
  # 直接使用 jest
27
- node --experimental-vm-modules node_modules/jest/bin/jest.js tests/e2e/query/print.test.cjs --no-cache # 单个文件
35
+ node --experimental-vm-modules node_modules/jest/bin/jest.js tests/e2e/skills/query/print.test.cjs --no-cache # 单个文件
28
36
  node --experimental-vm-modules node_modules/jest/bin/jest.js tests/e2e --no-cache # 整个目录
29
37
  ```
30
38