testeranto 0.146.1 → 0.146.4
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 +3 -1
- package/dist/common/src/Node.js +9 -6
- package/dist/common/src/PM/PM_WithEslintAndTsc.js +75 -58
- package/dist/common/src/PM/main.js +131 -79
- package/dist/common/src/PM/node.js +1 -14
- package/dist/common/src/PM/nodeSidecar.js +0 -1
- package/dist/common/src/Pure.js +17 -1
- package/dist/common/src/Pure.test.js +172 -0
- package/dist/common/src/build.js +0 -1
- package/dist/common/src/esbuildConfigs/consoleDetectorPlugin.js +22 -11
- package/dist/common/src/esbuildConfigs/nativeImportDetectorPlugin.js +24 -0
- package/dist/common/src/esbuildConfigs/pure.js +2 -1
- package/dist/common/src/esbuildConfigs/rebuildPlugin.js +1 -4
- package/dist/common/src/lib/BaseSuite.js +89 -0
- package/dist/common/src/lib/BaseSuite.test/node.test.js +9 -0
- package/dist/common/src/lib/BaseSuite.test/pure.test.js +9 -0
- package/dist/common/src/lib/BaseSuite.test/test.js +232 -0
- package/dist/common/src/lib/BaseSuite.test/web.test.js +9 -0
- package/dist/common/src/lib/abstractBase.js +1 -90
- package/dist/common/src/lib/abstractBase.test/MockGiven.js +17 -0
- package/dist/common/src/lib/abstractBase.test/MockThen.js +13 -0
- package/dist/common/src/lib/abstractBase.test/MockWhen.js +13 -0
- package/dist/common/src/lib/abstractBase.test/implementation.js +42 -0
- package/dist/common/src/lib/abstractBase.test/index.js +17 -0
- package/dist/common/src/lib/abstractBase.test/interface.js +12 -0
- package/dist/common/src/lib/abstractBase.test/specification.js +19 -0
- package/dist/common/src/lib/abstractBase.test/types.js +2 -0
- package/dist/common/src/lib/baseBuilder.test/TestBaseBuilder.js +36 -0
- package/dist/common/src/lib/baseBuilder.test/baseBuilder.test.implementation.js +97 -0
- package/dist/common/src/lib/baseBuilder.test/baseBuilder.test.interface.js +17 -0
- package/dist/common/src/lib/baseBuilder.test/baseBuilder.test.node.js +11 -0
- package/dist/common/src/lib/baseBuilder.test/baseBuilder.test.pure.js +11 -0
- package/dist/common/src/lib/baseBuilder.test/baseBuilder.test.specification.js +13 -0
- package/dist/common/src/lib/baseBuilder.test/baseBuilder.test.types.js +2 -0
- package/dist/common/src/lib/baseBuilder.test/baseBuilder.test.web.js +11 -0
- package/dist/common/src/lib/basebuilder.js +2 -1
- package/dist/common/src/lib/classBuilder.test/TestClassBuilder.js +41 -0
- package/dist/common/src/lib/classBuilder.test/classBuilder.test.implementation.js +182 -0
- package/dist/common/src/lib/classBuilder.test/classBuilder.test.interface.js +17 -0
- package/dist/common/src/lib/classBuilder.test/classBuilder.test.js +11 -0
- package/dist/common/src/lib/classBuilder.test/classBuilder.test.specification.js +41 -0
- package/dist/common/src/lib/classBuilder.test/classBuilder.test.types.js +2 -0
- package/dist/common/src/lib/core.js +4 -13
- package/dist/common/src/lib/core.test/MockCore.js +25 -0
- package/dist/common/src/lib/core.test/core.test.implementation.js +102 -0
- package/dist/common/src/lib/core.test/core.test.interface.js +18 -0
- package/dist/common/src/lib/core.test/core.test.js +17 -0
- package/dist/common/src/lib/core.test/core.test.specification.js +33 -0
- package/dist/common/src/lib/core.test/core.test.types.js +2 -0
- package/dist/common/src/lib/pmProxy.js +9 -166
- package/dist/common/src/lib/pmProxy.test/implementation.js +76 -0
- package/dist/common/src/lib/pmProxy.test/index.js +15 -0
- package/dist/common/src/lib/pmProxy.test/interface.js +37 -0
- package/dist/common/src/lib/pmProxy.test/mockPM.js +34 -0
- package/dist/common/src/lib/pmProxy.test/mockPMBase.js +115 -0
- package/dist/common/src/lib/pmProxy.test/specification.js +39 -0
- package/dist/common/src/lib/pmProxy.test/types.js +2 -0
- package/dist/common/src/run.js +6 -6
- package/dist/common/testeranto.config.js +33 -18
- package/dist/common/tsconfig.common.tsbuildinfo +1 -1
- package/dist/module/src/Node.js +9 -6
- package/dist/module/src/PM/PM_WithEslintAndTsc.js +75 -58
- package/dist/module/src/PM/main.js +131 -79
- package/dist/module/src/PM/node.js +1 -14
- package/dist/module/src/PM/nodeSidecar.js +0 -1
- package/dist/module/src/Pure.js +17 -1
- package/dist/module/src/Pure.test.js +167 -0
- package/dist/module/src/build.js +0 -1
- package/dist/module/src/esbuildConfigs/consoleDetectorPlugin.js +19 -11
- package/dist/module/src/esbuildConfigs/nativeImportDetectorPlugin.js +21 -0
- package/dist/module/src/esbuildConfigs/pure.js +2 -1
- package/dist/module/src/esbuildConfigs/rebuildPlugin.js +1 -4
- package/dist/module/src/lib/BaseSuite.js +85 -0
- package/dist/module/src/lib/BaseSuite.test/node.test.js +4 -0
- package/dist/module/src/lib/BaseSuite.test/pure.test.js +4 -0
- package/dist/module/src/lib/BaseSuite.test/test.js +227 -0
- package/dist/module/src/lib/BaseSuite.test/web.test.js +4 -0
- package/dist/module/src/lib/abstractBase.js +1 -89
- package/dist/module/src/lib/abstractBase.test/MockGiven.js +13 -0
- package/dist/module/src/lib/abstractBase.test/MockThen.js +9 -0
- package/dist/module/src/lib/abstractBase.test/MockWhen.js +9 -0
- package/dist/module/src/lib/abstractBase.test/implementation.js +39 -0
- package/dist/module/src/lib/abstractBase.test/index.js +12 -0
- package/dist/module/src/lib/abstractBase.test/interface.js +9 -0
- package/dist/module/src/lib/abstractBase.test/specification.js +15 -0
- package/dist/module/src/lib/abstractBase.test/types.js +1 -0
- package/dist/module/src/lib/baseBuilder.test/TestBaseBuilder.js +32 -0
- package/dist/module/src/lib/baseBuilder.test/baseBuilder.test.implementation.js +94 -0
- package/dist/module/src/lib/baseBuilder.test/baseBuilder.test.interface.js +14 -0
- package/dist/module/src/lib/baseBuilder.test/baseBuilder.test.node.js +6 -0
- package/dist/module/src/lib/baseBuilder.test/baseBuilder.test.pure.js +6 -0
- package/dist/module/src/lib/baseBuilder.test/baseBuilder.test.specification.js +9 -0
- package/dist/module/src/lib/baseBuilder.test/baseBuilder.test.types.js +1 -0
- package/dist/module/src/lib/baseBuilder.test/baseBuilder.test.web.js +6 -0
- package/dist/module/src/lib/basebuilder.js +2 -1
- package/dist/module/src/lib/classBuilder.test/TestClassBuilder.js +37 -0
- package/dist/module/src/lib/classBuilder.test/classBuilder.test.implementation.js +179 -0
- package/dist/module/src/lib/classBuilder.test/classBuilder.test.interface.js +14 -0
- package/dist/module/src/lib/classBuilder.test/classBuilder.test.js +6 -0
- package/dist/module/src/lib/classBuilder.test/classBuilder.test.specification.js +37 -0
- package/dist/module/src/lib/classBuilder.test/classBuilder.test.types.js +1 -0
- package/dist/module/src/lib/core.js +3 -12
- package/dist/module/src/lib/core.test/MockCore.js +18 -0
- package/dist/module/src/lib/core.test/core.test.implementation.js +99 -0
- package/dist/module/src/lib/core.test/core.test.interface.js +15 -0
- package/dist/module/src/lib/core.test/core.test.js +12 -0
- package/dist/module/src/lib/core.test/core.test.specification.js +29 -0
- package/dist/module/src/lib/core.test/core.test.types.js +1 -0
- package/dist/module/src/lib/pmProxy.js +9 -166
- package/dist/module/src/lib/pmProxy.test/implementation.js +73 -0
- package/dist/module/src/lib/pmProxy.test/index.js +10 -0
- package/dist/module/src/lib/pmProxy.test/interface.js +34 -0
- package/dist/module/src/lib/pmProxy.test/mockPM.js +30 -0
- package/dist/module/src/lib/pmProxy.test/mockPMBase.js +111 -0
- package/dist/module/src/lib/pmProxy.test/specification.js +35 -0
- package/dist/module/src/lib/pmProxy.test/types.js +1 -0
- package/dist/module/src/run.js +6 -6
- package/dist/module/testeranto.config.js +33 -18
- package/dist/module/tsconfig.module.tsbuildinfo +1 -1
- package/dist/prebuild/Project.js +16 -15
- package/dist/prebuild/TestReport.js +14 -12
- package/dist/prebuild/build.mjs +34 -34
- package/dist/prebuild/run.mjs +259 -173
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/src/PM/PM_WithEslintAndTsc.d.ts +2 -1
- package/dist/types/src/PM/main.d.ts +5 -2
- package/dist/types/src/Pure.d.ts +2 -2
- package/dist/types/src/Pure.test.d.ts +36 -0
- package/dist/types/src/Types.d.ts +7 -6
- package/dist/types/src/Web.d.ts +1 -1
- package/dist/types/src/esbuildConfigs/consoleDetectorPlugin.d.ts +1 -1
- package/dist/types/src/esbuildConfigs/nativeImportDetectorPlugin.d.ts +2 -0
- package/dist/types/src/lib/BaseSuite.d.ts +39 -0
- package/dist/types/src/lib/BaseSuite.test/node.test.d.ts +3 -0
- package/dist/types/src/lib/BaseSuite.test/pure.test.d.ts +3 -0
- package/dist/types/src/lib/BaseSuite.test/test.d.ts +42 -0
- package/dist/types/src/lib/BaseSuite.test/web.test.d.ts +3 -0
- package/dist/types/src/lib/abstractBase.d.ts +1 -36
- package/dist/types/src/lib/abstractBase.test/MockGiven.d.ts +7 -0
- package/dist/types/src/lib/abstractBase.test/MockThen.d.ts +6 -0
- package/dist/types/src/lib/abstractBase.test/MockWhen.d.ts +6 -0
- package/dist/types/src/lib/abstractBase.test/implementation.d.ts +3 -0
- package/dist/types/src/lib/abstractBase.test/index.d.ts +3 -0
- package/dist/types/src/lib/abstractBase.test/interface.d.ts +3 -0
- package/dist/types/src/lib/abstractBase.test/specification.d.ts +3 -0
- package/dist/types/src/lib/abstractBase.test/types.d.ts +39 -0
- package/dist/types/src/lib/baseBuilder.test/TestBaseBuilder.d.ts +15 -0
- package/dist/types/src/lib/baseBuilder.test/baseBuilder.test.implementation.d.ts +3 -0
- package/dist/types/src/lib/baseBuilder.test/baseBuilder.test.interface.d.ts +3 -0
- package/dist/types/src/lib/baseBuilder.test/baseBuilder.test.node.d.ts +3 -0
- package/dist/types/src/lib/baseBuilder.test/baseBuilder.test.pure.d.ts +3 -0
- package/dist/types/src/lib/baseBuilder.test/baseBuilder.test.specification.d.ts +3 -0
- package/dist/types/src/lib/baseBuilder.test/baseBuilder.test.types.d.ts +20 -0
- package/dist/types/src/lib/baseBuilder.test/baseBuilder.test.web.d.ts +3 -0
- package/dist/types/src/lib/classBuilder.test/TestClassBuilder.d.ts +21 -0
- package/dist/types/src/lib/classBuilder.test/classBuilder.test.d.ts +3 -0
- package/dist/types/src/lib/classBuilder.test/classBuilder.test.implementation.d.ts +3 -0
- package/dist/types/src/lib/classBuilder.test/classBuilder.test.interface.d.ts +3 -0
- package/dist/types/src/lib/classBuilder.test/classBuilder.test.specification.d.ts +3 -0
- package/dist/types/src/lib/classBuilder.test/classBuilder.test.types.d.ts +56 -0
- package/dist/types/src/lib/core.d.ts +1 -1
- package/dist/types/src/lib/core.test/MockCore.d.ts +10 -0
- package/dist/types/src/lib/core.test/core.test.d.ts +3 -0
- package/dist/types/src/lib/core.test/core.test.implementation.d.ts +3 -0
- package/dist/types/src/lib/core.test/core.test.interface.d.ts +3 -0
- package/dist/types/src/lib/core.test/core.test.specification.d.ts +3 -0
- package/dist/types/src/lib/core.test/core.test.types.d.ts +46 -0
- package/dist/types/src/lib/index.d.ts +2 -1
- package/dist/types/src/lib/pmProxy.d.ts +11 -6
- package/dist/types/src/lib/pmProxy.test/implementation.d.ts +3 -0
- package/dist/types/src/lib/pmProxy.test/index.d.ts +7 -0
- package/dist/types/src/lib/pmProxy.test/interface.d.ts +3 -0
- package/dist/types/src/lib/pmProxy.test/mockPM.d.ts +10 -0
- package/dist/types/src/lib/pmProxy.test/mockPMBase.d.ts +39 -0
- package/dist/types/src/lib/pmProxy.test/specification.d.ts +3 -0
- package/dist/types/src/lib/pmProxy.test/types.d.ts +42 -0
- package/dist/types/src/lib/types.d.ts +2 -1
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/docs.html +35 -33
- package/index.html +23 -30
- package/package.json +3 -2
- package/testeranto/index.html +1 -1
- package/testeranto/reports/allTests/index.html +1 -1
- package/testeranto/reports/allTests/src/Pure.test/pure/index.html +1 -1
- package/testeranto/reports/allTests/src/Pure.test/pure/logs.txt +2 -2
- package/testeranto/reports/allTests/src/lib/BaseSuite.test/node.test/node/index.html +1 -1
- package/testeranto/reports/allTests/src/lib/BaseSuite.test/pure.test/pure/index.html +1 -1
- package/testeranto/reports/allTests/src/lib/BaseSuite.test/pure.test/pure/logs.txt +2 -2
- package/testeranto/reports/allTests/src/lib/BaseSuite.test/web.test/web/index.html +1 -1
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.node/node/index.html +1 -1
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.pure/pure/index.html +1 -1
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.web/web/index.html +1 -1
- package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/index.html +1 -1
- package/testeranto/reports/allTests/src/lib/core.test/core.test/node/index.html +1 -1
- package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/index.html +1 -1
- package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/logs.txt +3 -3
- package/testeranto.config.ts +1 -1
- package/tsc.log +36 -38
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const Pure_1 = __importDefault(require("./Pure"));
|
|
7
|
+
const mockPMBase_1 = require("./lib/pmProxy.test/mockPMBase");
|
|
8
|
+
// Implementation for PureTesteranto tests
|
|
9
|
+
const implementation = {
|
|
10
|
+
suites: {
|
|
11
|
+
Default: "PureTesteranto Test Suite",
|
|
12
|
+
},
|
|
13
|
+
givens: {
|
|
14
|
+
Default: () => ({
|
|
15
|
+
pm: new mockPMBase_1.MockPMBase(),
|
|
16
|
+
config: {},
|
|
17
|
+
proxies: {
|
|
18
|
+
butThenProxy: (pm, path) => (Object.assign(Object.assign({}, pm), { writeFileSync: (p, c) => pm.writeFileSync(`${path}/butThen/${p}`, c) })),
|
|
19
|
+
andWhenProxy: (pm, path) => (Object.assign(Object.assign({}, pm), { writeFileSync: (p, c) => pm.writeFileSync(`${path}/andWhen/${p}`, c) })),
|
|
20
|
+
beforeEachProxy: (pm, suite) => (Object.assign(Object.assign({}, pm), { writeFileSync: (p, c) => pm.writeFileSync(`suite-${suite}/beforeEach/${p}`, c) }))
|
|
21
|
+
}
|
|
22
|
+
}),
|
|
23
|
+
},
|
|
24
|
+
whens: {
|
|
25
|
+
applyProxy: (proxyType) => (store) => {
|
|
26
|
+
switch (proxyType) {
|
|
27
|
+
case "invalidConfig":
|
|
28
|
+
throw new Error("Invalid configuration");
|
|
29
|
+
case "missingProxy":
|
|
30
|
+
return Object.assign(Object.assign({}, store), { pm: {} }); // Break proxy chain
|
|
31
|
+
case "largePayload":
|
|
32
|
+
return Object.assign(Object.assign({}, store), { largePayload: true, pm: Object.assign(Object.assign({}, store.pm), { writeFileSync: (p, c) => {
|
|
33
|
+
if (c.length > 1e6) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
throw new Error("Payload too small");
|
|
37
|
+
} }) });
|
|
38
|
+
default:
|
|
39
|
+
return store;
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
thens: {
|
|
44
|
+
verifyProxy: (expectedPath) => (store) => {
|
|
45
|
+
var _a;
|
|
46
|
+
const testPath = "expected";
|
|
47
|
+
const result = store.pm.writeFileSync(testPath, "content");
|
|
48
|
+
const actualPath = (_a = store.pm.getLastCall("writeFileSync")) === null || _a === void 0 ? void 0 : _a.path;
|
|
49
|
+
if (actualPath !== expectedPath) {
|
|
50
|
+
throw new Error(`Expected path ${expectedPath}, got ${actualPath}`);
|
|
51
|
+
}
|
|
52
|
+
return store;
|
|
53
|
+
},
|
|
54
|
+
verifyNoProxy: () => (store) => {
|
|
55
|
+
if (store.pm.getCallCount("writeFileSync") > 0) {
|
|
56
|
+
throw new Error("Proxy was unexpectedly applied");
|
|
57
|
+
}
|
|
58
|
+
return store;
|
|
59
|
+
},
|
|
60
|
+
verifyError: (expectedError) => (store) => {
|
|
61
|
+
try {
|
|
62
|
+
store.pm.writeFileSync("test", "content");
|
|
63
|
+
throw new Error("Expected error but none was thrown");
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
if (!error.message.includes(expectedError)) {
|
|
67
|
+
throw new Error(`Expected error "${expectedError}", got "${error.message}"`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return store;
|
|
71
|
+
},
|
|
72
|
+
verifyResourceConfig: () => (store) => {
|
|
73
|
+
if (!store.pm.testResourceConfiguration) {
|
|
74
|
+
throw new Error("Missing test resource configuration");
|
|
75
|
+
}
|
|
76
|
+
return store;
|
|
77
|
+
},
|
|
78
|
+
verifyLargePayload: () => (store) => {
|
|
79
|
+
const largeContent = "x".repeat(2e6); // 2MB payload
|
|
80
|
+
const result = store.pm.writeFileSync("large.txt", largeContent);
|
|
81
|
+
if (!result) {
|
|
82
|
+
throw new Error("Failed to handle large payload");
|
|
83
|
+
}
|
|
84
|
+
return store;
|
|
85
|
+
},
|
|
86
|
+
verifyTypeSafety: () => (store) => {
|
|
87
|
+
// TypeScript will catch these at compile time
|
|
88
|
+
return store;
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
checks: {
|
|
92
|
+
Default: () => ({}),
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
// Specification for PureTesteranto tests
|
|
96
|
+
const specification = (Suite, Given, When, Then, Check) => [
|
|
97
|
+
Suite.Default("Core Functionality", {
|
|
98
|
+
initializationTest: Given.Default(["Should initialize with default configuration"], [], [Then.verifyNoProxy()]),
|
|
99
|
+
resourceConfigTest: Given.Default(["Should handle test resource configuration"], [When.applyProxy("resourceConfig")], [Then.verifyResourceConfig()]),
|
|
100
|
+
}),
|
|
101
|
+
Suite.Default("Proxy Integration", {
|
|
102
|
+
butThenProxyTest: Given.Default(["Should integrate with butThenProxy"], [When.applyProxy("butThenProxy")], [Then.verifyProxy("test/path/butThen/expected")]),
|
|
103
|
+
andWhenProxyTest: Given.Default(["Should integrate with andWhenProxy"], [When.applyProxy("andWhenProxy")], [Then.verifyProxy("test/path/andWhen/expected")]),
|
|
104
|
+
beforeEachProxyTest: Given.Default(["Should integrate with beforeEachProxy"], [When.applyProxy("beforeEachProxy")], [Then.verifyProxy("suite-1/beforeEach/expected")]),
|
|
105
|
+
}),
|
|
106
|
+
Suite.Default("Error Handling", {
|
|
107
|
+
invalidConfigTest: Given.Default(["Should handle invalid configuration"], [When.applyProxy("invalidConfig")], [Then.verifyError("Invalid configuration")]),
|
|
108
|
+
missingProxyTest: Given.Default(["Should handle missing proxy"], [When.applyProxy("missingProxy")], [Then.verifyError("Proxy not found")]),
|
|
109
|
+
}),
|
|
110
|
+
Suite.Default("Performance", {
|
|
111
|
+
multipleProxiesTest: Given.Default(["Should handle multiple proxies efficiently"], [
|
|
112
|
+
When.applyProxy("butThenProxy"),
|
|
113
|
+
When.applyProxy("andWhenProxy"),
|
|
114
|
+
When.applyProxy("beforeEachProxy")
|
|
115
|
+
], [
|
|
116
|
+
Then.verifyProxy("test/path/butThen/expected"),
|
|
117
|
+
Then.verifyProxy("test/path/andWhen/expected"),
|
|
118
|
+
Then.verifyProxy("suite-1/beforeEach/expected")
|
|
119
|
+
]),
|
|
120
|
+
largePayloadTest: Given.Default(["Should handle large payloads"], [When.applyProxy("largePayload")], [Then.verifyLargePayload()]),
|
|
121
|
+
}),
|
|
122
|
+
Suite.Default("Cross-Component Verification", {
|
|
123
|
+
proxyChainTest: Given.Default(["Proxies should chain correctly"], [
|
|
124
|
+
When.applyProxy("butThenProxy"),
|
|
125
|
+
When.applyProxy("andWhenProxy")
|
|
126
|
+
], [
|
|
127
|
+
Then.verifyProxy("test/path/andWhen/butThen/expected")
|
|
128
|
+
]),
|
|
129
|
+
errorPropagationTest: Given.Default(["Errors should propagate across components"], [When.applyProxy("invalidConfig")], [Then.verifyError("Invalid configuration")]),
|
|
130
|
+
resourceSharingTest: Given.Default(["Resources should be shared correctly"], [When.applyProxy("resourceConfig")], [Then.verifyResourceConfig()])
|
|
131
|
+
}),
|
|
132
|
+
Suite.Default("Type Safety", {
|
|
133
|
+
strictTypeTest: Given.Default(["Should enforce type safety"], [When.applyProxy("typeSafe")], [Then.verifyTypeSafety()]),
|
|
134
|
+
invalidTypeTest: Given.Default(["Should reject invalid types"], [When.applyProxy("invalidType")], [Then.verifyError("Type mismatch")]),
|
|
135
|
+
}),
|
|
136
|
+
Suite.Default("Integration Tests", {
|
|
137
|
+
// Verify builders work together
|
|
138
|
+
builderIntegration: Given.Default(["BaseBuilder and ClassBuilder should integrate properly"], [], [
|
|
139
|
+
Then.initializedProperly(),
|
|
140
|
+
Then.specsGenerated(),
|
|
141
|
+
Then.jobsCreated(),
|
|
142
|
+
Then.artifactsTracked()
|
|
143
|
+
]),
|
|
144
|
+
// Verify PM proxy integration
|
|
145
|
+
pmProxyIntegration: Given.Default(["PM proxies should work with test runners"], [When.applyProxy("butThenProxy")], [Then.verifyProxy("test/path/butThen/expected")]),
|
|
146
|
+
// Verify full test lifecycle
|
|
147
|
+
fullLifecycle: Given.Default(["Should complete full test lifecycle"], [
|
|
148
|
+
When.addArtifact(Promise.resolve("test")),
|
|
149
|
+
When.setTestJobs([]),
|
|
150
|
+
When.modifySpecs((specs) => [...specs])
|
|
151
|
+
], [
|
|
152
|
+
Then.testRunSuccessful(),
|
|
153
|
+
Then.artifactsTracked(),
|
|
154
|
+
Then.specsModified(0)
|
|
155
|
+
])
|
|
156
|
+
})
|
|
157
|
+
];
|
|
158
|
+
// Test interface for PureTesteranto
|
|
159
|
+
const testInterface = {
|
|
160
|
+
beforeEach: async (subject, initializer) => {
|
|
161
|
+
return { pm: initializer() };
|
|
162
|
+
},
|
|
163
|
+
andWhen: async (store, whenCB) => whenCB(store),
|
|
164
|
+
butThen: async (store, thenCB) => thenCB(store),
|
|
165
|
+
afterEach: async (store) => store,
|
|
166
|
+
afterAll: async () => { },
|
|
167
|
+
beforeAll: async (input, testResource) => ({}),
|
|
168
|
+
assertThis: (x) => x,
|
|
169
|
+
};
|
|
170
|
+
// Export the test suite
|
|
171
|
+
exports.default = (0, Pure_1.default)(null, // No initial input
|
|
172
|
+
specification, implementation, testInterface);
|
package/dist/common/src/build.js
CHANGED
|
@@ -189,7 +189,6 @@ Promise.resolve(`${process.cwd() + "/" + "testeranto.config.ts"}`).then(s => __i
|
|
|
189
189
|
// ],
|
|
190
190
|
];
|
|
191
191
|
x.forEach(async ([runtime, keys]) => {
|
|
192
|
-
console.log(runtime, keys);
|
|
193
192
|
keys.forEach(async (k) => {
|
|
194
193
|
const folder = `testeranto/reports/${testName}/${k
|
|
195
194
|
.split(".")
|
|
@@ -1,27 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.consoleDetectorPlugin = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
4
8
|
exports.consoleDetectorPlugin = {
|
|
5
|
-
name:
|
|
9
|
+
name: "console-detector",
|
|
6
10
|
setup(build) {
|
|
7
11
|
build.onLoad({ filter: /\.(js|ts)$/ }, async (args) => {
|
|
8
|
-
const contents = await
|
|
12
|
+
const contents = await fs_1.default.promises.readFile(args.path, "utf8");
|
|
9
13
|
const consolePattern = /console\.(log|error|warn|info|debug|trace|dir|dirxml|table|group|groupEnd|clear|count|countReset|assert|profile|profileEnd|time|timeLog|timeEnd|timeStamp|context|memory)/g;
|
|
10
14
|
const matches = contents.match(consolePattern);
|
|
11
15
|
if (matches) {
|
|
12
16
|
const uniqueMethods = [...new Set(matches)];
|
|
13
17
|
return {
|
|
14
|
-
warnings: uniqueMethods.map(method => ({
|
|
15
|
-
text: `
|
|
16
|
-
location: {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
warnings: uniqueMethods.map((method) => ({
|
|
19
|
+
text: `call of "${method}" was detected, which is not supported in the pure runtime.`,
|
|
20
|
+
// location: {
|
|
21
|
+
// file: args.path,
|
|
22
|
+
// line:
|
|
23
|
+
// contents
|
|
24
|
+
// .split("\n")
|
|
25
|
+
// .findIndex((line) => line.includes(method)) + 1,
|
|
26
|
+
// column: 0,
|
|
27
|
+
// },
|
|
28
|
+
})),
|
|
22
29
|
};
|
|
23
30
|
}
|
|
24
31
|
return null;
|
|
25
32
|
});
|
|
26
|
-
|
|
33
|
+
build.onEnd((buildResult) => {
|
|
34
|
+
if (buildResult.warnings.find((br) => br.pluginName === "console-detector"))
|
|
35
|
+
console.warn(`Warning: An unsupported method call was detected in a source file used to build for the pure runtime. It is possible that this method call is in a comment block. If you really want to use this function, change this test to the "node" runtime.`);
|
|
36
|
+
});
|
|
37
|
+
},
|
|
27
38
|
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.nativeImportDetectorPlugin = void 0;
|
|
4
|
+
const node_module_1 = require("node:module");
|
|
5
|
+
exports.nativeImportDetectorPlugin = {
|
|
6
|
+
name: "native-node-import-filter",
|
|
7
|
+
setup(build) {
|
|
8
|
+
build.onResolve({ filter: /fs/ }, (args) => {
|
|
9
|
+
if ((0, node_module_1.isBuiltin)(args.path)) {
|
|
10
|
+
return {
|
|
11
|
+
warnings: [
|
|
12
|
+
{
|
|
13
|
+
text: `cannot use native node package "${args.path}" in a "pure" test. If you really want to use this package, convert this test from "pure" to "node"`,
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
};
|
|
17
|
+
// throw new Error(
|
|
18
|
+
// `cannot use native node package "${args.path}" in a "pure" test. If you really want to use this package, convert this test from "pure" to "node"`
|
|
19
|
+
// );
|
|
20
|
+
}
|
|
21
|
+
return { path: args.path };
|
|
22
|
+
});
|
|
23
|
+
},
|
|
24
|
+
};
|
|
@@ -23,12 +23,13 @@ exports.default = (config, entryPoints, testName) => {
|
|
|
23
23
|
featuresPlugin_js_1.default,
|
|
24
24
|
inputFilesPluginFactory,
|
|
25
25
|
consoleDetectorPlugin_js_1.consoleDetectorPlugin,
|
|
26
|
+
// nativeImportDetectorPlugin,
|
|
26
27
|
{
|
|
27
28
|
name: "native-node-import-filter",
|
|
28
29
|
setup(build) {
|
|
29
30
|
build.onResolve({ filter: /fs/ }, (args) => {
|
|
30
31
|
if ((0, node_module_1.isBuiltin)(args.path)) {
|
|
31
|
-
throw new Error(`
|
|
32
|
+
throw new Error(`You attempted to import a node module "${args.path}" into a "pure" test, which is not allowed. If you really want to use this package, convert this test from "pure" to "node"`);
|
|
32
33
|
}
|
|
33
34
|
return { path: args.path };
|
|
34
35
|
});
|
|
@@ -8,11 +8,8 @@ exports.default = (r) => {
|
|
|
8
8
|
return {
|
|
9
9
|
name: "rebuild-notify",
|
|
10
10
|
setup: (build) => {
|
|
11
|
-
build.onStart(() => {
|
|
12
|
-
console.log(`> web build starting...`);
|
|
13
|
-
});
|
|
14
11
|
build.onEnd((result) => {
|
|
15
|
-
console.log(
|
|
12
|
+
console.log(`${r} > build ended with ${result.errors.length} errors`);
|
|
16
13
|
if (result.errors.length > 0) {
|
|
17
14
|
fs_1.default.writeFileSync(`./testeranto/reports${r}_build_errors`, JSON.stringify(result, null, 2));
|
|
18
15
|
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseSuite = void 0;
|
|
4
|
+
const pmProxy_1 = require("./pmProxy");
|
|
5
|
+
class BaseSuite {
|
|
6
|
+
constructor(name, index, givens = {}, checks = []) {
|
|
7
|
+
this.name = name;
|
|
8
|
+
this.index = index;
|
|
9
|
+
this.givens = givens;
|
|
10
|
+
this.checks = checks;
|
|
11
|
+
this.fails = 0;
|
|
12
|
+
}
|
|
13
|
+
features() {
|
|
14
|
+
const features = Object.keys(this.givens)
|
|
15
|
+
.map((k) => this.givens[k].features)
|
|
16
|
+
.flat()
|
|
17
|
+
.filter((value, index, array) => {
|
|
18
|
+
return array.indexOf(value) === index;
|
|
19
|
+
});
|
|
20
|
+
return features || [];
|
|
21
|
+
}
|
|
22
|
+
toObj() {
|
|
23
|
+
const givens = Object.keys(this.givens).map((k) => this.givens[k].toObj());
|
|
24
|
+
const checks = Object.keys(this.checks).map((k) => this.checks[k].toObj());
|
|
25
|
+
return {
|
|
26
|
+
name: this.name,
|
|
27
|
+
givens,
|
|
28
|
+
checks,
|
|
29
|
+
fails: this.fails,
|
|
30
|
+
failed: this.failed,
|
|
31
|
+
features: this.features(),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
setup(s, artifactory, tr, pm) {
|
|
35
|
+
return new Promise((res) => res(s));
|
|
36
|
+
}
|
|
37
|
+
assertThat(t) {
|
|
38
|
+
return !!t;
|
|
39
|
+
}
|
|
40
|
+
afterAll(store, artifactory, pm) {
|
|
41
|
+
return store;
|
|
42
|
+
}
|
|
43
|
+
async run(input, testResourceConfiguration, artifactory, tLog, pm) {
|
|
44
|
+
this.testResourceConfiguration = testResourceConfiguration;
|
|
45
|
+
// tLog("test resources: ", JSON.stringify(testResourceConfiguration));
|
|
46
|
+
const suiteArtifactory = (fPath, value) => artifactory(`suite-${this.index}-${this.name}/${fPath}`, value);
|
|
47
|
+
// console.log("\nSuite:", this.index, this.name);
|
|
48
|
+
tLog("\nSuite:", this.index, this.name);
|
|
49
|
+
const sNdx = this.index;
|
|
50
|
+
// const sName = this.name;
|
|
51
|
+
const subject = await this.setup(input, suiteArtifactory, testResourceConfiguration, (0, pmProxy_1.beforeAllProxy)(pm, sNdx.toString()));
|
|
52
|
+
for (const [gKey, g] of Object.entries(this.givens)) {
|
|
53
|
+
const giver = this.givens[gKey];
|
|
54
|
+
this.store = await giver
|
|
55
|
+
.give(subject, gKey, testResourceConfiguration, this.assertThat, suiteArtifactory, tLog, pm, sNdx)
|
|
56
|
+
.catch((e) => {
|
|
57
|
+
this.failed = true;
|
|
58
|
+
this.fails = this.fails + 1;
|
|
59
|
+
console.error("Given error 1:", e);
|
|
60
|
+
throw e;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
for (const [ndx, thater] of this.checks.entries()) {
|
|
64
|
+
await thater.check(subject, thater.name, testResourceConfiguration, this.assertThat, suiteArtifactory, tLog, pm);
|
|
65
|
+
}
|
|
66
|
+
try {
|
|
67
|
+
this.afterAll(this.store, artifactory, (0, pmProxy_1.afterAllProxy)(pm, sNdx.toString()));
|
|
68
|
+
}
|
|
69
|
+
catch (e) {
|
|
70
|
+
console.error(e);
|
|
71
|
+
// this.fails.push(this);
|
|
72
|
+
// return this;
|
|
73
|
+
}
|
|
74
|
+
// @TODO fix me
|
|
75
|
+
// for (const k of Object.keys(this.givens)) {
|
|
76
|
+
// const giver = this.givens[k];
|
|
77
|
+
// try {
|
|
78
|
+
// giver.afterAll(this.store, artifactory, pm);
|
|
79
|
+
// } catch (e) {
|
|
80
|
+
// console.error(e);
|
|
81
|
+
// this.fails.push(giver);
|
|
82
|
+
// return this;
|
|
83
|
+
// }
|
|
84
|
+
// }
|
|
85
|
+
////////////////
|
|
86
|
+
return this;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.BaseSuite = BaseSuite;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const Node_1 = __importDefault(require("../../Node"));
|
|
7
|
+
const BaseSuite_1 = require("../BaseSuite");
|
|
8
|
+
const test_1 = require("./test");
|
|
9
|
+
exports.default = (0, Node_1.default)(BaseSuite_1.BaseSuite, test_1.specification, test_1.implementation, test_1.testInterface);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const Pure_1 = __importDefault(require("../../Pure"));
|
|
7
|
+
const BaseSuite_1 = require("../BaseSuite");
|
|
8
|
+
const test_1 = require("./test");
|
|
9
|
+
exports.default = (0, Pure_1.default)(BaseSuite_1.BaseSuite, test_1.specification, test_1.implementation, test_1.testInterface);
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.testInterface = exports.implementation = exports.specification = exports.MockGiven = void 0;
|
|
4
|
+
const abstractBase_1 = require("../abstractBase");
|
|
5
|
+
const BaseSuite_1 = require("../BaseSuite");
|
|
6
|
+
// 2. Mock implementations with proper typing
|
|
7
|
+
class MockGiven extends abstractBase_1.BaseGiven {
|
|
8
|
+
constructor(name, features, whens, thens) {
|
|
9
|
+
super(name, features, whens, thens, async () => ({ testStore: true }), // givenCB
|
|
10
|
+
{} // initialValues
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
async givenThat(subject, testResourceConfiguration, artifactory, givenCB, initialValues, pm) {
|
|
14
|
+
return { testStore: true };
|
|
15
|
+
}
|
|
16
|
+
uberCatcher(e) {
|
|
17
|
+
console.error("Given error 2:", e);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.MockGiven = MockGiven;
|
|
21
|
+
class MockWhen extends abstractBase_1.BaseWhen {
|
|
22
|
+
async andWhen(store, whenCB, testResource, pm) {
|
|
23
|
+
return Object.assign(Object.assign({}, store), { testStore: true });
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
class MockThen extends abstractBase_1.BaseThen {
|
|
27
|
+
async butThen(store, thenCB, testResourceConfiguration, pm) {
|
|
28
|
+
return { testSelection: true };
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
class MockCheck extends abstractBase_1.BaseCheck {
|
|
32
|
+
async checkThat(subject, testResourceConfiguration, artifactory, initializer, initialValues, pm) {
|
|
33
|
+
return { testStore: true };
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
class TestableSuite extends BaseSuite_1.BaseSuite {
|
|
37
|
+
constructor(name, index) {
|
|
38
|
+
super(name, index, {
|
|
39
|
+
testGiven: new MockGiven("testGiven", ["testFeature"], [
|
|
40
|
+
new MockWhen("testWhen", () => Promise.resolve({ testStore: true })),
|
|
41
|
+
], [
|
|
42
|
+
new MockThen("testThen", async () => Promise.resolve({ testSelection: true })),
|
|
43
|
+
]),
|
|
44
|
+
}, [
|
|
45
|
+
new MockCheck("testCheck", ["testFeature"], () => Promise.resolve({ testStore: true }), null, () => { }),
|
|
46
|
+
]);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
// 3. Enhanced Test Specification with more test cases
|
|
50
|
+
const specification = (Suite, Given, When, Then, Check) => [
|
|
51
|
+
Suite.Default("BaseSuite Core Functionality Tests", {
|
|
52
|
+
// Test initialization and basic properties
|
|
53
|
+
initialization: Given.Default(["BaseSuite should initialize with correct name and index"], [], [
|
|
54
|
+
Then.SuiteNameMatches("testSuite"),
|
|
55
|
+
Then.SuiteIndexMatches(0),
|
|
56
|
+
Then.FeaturesIncludes("testFeature"),
|
|
57
|
+
]),
|
|
58
|
+
// Test execution flow
|
|
59
|
+
execution: Given.Default(["BaseSuite should execute all phases successfully"], [When.RunSuite()], [Then.StoreValid(), Then.NoErrorsOccurred(), Then.AllChecksCompleted()]),
|
|
60
|
+
// Test multiple features
|
|
61
|
+
multipleFeatures: Given.Default(["BaseSuite should handle multiple features"], [When.AddFeature("additionalFeature")], [
|
|
62
|
+
Then.FeaturesIncludes("testFeature"),
|
|
63
|
+
Then.FeaturesIncludes("additionalFeature"),
|
|
64
|
+
Then.FeatureCountMatches(2),
|
|
65
|
+
]),
|
|
66
|
+
// Test error handling
|
|
67
|
+
errorHandling: Given.Default(["BaseSuite should handle errors gracefully"], [When.RunSuiteWithError()], [
|
|
68
|
+
Then.ErrorCountMatches(1),
|
|
69
|
+
// Then.FailedFlagSet(),
|
|
70
|
+
]),
|
|
71
|
+
}, [
|
|
72
|
+
// Additional validation checks
|
|
73
|
+
// Check.Default(
|
|
74
|
+
// ["Verify suite state after all tests"],
|
|
75
|
+
// [],
|
|
76
|
+
// [
|
|
77
|
+
// Then.AllTestsCompleted(),
|
|
78
|
+
// Then.CleanExit()
|
|
79
|
+
// ]
|
|
80
|
+
// )
|
|
81
|
+
]),
|
|
82
|
+
Suite.Default("Comprehensive Integration", {
|
|
83
|
+
fullStackTest: Given.Default(["All components should work together"], [
|
|
84
|
+
When.addArtifact(Promise.resolve("test")),
|
|
85
|
+
When.modifySpecs((specs) => [...specs, "extra"]),
|
|
86
|
+
When.modifyJobs((jobs) => [...jobs, {}]),
|
|
87
|
+
], [
|
|
88
|
+
Then.specsModified(1),
|
|
89
|
+
Then.jobsModified(1),
|
|
90
|
+
Then.artifactsTracked(),
|
|
91
|
+
Then.testRunSuccessful(),
|
|
92
|
+
]),
|
|
93
|
+
}),
|
|
94
|
+
];
|
|
95
|
+
exports.specification = specification;
|
|
96
|
+
// 4. Enhanced Test Implementation with more operations
|
|
97
|
+
exports.implementation = {
|
|
98
|
+
suites: {
|
|
99
|
+
Default: "BaseSuite Comprehensive Test Suite",
|
|
100
|
+
},
|
|
101
|
+
givens: {
|
|
102
|
+
Default: () => new TestableSuite("testSuite", 0),
|
|
103
|
+
},
|
|
104
|
+
whens: {
|
|
105
|
+
RunSuite: () => async (suite) => {
|
|
106
|
+
const mockConfig = {
|
|
107
|
+
name: "test",
|
|
108
|
+
fs: "/tmp",
|
|
109
|
+
ports: [3000],
|
|
110
|
+
environment: {},
|
|
111
|
+
timeout: 5000,
|
|
112
|
+
retries: 3,
|
|
113
|
+
};
|
|
114
|
+
const mockArtifactory = (key, value) => { };
|
|
115
|
+
const mockTLog = (...args) => { };
|
|
116
|
+
const mockPM = {
|
|
117
|
+
server: null,
|
|
118
|
+
testResourceConfiguration: mockConfig,
|
|
119
|
+
start: async () => { },
|
|
120
|
+
stop: async () => { },
|
|
121
|
+
testArtiFactoryfileWriter: () => { },
|
|
122
|
+
$: () => { },
|
|
123
|
+
click: () => { },
|
|
124
|
+
closePage: () => { },
|
|
125
|
+
createWriteStream: async () => "",
|
|
126
|
+
};
|
|
127
|
+
return await suite.run(null, mockConfig, mockArtifactory, mockTLog, mockPM);
|
|
128
|
+
},
|
|
129
|
+
RunSuiteWithError: () => async (suite) => {
|
|
130
|
+
// Force an error by passing invalid config
|
|
131
|
+
try {
|
|
132
|
+
await suite.run(null, {}, // Invalid config
|
|
133
|
+
() => { }, () => { }, {});
|
|
134
|
+
}
|
|
135
|
+
catch (e) {
|
|
136
|
+
// Error is caught and counted by BaseSuite
|
|
137
|
+
}
|
|
138
|
+
return suite;
|
|
139
|
+
},
|
|
140
|
+
AddFeature: (feature) => (suite) => {
|
|
141
|
+
// Add a feature to the first given
|
|
142
|
+
const firstGivenKey = Object.keys(suite.givens)[0];
|
|
143
|
+
if (firstGivenKey) {
|
|
144
|
+
suite.givens[firstGivenKey].features.push(feature);
|
|
145
|
+
}
|
|
146
|
+
return suite;
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
thens: {
|
|
150
|
+
SuiteNameMatches: (expectedName) => (suite) => {
|
|
151
|
+
if (suite.name !== expectedName) {
|
|
152
|
+
throw new Error(`Expected suite name '${expectedName}', got '${suite.name}'`);
|
|
153
|
+
}
|
|
154
|
+
return suite;
|
|
155
|
+
},
|
|
156
|
+
SuiteIndexMatches: (expectedIndex) => (suite) => {
|
|
157
|
+
if (suite.index !== expectedIndex) {
|
|
158
|
+
throw new Error(`Expected suite index ${expectedIndex}, got ${suite.index}`);
|
|
159
|
+
}
|
|
160
|
+
return suite;
|
|
161
|
+
},
|
|
162
|
+
FeaturesIncludes: (feature) => (suite) => {
|
|
163
|
+
if (!suite.features().includes(feature)) {
|
|
164
|
+
throw new Error(`Expected features to include ${feature}`);
|
|
165
|
+
}
|
|
166
|
+
return suite;
|
|
167
|
+
},
|
|
168
|
+
FeatureCountMatches: (expectedCount) => (suite) => {
|
|
169
|
+
const actualCount = suite.features().length;
|
|
170
|
+
if (actualCount !== expectedCount) {
|
|
171
|
+
throw new Error(`Expected ${expectedCount} features, got ${actualCount}`);
|
|
172
|
+
}
|
|
173
|
+
return suite;
|
|
174
|
+
},
|
|
175
|
+
StoreValid: () => (suite) => {
|
|
176
|
+
var _a;
|
|
177
|
+
if (!((_a = suite.store) === null || _a === void 0 ? void 0 : _a.testStore)) {
|
|
178
|
+
throw new Error("Expected valid store after execution");
|
|
179
|
+
}
|
|
180
|
+
return suite;
|
|
181
|
+
},
|
|
182
|
+
NoErrorsOccurred: () => (suite) => {
|
|
183
|
+
if (suite.failed || suite.fails > 0) {
|
|
184
|
+
throw new Error("Expected no errors to occur during execution");
|
|
185
|
+
}
|
|
186
|
+
return suite;
|
|
187
|
+
},
|
|
188
|
+
ErrorCountMatches: (expectedCount) => (suite) => {
|
|
189
|
+
if (suite.fails !== expectedCount) {
|
|
190
|
+
throw new Error(`Expected ${expectedCount} errors, got ${suite.fails}`);
|
|
191
|
+
}
|
|
192
|
+
return suite;
|
|
193
|
+
},
|
|
194
|
+
FailedFlagSet: () => (suite) => {
|
|
195
|
+
if (!suite.failed) {
|
|
196
|
+
throw new Error("Expected failed flag to be set after error");
|
|
197
|
+
}
|
|
198
|
+
return suite;
|
|
199
|
+
},
|
|
200
|
+
AllChecksCompleted: () => (suite) => {
|
|
201
|
+
if (suite.checks.some((check) => !check.key)) {
|
|
202
|
+
throw new Error("Expected all checks to be completed");
|
|
203
|
+
}
|
|
204
|
+
return suite;
|
|
205
|
+
},
|
|
206
|
+
AllTestsCompleted: () => (suite) => {
|
|
207
|
+
if (!suite.store) {
|
|
208
|
+
throw new Error("Expected all tests to be completed");
|
|
209
|
+
}
|
|
210
|
+
return suite;
|
|
211
|
+
},
|
|
212
|
+
CleanExit: () => (suite) => {
|
|
213
|
+
if (suite.failed && suite.fails === 0) {
|
|
214
|
+
throw new Error("Expected clean exit state");
|
|
215
|
+
}
|
|
216
|
+
return suite;
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
checks: {
|
|
220
|
+
Default: () => new TestableSuite("testCheck", 1),
|
|
221
|
+
},
|
|
222
|
+
};
|
|
223
|
+
// 5. Fully typed Test Interface
|
|
224
|
+
exports.testInterface = {
|
|
225
|
+
beforeEach: async (subject, initializer) => initializer(),
|
|
226
|
+
andWhen: async (store, whenCB, testResource, pm) => whenCB(store, pm),
|
|
227
|
+
butThen: async (store, thenCB, testResource, pm) => thenCB(store, pm),
|
|
228
|
+
afterEach: (store) => store,
|
|
229
|
+
afterAll: (store, pm) => { },
|
|
230
|
+
assertThis: (result) => !!result,
|
|
231
|
+
beforeAll: async (input, testResource, pm) => input,
|
|
232
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const Web_1 = __importDefault(require("../../Web"));
|
|
7
|
+
const BaseSuite_1 = require("../BaseSuite");
|
|
8
|
+
const test_1 = require("./test");
|
|
9
|
+
exports.default = (0, Web_1.default)(BaseSuite_1.BaseSuite, test_1.specification, test_1.implementation, test_1.testInterface);
|