@continuous-excellence/testmints-js 0.0.1 → 0.0.2
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 +14 -8
- package/dist/vitest.d.ts +8 -1
- package/dist/vitest.d.ts.map +1 -1
- package/dist/vitest.js +33 -22
- package/dist/vitest.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,19 +16,24 @@ The test suite is first-class usage documentation: each test should show a reali
|
|
|
16
16
|
also proving the library behavior it relies on.
|
|
17
17
|
|
|
18
18
|
```ts
|
|
19
|
-
import { expect } from 'vitest'
|
|
20
|
-
import {
|
|
19
|
+
import { expect, test } from 'vitest'
|
|
20
|
+
import { mint } from '@continuous-excellence/testmints-js/vitest'
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
test('15 produces FizzBuzz', mint({
|
|
23
23
|
setup: () => 15,
|
|
24
24
|
exercise: (input) => fizzBuzz(input),
|
|
25
25
|
verify: (output) => expect(output).toBe('FizzBuzz'),
|
|
26
|
-
})
|
|
26
|
+
}))
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
+
`mint` validates the complete definition when the test file is collected, while keeping Vitest's
|
|
30
|
+
`test` or `it` call visible to test explorers and source scanners. When an explicit callback is
|
|
31
|
+
clearer—for example, in a parameterized test—use `runMint(definition, context)` inside the Vitest
|
|
32
|
+
callback instead.
|
|
33
|
+
|
|
29
34
|
## Local phase artifacts with Vitest
|
|
30
35
|
|
|
31
|
-
Enable the Node/Vitest reporting plugin in `vitest.config.ts`. Existing `
|
|
36
|
+
Enable the Node/Vitest reporting plugin in `vitest.config.ts`. Existing `mint` callbacks need no
|
|
32
37
|
per-test configuration.
|
|
33
38
|
|
|
34
39
|
```ts
|
|
@@ -66,21 +71,22 @@ Resources acquired through `scope.using()` survive verification and are released
|
|
|
66
71
|
including after a failed setup, exercise, or verification.
|
|
67
72
|
|
|
68
73
|
```ts
|
|
69
|
-
|
|
74
|
+
test('a member can save their display name', mint({
|
|
70
75
|
setup: async ({ scope }) => ({
|
|
71
76
|
account: await scope.using('temporary account', createAccount, deleteAccount),
|
|
72
77
|
displayName: 'Ada',
|
|
73
78
|
}),
|
|
74
79
|
exercise: ({ account, displayName }) => updateProfile(account.id, { displayName }),
|
|
75
80
|
verify: (profile) => expect(profile.displayName).toBe('Ada'),
|
|
76
|
-
})
|
|
81
|
+
}))
|
|
77
82
|
```
|
|
78
83
|
|
|
79
84
|
## Development
|
|
80
85
|
|
|
81
86
|
`npm run check` runs formatting/lint checks, type fixtures, and the test suite. Every test is both
|
|
82
87
|
evidence for the library and an example of its intended use. Core-contract scenarios also use
|
|
83
|
-
`
|
|
88
|
+
visible Vitest registration with `mint`, exercising lower-level bootstrap primitives within that
|
|
89
|
+
same test shape.
|
|
84
90
|
|
|
85
91
|
Contributors should begin with [the project philosophy](docs/project-philosophy.md). The
|
|
86
92
|
[library direction log](docs/library-direction.md) captures longer-term design questions that are
|
package/dist/vitest.d.ts
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import type { Plugin } from "vite";
|
|
2
|
+
import type { TestContext, TestFunction } from "vitest";
|
|
2
3
|
import { type TestmintDefinition } from "./core.js";
|
|
3
4
|
export interface TestmintsVitestOptions {
|
|
4
5
|
/** Root directory for run artifacts. Defaults to `.testmints`. */
|
|
5
6
|
outputDir?: string;
|
|
6
7
|
}
|
|
7
|
-
/**
|
|
8
|
+
/** Execute a complete Testmint definition from a Vitest test callback. */
|
|
9
|
+
export declare function runMint<Input, Output>(definition: TestmintDefinition<Input, Output>, context: TestContext): Promise<void>;
|
|
10
|
+
/** Create a Vitest callback from a complete Testmint definition. */
|
|
11
|
+
export declare function mint<Input, Output>(definition: TestmintDefinition<Input, Output>): TestFunction;
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated Use Vitest registration directly: `test(name, mint(definition))`.
|
|
14
|
+
*/
|
|
8
15
|
export declare function mintTest<Input, Output>(name: string, definition: TestmintDefinition<Input, Output>): void;
|
|
9
16
|
/** Enable local Testmints NDJSON artifacts for a Node Vitest project. */
|
|
10
17
|
export declare function testmintsVitest(options?: TestmintsVitestOptions): Plugin;
|
package/dist/vitest.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.d.ts","sourceRoot":"","sources":["../src/vitest.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"vitest.d.ts","sourceRoot":"","sources":["../src/vitest.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAIxD,OAAO,EAEN,KAAK,kBAAkB,EAEvB,MAAM,WAAW,CAAC;AASnB,MAAM,WAAW,sBAAsB;IACtC,kEAAkE;IAClE,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAqCD,0EAA0E;AAC1E,wBAAsB,OAAO,CAAC,KAAK,EAAE,MAAM,EAC1C,UAAU,EAAE,kBAAkB,CAAC,KAAK,EAAE,MAAM,CAAC,EAC7C,OAAO,EAAE,WAAW,GAClB,OAAO,CAAC,IAAI,CAAC,CAEf;AAED,oEAAoE;AACpE,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,EACjC,UAAU,EAAE,kBAAkB,CAAC,KAAK,EAAE,MAAM,CAAC,GAC3C,YAAY,CAGd;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EACrC,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,kBAAkB,CAAC,KAAK,EAAE,MAAM,CAAC,GAC3C,IAAI,CAEN;AAyDD,yEAAyE;AACzE,wBAAgB,eAAe,CAAC,OAAO,GAAE,sBAA2B,GAAG,MAAM,CA4B5E"}
|
package/dist/vitest.js
CHANGED
|
@@ -10,30 +10,41 @@ function id() {
|
|
|
10
10
|
}
|
|
11
11
|
const producerId = `${process.pid}-${threadId}`;
|
|
12
12
|
let producerSequence = 0;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
},
|
|
32
|
-
nextEventSequence: () => producerSequence++,
|
|
33
|
-
}),
|
|
34
|
-
});
|
|
13
|
+
async function runValidatedMint(definition, context) {
|
|
14
|
+
const reporting = reportingContext();
|
|
15
|
+
const task = context.task;
|
|
16
|
+
await executeDefinition(definition, {
|
|
17
|
+
signal: context.signal,
|
|
18
|
+
...(reporting === undefined
|
|
19
|
+
? {}
|
|
20
|
+
: {
|
|
21
|
+
sink: new NdjsonEventSink(reporting),
|
|
22
|
+
eventContext: {
|
|
23
|
+
runId: reporting.runId,
|
|
24
|
+
producerId,
|
|
25
|
+
attemptId: id(),
|
|
26
|
+
testId: task.id,
|
|
27
|
+
title: task.fullName,
|
|
28
|
+
},
|
|
29
|
+
nextEventSequence: () => producerSequence++,
|
|
30
|
+
}),
|
|
35
31
|
});
|
|
36
32
|
}
|
|
33
|
+
/** Execute a complete Testmint definition from a Vitest test callback. */
|
|
34
|
+
export async function runMint(definition, context) {
|
|
35
|
+
await runValidatedMint(validateDefinition(definition), context);
|
|
36
|
+
}
|
|
37
|
+
/** Create a Vitest callback from a complete Testmint definition. */
|
|
38
|
+
export function mint(definition) {
|
|
39
|
+
const validated = validateDefinition(definition);
|
|
40
|
+
return async (context) => runValidatedMint(validated, context);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* @deprecated Use Vitest registration directly: `test(name, mint(definition))`.
|
|
44
|
+
*/
|
|
45
|
+
export function mintTest(name, definition) {
|
|
46
|
+
test(name, mint(definition));
|
|
47
|
+
}
|
|
37
48
|
class TestmintsReporter {
|
|
38
49
|
context;
|
|
39
50
|
#incomplete = false;
|
package/dist/vitest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.js","sourceRoot":"","sources":["../src/vitest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"vitest.js","sourceRoot":"","sources":["../src/vitest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAG/C,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAGtC,OAAO,EACN,iBAAiB,EAEjB,kBAAkB,GAClB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EAEf,aAAa,GACb,MAAM,gBAAgB,CAAC;AAOxB,SAAS,gBAAgB;IACxB,OAAO,MAAM,CAAC,WAAW,CAAC,CAAC;AAC5B,CAAC;AAED,SAAS,EAAE;IACV,OAAO,MAAM,CAAC,UAAU,EAAE,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,QAAQ,EAAE,CAAC;AAChD,IAAI,gBAAgB,GAAG,CAAC,CAAC;AAEzB,KAAK,UAAU,gBAAgB,CAC9B,UAA6C,EAC7C,OAAoB;IAEpB,MAAM,SAAS,GAAG,gBAAgB,EAAE,CAAC;IACrC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAC1B,MAAM,iBAAiB,CAAC,UAAU,EAAE;QACnC,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,GAAG,CAAC,SAAS,KAAK,SAAS;YAC1B,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC;gBACA,IAAI,EAAE,IAAI,eAAe,CAAC,SAAS,CAAC;gBACpC,YAAY,EAAE;oBACb,KAAK,EAA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