@supersigil/vitest 0.1.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 ADDED
@@ -0,0 +1,45 @@
1
+ # @supersigil/vitest
2
+
3
+ Vitest helper for annotating tests with [Supersigil](https://supersigil.org) criterion refs.
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ npm install -D @supersigil/vitest
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ Use the `verifies()` function to link test cases to specification criteria:
14
+
15
+ ```ts
16
+ import { verifies } from '@supersigil/vitest'
17
+
18
+ it('rejects invalid email', verifies('auth/req#req-1-1'), () => {
19
+ expect(validateEmail('bad')).toBe(false)
20
+ })
21
+ ```
22
+
23
+ Multiple criteria can be referenced:
24
+
25
+ ```ts
26
+ it('sends welcome email', verifies('auth/req#req-2-1', 'notifications/req#req-1-1'), () => {
27
+ // ...
28
+ })
29
+ ```
30
+
31
+ The returned object can be spread into other test options:
32
+
33
+ ```ts
34
+ it('completes within timeout', { ...verifies('perf/req#req-1-1'), timeout: 5000 }, () => {
35
+ // ...
36
+ })
37
+ ```
38
+
39
+ ## How it works
40
+
41
+ `verifies()` returns a Vitest-compatible metadata object (`{ meta: { verifies: [...] } }`) that Supersigil reads during verification to trace test coverage back to specification criteria.
42
+
43
+ ## License
44
+
45
+ [MIT](../../LICENSE-MIT) OR [Apache-2.0](../../LICENSE-APACHE)
@@ -0,0 +1,11 @@
1
+ declare module 'vitest' {
2
+ interface TaskMeta {
3
+ verifies?: string[];
4
+ }
5
+ }
6
+ export declare function verifies(...refs: string[]): {
7
+ meta: {
8
+ verifies: string[];
9
+ };
10
+ };
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,QAAQ,CAAC;IACtB,UAAU,QAAQ;QAChB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;KACpB;CACF;AAED,wBAAgB,QAAQ,CACtB,GAAG,IAAI,EAAE,MAAM,EAAE,GAChB;IAAE,IAAI,EAAE;QAAE,QAAQ,EAAE,MAAM,EAAE,CAAA;KAAE,CAAA;CAAE,CAElC"}
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+ // src/index.ts
2
+ function verifies(...refs) {
3
+ return { meta: { verifies: refs } };
4
+ }
5
+ export {
6
+ verifies
7
+ };
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts"],
4
+ "sourcesContent": ["declare module 'vitest' {\n interface TaskMeta {\n verifies?: string[]\n }\n}\n\nexport function verifies(\n ...refs: string[]\n): { meta: { verifies: string[] } } {\n return { meta: { verifies: refs } }\n}\n"],
5
+ "mappings": ";AAMO,SAAS,YACX,MAC+B;AAClC,SAAO,EAAE,MAAM,EAAE,UAAU,KAAK,EAAE;AACpC;",
6
+ "names": []
7
+ }
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@supersigil/vitest",
3
+ "version": "0.1.0",
4
+ "description": "Vitest helper for annotating tests with Supersigil criterion refs",
5
+ "license": "MIT OR Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/jonisavo/supersigil.git",
9
+ "directory": "packages/vitest"
10
+ },
11
+ "homepage": "https://supersigil.org",
12
+ "bugs": "https://github.com/jonisavo/supersigil/issues",
13
+ "keywords": [
14
+ "vitest",
15
+ "testing",
16
+ "supersigil",
17
+ "specification",
18
+ "traceability"
19
+ ],
20
+ "engines": {
21
+ "node": ">=18"
22
+ },
23
+ "type": "module",
24
+ "exports": {
25
+ ".": {
26
+ "import": "./dist/index.js",
27
+ "types": "./dist/index.d.ts"
28
+ }
29
+ },
30
+ "files": [
31
+ "dist/",
32
+ "src/",
33
+ "README.md"
34
+ ],
35
+ "peerDependencies": {
36
+ "vitest": ">=4.1.0"
37
+ },
38
+ "devDependencies": {
39
+ "esbuild": "^0.28.0",
40
+ "typescript": "^6.0.2",
41
+ "vitest": "^4.1.3"
42
+ },
43
+ "scripts": {
44
+ "build": "node esbuild.mjs && tsc --emitDeclarationOnly --noEmit false --outDir dist",
45
+ "test": "vitest run"
46
+ }
47
+ }
package/src/index.ts ADDED
@@ -0,0 +1,11 @@
1
+ declare module 'vitest' {
2
+ interface TaskMeta {
3
+ verifies?: string[]
4
+ }
5
+ }
6
+
7
+ export function verifies(
8
+ ...refs: string[]
9
+ ): { meta: { verifies: string[] } } {
10
+ return { meta: { verifies: refs } }
11
+ }