@mpcore/vitest 1.0.0 → 1.2.0
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/README.md +2 -0
- package/dist/{config-D3NKpUBr.d.mts → config-B8tDz46r.d.mts} +0 -4
- package/dist/{config-1SyUfssv.mjs → config-B9jueOkR.mjs} +2 -4
- package/dist/config.d.mts +1 -1
- package/dist/config.mjs +1 -1
- package/dist/index.d.mts +1 -3
- package/dist/index.mjs +2 -3
- package/dist/setup.mjs +3 -3
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -40,3 +40,5 @@ test('renders a page', async ({ mpcore, expect }) => {
|
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
`createMpcoreTest({ artifact: { projectPath: process.cwd() } })` still accepts an existing artifact directly. `createVitestProject()` also uses the configured artifact when omitted, and closes its runtime with the current test. Optional host mocks and `failOnConsoleError` can be passed without replacing the injected artifact. Calling either helper without a configured or explicit artifact reports an actionable error.
|
|
43
|
+
|
|
44
|
+
Setup also registers the semantic tree snapshot serializer from `@mpcore/test`. Use `expect(result.screen).toMatchSnapshot()` or snapshot an individual node. Snapshots preserve public tree and event-binding semantics while removing runtime IDs, style scope markers and generated handler names. Full diagnostic snapshots returned by `page.snapshot()` remain unchanged; use `toMiniProgramSnapshot()` explicitly to serialize one.
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { MiniProgramArtifact } from "@mpcore/test";
|
|
2
2
|
import { VitestPluginContext } from "vitest/node";
|
|
3
|
-
//#region src/artifact.d.ts
|
|
4
3
|
interface MpcoreArtifactWatcher {
|
|
5
4
|
artifact: MiniProgramArtifact;
|
|
6
5
|
close: () => void | Promise<void>;
|
|
@@ -19,8 +18,6 @@ declare module 'vitest' {
|
|
|
19
18
|
mpcoreArtifact: MiniProgramArtifact;
|
|
20
19
|
}
|
|
21
20
|
}
|
|
22
|
-
//#endregion
|
|
23
|
-
//#region src/config.d.ts
|
|
24
21
|
interface MpcoreVitestOptions {
|
|
25
22
|
artifact?: MpcoreArtifactFactory;
|
|
26
23
|
}
|
|
@@ -39,5 +36,4 @@ interface MpcoreVitestPlugin {
|
|
|
39
36
|
}
|
|
40
37
|
/** 配置入口仅依赖 runner 的公开类型,不提前加载测试线程的 expect/test。 */
|
|
41
38
|
declare function mpcoreTest(options?: MpcoreVitestOptions): MpcoreVitestPlugin;
|
|
42
|
-
//#endregion
|
|
43
39
|
export { MpcoreArtifactWatchCallbacks as a, MpcoreArtifactFactory as i, MpcoreVitestPlugin as n, MpcoreArtifactWatcher as o, mpcoreTest as r, MpcoreVitestOptions as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { fileURLToPath } from "node:url";
|
|
2
|
-
|
|
2
|
+
// src/artifact.ts
|
|
3
3
|
const MPCORE_ARTIFACT_KEY = "mpcoreArtifact";
|
|
4
4
|
/** 每次 configureVitest 调用只持有当前 project 的 watcher 和重跑队列。 */
|
|
5
5
|
async function configureArtifact(factory, { project, vitest }) {
|
|
@@ -57,8 +57,7 @@ async function configureArtifact(factory, { project, vitest }) {
|
|
|
57
57
|
})();
|
|
58
58
|
await starting;
|
|
59
59
|
}
|
|
60
|
-
|
|
61
|
-
//#region src/config.ts
|
|
60
|
+
// src/config.ts
|
|
62
61
|
/** 配置入口仅依赖 runner 的公开类型,不提前加载测试线程的 expect/test。 */
|
|
63
62
|
function mpcoreTest(options = {}) {
|
|
64
63
|
const setupFile = fileURLToPath(new URL("./setup.mjs", import.meta.url));
|
|
@@ -73,5 +72,4 @@ function mpcoreTest(options = {}) {
|
|
|
73
72
|
}
|
|
74
73
|
};
|
|
75
74
|
}
|
|
76
|
-
//#endregion
|
|
77
75
|
export { MPCORE_ARTIFACT_KEY as n, mpcoreTest as t };
|
package/dist/config.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as MpcoreArtifactWatchCallbacks, i as MpcoreArtifactFactory, n as MpcoreVitestPlugin, o as MpcoreArtifactWatcher, r as mpcoreTest, t as MpcoreVitestOptions } from "./config-
|
|
1
|
+
import { a as MpcoreArtifactWatchCallbacks, i as MpcoreArtifactFactory, n as MpcoreVitestPlugin, o as MpcoreArtifactWatcher, r as mpcoreTest, t as MpcoreVitestOptions } from "./config-B8tDz46r.mjs";
|
|
2
2
|
export { type MpcoreArtifactFactory, type MpcoreArtifactWatchCallbacks, type MpcoreArtifactWatcher, MpcoreVitestOptions, MpcoreVitestPlugin, mpcoreTest };
|
package/dist/config.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as mpcoreTest } from "./config-
|
|
1
|
+
export { t as mpcoreTest } from "./config-B9jueOkR.mjs";
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { a as MpcoreArtifactWatchCallbacks, i as MpcoreArtifactFactory, n as MpcoreVitestPlugin, o as MpcoreArtifactWatcher, r as mpcoreTest, t as MpcoreVitestOptions } from "./config-
|
|
1
|
+
import { a as MpcoreArtifactWatchCallbacks, i as MpcoreArtifactFactory, n as MpcoreVitestPlugin, o as MpcoreArtifactWatcher, r as mpcoreTest, t as MpcoreVitestOptions } from "./config-B8tDz46r.mjs";
|
|
2
2
|
import { CreateTestProjectOptions, MiniProgramEmissionSource, MiniProgramNode, MiniProgramTestProject } from "@mpcore/test";
|
|
3
3
|
export * from "@mpcore/test";
|
|
4
|
-
//#region src/index.d.ts
|
|
5
4
|
export interface MpcoreVitestFixture {
|
|
6
5
|
mpcore: MiniProgramTestProject;
|
|
7
6
|
}
|
|
@@ -20,5 +19,4 @@ declare module 'vitest' {
|
|
|
20
19
|
toHaveTextContent: T extends MiniProgramNode ? (value: string | RegExp) => R : never;
|
|
21
20
|
}
|
|
22
21
|
}
|
|
23
|
-
//#endregion
|
|
24
22
|
export { type MpcoreArtifactFactory, type MpcoreArtifactWatchCallbacks, type MpcoreArtifactWatcher, type MpcoreVitestOptions, type MpcoreVitestPlugin, mpcoreTest };
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { t as mpcoreTest } from "./config-
|
|
1
|
+
import { t as mpcoreTest } from "./config-B9jueOkR.mjs";
|
|
2
2
|
import { createTestProject, mpcoreMatchers } from "@mpcore/test";
|
|
3
3
|
import { expect, inject, onTestFinished, test } from "vitest";
|
|
4
4
|
export * from "@mpcore/test";
|
|
5
|
-
|
|
5
|
+
// src/index.ts
|
|
6
6
|
function projectOptions(options = {}) {
|
|
7
7
|
const artifact = options.artifact ?? inject("mpcoreArtifact");
|
|
8
8
|
if (!artifact) throw new Error("No mpcore artifact was provided. Configure mpcoreTest({ artifact }) from @mpcore/vitest/config or pass an explicit artifact.");
|
|
@@ -31,5 +31,4 @@ function createVitestProject(options) {
|
|
|
31
31
|
function registerMpcoreMatchers() {
|
|
32
32
|
expect.extend(mpcoreMatchers);
|
|
33
33
|
}
|
|
34
|
-
//#endregion
|
|
35
34
|
export { createMpcoreTest, createVitestProject, mpcoreTest, registerMpcoreMatchers };
|
package/dist/setup.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { mpcoreMatchers } from "@mpcore/test";
|
|
1
|
+
import { mpcoreMatchers, mpcoreSnapshotSerializer } from "@mpcore/test";
|
|
2
2
|
import { expect } from "vitest";
|
|
3
|
-
|
|
3
|
+
// src/setup.ts
|
|
4
4
|
expect.extend(mpcoreMatchers);
|
|
5
|
-
|
|
5
|
+
expect.addSnapshotSerializer(mpcoreSnapshotSerializer);
|
|
6
6
|
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpcore/vitest",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.2.0",
|
|
5
5
|
"description": "Vitest integration for @mpcore/test",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -45,16 +45,16 @@
|
|
|
45
45
|
"dist"
|
|
46
46
|
],
|
|
47
47
|
"engines": {
|
|
48
|
-
"node": "^22.
|
|
48
|
+
"node": "^22.23.4 || ^24.22.1 || >=26.12.1"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"vitest": ">=5.0.0"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@mpcore/test": "1.
|
|
54
|
+
"@mpcore/test": "1.2.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"vitest": "~5.0.
|
|
57
|
+
"vitest": "~5.0.5"
|
|
58
58
|
},
|
|
59
59
|
"publishConfig": {
|
|
60
60
|
"access": "public",
|