@lssm/lib.testing 0.3.0 → 0.4.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
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
# @lssm/lib.testing
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Safe regeneration verification** — Capture production traffic and generate golden tests automatically.
|
|
4
|
+
|
|
5
|
+
Golden-test utilities that record real requests/responses and generate runnable test suites. Prove that regenerated code behaves identically to the original.
|
|
4
6
|
|
|
5
7
|
- **TrafficRecorder** captures production requests/responses with sampling + sanitization.
|
|
6
8
|
- **GoldenTestGenerator** converts snapshots into runnable suites.
|
|
@@ -34,3 +36,13 @@ See `GoldenTestGenerator` for generating suites and CLI in `@lssm/app.contracts-
|
|
|
34
36
|
|
|
35
37
|
|
|
36
38
|
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
@@ -6,7 +6,7 @@ import{serialize as e}from"../generator/assertion-builder.js";function t(t){let
|
|
|
6
6
|
`)}
|
|
7
7
|
});`}).join(`
|
|
8
8
|
`);return`
|
|
9
|
-
import { describe, it, expect } from '
|
|
9
|
+
import { describe, it, expect } from 'bun:test';
|
|
10
10
|
import { ${t.runnerFunction} } from '${t.runnerImport}';
|
|
11
11
|
|
|
12
12
|
describe('${t.suiteName}', () => {${n}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest-adapter.js","names":[],"sources":["../../src/adapters/vitest-adapter.ts"],"sourcesContent":["import type { GoldenTestCase } from '../types';\nimport { serialize } from '../generator/assertion-builder';\n\nexport interface VitestAdapterOptions {\n suiteName: string;\n cases: GoldenTestCase[];\n runnerImport: string;\n runnerFunction: string;\n}\n\nexport function generateVitestSuite(options: VitestAdapterOptions) {\n const caseBlocks = options.cases\n .map((testCase) => {\n const inputConst = serialize(testCase.input);\n const metadataConst = serialize(testCase.metadata ?? {});\n const assertions = testCase.success\n ? [\n `const result = await ${options.runnerFunction}(input${testCase.id}, metadata${testCase.id});`,\n `expect(result).toEqual(${serialize(testCase.expectedOutput ?? null)});`,\n ]\n : [\n `await expect(${options.runnerFunction}(input${testCase.id}, metadata${testCase.id})).rejects.toMatchObject(${serialize(testCase.expectedError ?? { message: 'expected failure' })});`,\n ];\n\n return `\n it('${testCase.name}', async () => {\n const input${testCase.id} = ${inputConst};\n const metadata${testCase.id} = ${metadataConst};\n ${assertions.join('\\n ')}\n });`;\n })\n .join('\\n');\n\n return `\nimport { describe, it, expect } from '
|
|
1
|
+
{"version":3,"file":"vitest-adapter.js","names":[],"sources":["../../src/adapters/vitest-adapter.ts"],"sourcesContent":["import type { GoldenTestCase } from '../types';\nimport { serialize } from '../generator/assertion-builder';\n\nexport interface VitestAdapterOptions {\n suiteName: string;\n cases: GoldenTestCase[];\n runnerImport: string;\n runnerFunction: string;\n}\n\nexport function generateVitestSuite(options: VitestAdapterOptions) {\n const caseBlocks = options.cases\n .map((testCase) => {\n const inputConst = serialize(testCase.input);\n const metadataConst = serialize(testCase.metadata ?? {});\n const assertions = testCase.success\n ? [\n `const result = await ${options.runnerFunction}(input${testCase.id}, metadata${testCase.id});`,\n `expect(result).toEqual(${serialize(testCase.expectedOutput ?? null)});`,\n ]\n : [\n `await expect(${options.runnerFunction}(input${testCase.id}, metadata${testCase.id})).rejects.toMatchObject(${serialize(testCase.expectedError ?? { message: 'expected failure' })});`,\n ];\n\n return `\n it('${testCase.name}', async () => {\n const input${testCase.id} = ${inputConst};\n const metadata${testCase.id} = ${metadataConst};\n ${assertions.join('\\n ')}\n });`;\n })\n .join('\\n');\n\n return `\nimport { describe, it, expect } from 'bun:test';\nimport { ${options.runnerFunction} } from '${options.runnerImport}';\n\ndescribe('${options.suiteName}', () => {${caseBlocks}\n});\n`.trim();\n}\n"],"mappings":"8DAUA,SAAgB,EAAoB,EAA+B,CACjE,IAAM,EAAa,EAAQ,MACxB,IAAK,GAAa,CACjB,IAAM,EAAa,EAAU,EAAS,MAAM,CACtC,EAAgB,EAAU,EAAS,UAAY,EAAE,CAAC,CAClD,EAAa,EAAS,QACxB,CACE,wBAAwB,EAAQ,eAAe,QAAQ,EAAS,GAAG,YAAY,EAAS,GAAG,IAC3F,0BAA0B,EAAU,EAAS,gBAAkB,KAAK,CAAC,IACtE,CACD,CACE,gBAAgB,EAAQ,eAAe,QAAQ,EAAS,GAAG,YAAY,EAAS,GAAG,2BAA2B,EAAU,EAAS,eAAiB,CAAE,QAAS,mBAAoB,CAAC,CAAC,IACpL,CAEL,MAAO;QACL,EAAS,KAAK;iBACL,EAAS,GAAG,KAAK,EAAW;oBACzB,EAAS,GAAG,KAAK,EAAc;MAC7C,EAAW,KAAK;MAAS,CAAC;QAE1B,CACD,KAAK;EAAK,CAEb,MAAO;;WAEE,EAAQ,eAAe,WAAW,EAAQ,aAAa;;YAEtD,EAAQ,UAAU,YAAY,EAAW;;EAEnD,MAAM"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lssm/lib.testing",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"README.md"
|
|
11
11
|
],
|
|
12
12
|
"scripts": {
|
|
13
|
+
"publish:pkg": "bun publish --tolerate-republish --ignore-scripts --verbose",
|
|
13
14
|
"build": "bun build:bundle && bun build:types",
|
|
14
15
|
"build:bundle": "tsdown",
|
|
15
16
|
"build:types": "tsc --noEmit",
|
|
@@ -18,20 +19,22 @@
|
|
|
18
19
|
"lint": "bun lint:fix",
|
|
19
20
|
"lint:fix": "eslint src --fix",
|
|
20
21
|
"lint:check": "eslint src",
|
|
21
|
-
"test": "
|
|
22
|
+
"test": "bun run"
|
|
22
23
|
},
|
|
23
24
|
"dependencies": {
|
|
24
|
-
"@lssm/lib.contracts": "^1.
|
|
25
|
+
"@lssm/lib.contracts": "^1.11.0"
|
|
25
26
|
},
|
|
26
27
|
"devDependencies": {
|
|
27
|
-
"@lssm/tool.tsdown": "
|
|
28
|
-
"@lssm/tool.typescript": "
|
|
28
|
+
"@lssm/tool.tsdown": "0.12.0",
|
|
29
|
+
"@lssm/tool.typescript": "0.11.0",
|
|
29
30
|
"tsdown": "^0.16.6",
|
|
30
|
-
"typescript": "^5.9.3"
|
|
31
|
-
"vitest": "^1.6.0"
|
|
31
|
+
"typescript": "^5.9.3"
|
|
32
32
|
},
|
|
33
33
|
"exports": {
|
|
34
34
|
".": "./dist/index.js",
|
|
35
35
|
"./*": "./*"
|
|
36
|
+
},
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public"
|
|
36
39
|
}
|
|
37
40
|
}
|