testeranto.tiposkripto 0.1.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.
Files changed (56) hide show
  1. package/dist/common/Types.js +2 -0
  2. package/dist/common/lib/tiposkripto/src/BaseGiven.js +96 -0
  3. package/dist/common/lib/tiposkripto/src/BaseSuite.js +134 -0
  4. package/dist/common/lib/tiposkripto/src/BaseThen.js +65 -0
  5. package/dist/common/lib/tiposkripto/src/BaseTiposkripto.js +192 -0
  6. package/dist/common/lib/tiposkripto/src/BaseWhen.js +46 -0
  7. package/dist/common/lib/tiposkripto/src/CoreTypes.js +2 -0
  8. package/dist/common/lib/tiposkripto/src/Node.js +37 -0
  9. package/dist/common/lib/tiposkripto/src/Web.js +62 -0
  10. package/dist/common/lib/tiposkripto/src/index.js +86 -0
  11. package/dist/common/lib/tiposkripto/src/types.js +6 -0
  12. package/dist/common/lib/tiposkripto/tests/abstractBase.test/MockGiven.js +22 -0
  13. package/dist/common/lib/tiposkripto/tests/abstractBase.test/MockThen.js +16 -0
  14. package/dist/common/lib/tiposkripto/tests/abstractBase.test/MockWhen.js +18 -0
  15. package/dist/common/lib/tiposkripto/tests/abstractBase.test/adapter.js +24 -0
  16. package/dist/common/lib/tiposkripto/tests/abstractBase.test/implementation.js +38 -0
  17. package/dist/common/lib/tiposkripto/tests/abstractBase.test/index.js +17 -0
  18. package/dist/common/lib/tiposkripto/tests/abstractBase.test/specification.js +19 -0
  19. package/dist/common/lib/tiposkripto/tests/abstractBase.test/types.js +2 -0
  20. package/dist/common/package.json +3 -0
  21. package/dist/common/tsconfig.common.tsbuildinfo +1 -0
  22. package/dist/module/Types.js +1 -0
  23. package/dist/module/index.js +689 -0
  24. package/dist/module/lib/tiposkripto/src/BaseGiven.js +92 -0
  25. package/dist/module/lib/tiposkripto/src/BaseSuite.js +130 -0
  26. package/dist/module/lib/tiposkripto/src/BaseThen.js +61 -0
  27. package/dist/module/lib/tiposkripto/src/BaseTiposkripto.js +189 -0
  28. package/dist/module/lib/tiposkripto/src/BaseWhen.js +42 -0
  29. package/dist/module/lib/tiposkripto/src/CoreTypes.js +1 -0
  30. package/dist/module/lib/tiposkripto/src/Node.js +30 -0
  31. package/dist/module/lib/tiposkripto/src/Web.js +55 -0
  32. package/dist/module/lib/tiposkripto/src/index.js +48 -0
  33. package/dist/module/lib/tiposkripto/src/types.js +3 -0
  34. package/dist/module/lib/tiposkripto/tests/abstractBase.test/MockGiven.js +18 -0
  35. package/dist/module/lib/tiposkripto/tests/abstractBase.test/MockThen.js +12 -0
  36. package/dist/module/lib/tiposkripto/tests/abstractBase.test/MockWhen.js +14 -0
  37. package/dist/module/lib/tiposkripto/tests/abstractBase.test/adapter.js +21 -0
  38. package/dist/module/lib/tiposkripto/tests/abstractBase.test/implementation.js +35 -0
  39. package/dist/module/lib/tiposkripto/tests/abstractBase.test/index.js +12 -0
  40. package/dist/module/lib/tiposkripto/tests/abstractBase.test/specification.js +15 -0
  41. package/dist/module/lib/tiposkripto/tests/abstractBase.test/types.js +1 -0
  42. package/dist/module/package.json +3 -0
  43. package/dist/module/tsconfig.module.tsbuildinfo +1 -0
  44. package/dist/types/Types.d.ts +68 -0
  45. package/dist/types/lib/tiposkripto/src/BaseGiven.d.ts +42 -0
  46. package/dist/types/lib/tiposkripto/src/BaseSuite.d.ts +46 -0
  47. package/dist/types/lib/tiposkripto/src/BaseThen.d.ts +28 -0
  48. package/dist/types/lib/tiposkripto/src/BaseTiposkripto.d.ts +36 -0
  49. package/dist/types/lib/tiposkripto/src/BaseWhen.d.ts +27 -0
  50. package/dist/types/lib/tiposkripto/src/CoreTypes.d.ts +55 -0
  51. package/dist/types/lib/tiposkripto/src/Node.d.ts +9 -0
  52. package/dist/types/lib/tiposkripto/src/Web.d.ts +9 -0
  53. package/dist/types/lib/tiposkripto/src/index.d.ts +8 -0
  54. package/dist/types/lib/tiposkripto/src/types.d.ts +60 -0
  55. package/dist/types/tsconfig.types.tsbuildinfo +1 -0
  56. package/package.json +39 -0
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseGiven = void 0;
4
+ class BaseGiven {
5
+ addArtifact(path) {
6
+ if (typeof path !== "string") {
7
+ throw new Error(`[ARTIFACT ERROR] Expected string, got ${typeof path}: ${JSON.stringify(path)}`);
8
+ }
9
+ const normalizedPath = path.replace(/\\/g, "/"); // Normalize path separators
10
+ this.artifacts.push(normalizedPath);
11
+ }
12
+ constructor(features, whens, thens, givenCB, initialValues) {
13
+ this.artifacts = [];
14
+ this.features = features;
15
+ this.whens = whens;
16
+ this.thens = thens;
17
+ this.givenCB = givenCB;
18
+ this.initialValues = initialValues;
19
+ this.fails = 0; // Initialize fail count
20
+ }
21
+ beforeAll(store) {
22
+ return store;
23
+ }
24
+ toObj() {
25
+ return {
26
+ key: this.key,
27
+ whens: (this.whens || []).map((w) => {
28
+ if (w && w.toObj)
29
+ return w.toObj();
30
+ console.error("When step is not as expected!", JSON.stringify(w));
31
+ return {};
32
+ }),
33
+ thens: (this.thens || []).map((t) => (t && t.toObj ? t.toObj() : {})),
34
+ error: this.error ? [this.error, this.error.stack] : null,
35
+ failed: this.failed,
36
+ features: this.features || [],
37
+ artifacts: this.artifacts,
38
+ status: this.status,
39
+ };
40
+ }
41
+ async afterEach(store, key, artifactory) {
42
+ return store;
43
+ }
44
+ async give(subject, key, testResourceConfiguration, tester, artifactory, suiteNdx) {
45
+ this.key = key;
46
+ this.fails = 0; // Initialize fail count for this given
47
+ const givenArtifactory = (fPath, value) => artifactory(`given-${key}/${fPath}`, value);
48
+ try {
49
+ // Ensure addArtifact is properly bound to 'this'
50
+ const addArtifact = this.addArtifact.bind(this);
51
+ this.store = await this.givenThat(subject, testResourceConfiguration, givenArtifactory, this.givenCB, this.initialValues);
52
+ this.status = true;
53
+ }
54
+ catch (e) {
55
+ this.status = false;
56
+ this.failed = true;
57
+ this.fails++; // Increment fail count
58
+ this.error = e.stack;
59
+ }
60
+ try {
61
+ const whens = this.whens || [];
62
+ for (const [thenNdx, thenStep] of this.thens.entries()) {
63
+ try {
64
+ const t = await thenStep.test(this.store, testResourceConfiguration, `suite-${suiteNdx}/given-${key}/then-${thenNdx}`);
65
+ // If the test doesn't throw, it passed
66
+ tester(t);
67
+ }
68
+ catch (e) {
69
+ // Mark the given as failed if any then step fails
70
+ this.failed = true;
71
+ this.fails++; // Increment fail count
72
+ // Re-throw to propagate the error
73
+ throw e;
74
+ }
75
+ }
76
+ }
77
+ catch (e) {
78
+ this.error = e.stack;
79
+ this.failed = true;
80
+ }
81
+ finally {
82
+ try {
83
+ const addArtifact = this.addArtifact.bind(this);
84
+ await this.afterEach(this.store, this.key);
85
+ }
86
+ catch (e) {
87
+ this.failed = true;
88
+ this.fails++; // Increment fail count
89
+ throw e;
90
+ // this.error = e.message;
91
+ }
92
+ }
93
+ return this.store;
94
+ }
95
+ }
96
+ exports.BaseGiven = BaseGiven;
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseSuite = void 0;
4
+ class BaseSuite {
5
+ addArtifact(path) {
6
+ if (typeof path !== "string") {
7
+ throw new Error(`[ARTIFACT ERROR] Expected string, got ${typeof path}: ${JSON.stringify(path)}`);
8
+ }
9
+ const normalizedPath = path.replace(/\\/g, "/"); // Normalize path separators
10
+ this.artifacts.push(normalizedPath);
11
+ }
12
+ constructor(name, index, givens = {}) {
13
+ this.artifacts = [];
14
+ const suiteName = name || "testSuite"; // Ensure name is never undefined
15
+ if (!suiteName) {
16
+ throw new Error("BaseSuite requires a non-empty name");
17
+ }
18
+ this.name = suiteName;
19
+ this.index = index;
20
+ this.givens = givens;
21
+ this.fails = 0;
22
+ }
23
+ features() {
24
+ try {
25
+ const features = Object.keys(this.givens)
26
+ .map((k) => this.givens[k].features)
27
+ .flat()
28
+ .filter((value, index, array) => {
29
+ return array.indexOf(value) === index;
30
+ });
31
+ // Convert all features to strings
32
+ const stringFeatures = features.map((feature) => {
33
+ if (typeof feature === "string") {
34
+ return feature;
35
+ }
36
+ else if (feature && typeof feature === "object") {
37
+ return feature.name || JSON.stringify(feature);
38
+ }
39
+ else {
40
+ return String(feature);
41
+ }
42
+ });
43
+ return stringFeatures || [];
44
+ }
45
+ catch (e) {
46
+ console.error("[ERROR] Failed to extract features:", JSON.stringify(e));
47
+ return [];
48
+ }
49
+ }
50
+ toObj() {
51
+ const givens = Object.keys(this.givens).map((k) => {
52
+ const givenObj = this.givens[k].toObj();
53
+ // Ensure given features are strings
54
+ // if (givenObj.features) {
55
+ // givenObj.features = givenObj.features.map(feature => {
56
+ // return feature;
57
+ // // if (typeof feature === 'string') {
58
+ // // return feature;
59
+ // // } else if (feature && typeof feature === 'object') {
60
+ // // return feature.name || JSON.stringify(feature);
61
+ // // } else {
62
+ // // return String(feature);
63
+ // // }
64
+ // });
65
+ // }
66
+ return givenObj;
67
+ });
68
+ return {
69
+ name: this.name,
70
+ givens,
71
+ fails: this.fails,
72
+ failed: this.failed,
73
+ features: this.features(),
74
+ artifacts: this.artifacts
75
+ ? this.artifacts.filter((art) => typeof art === "string")
76
+ : [],
77
+ };
78
+ }
79
+ setup(s, artifactory, tr
80
+ // pm: IPM
81
+ ) {
82
+ console.log("mark9");
83
+ return new Promise((res) => res(s));
84
+ }
85
+ assertThat(t) {
86
+ return !!t;
87
+ }
88
+ afterAll(store, artifactory) {
89
+ return store;
90
+ }
91
+ async run(input, testResourceConfiguration) {
92
+ this.testResourceConfiguration = testResourceConfiguration;
93
+ const sNdx = this.index;
94
+ const subject = await this.setup(input,
95
+ // suiteArtifactory,
96
+ testResourceConfiguration
97
+ // proxiedPm
98
+ );
99
+ for (const [gKey, g] of Object.entries(this.givens)) {
100
+ const giver = this.givens[gKey];
101
+ try {
102
+ this.store = await giver.give(subject, gKey, testResourceConfiguration, this.assertThat, sNdx);
103
+ // Add the number of failures from this given to the suite's total
104
+ this.fails += giver.fails || 0;
105
+ }
106
+ catch (e) {
107
+ this.failed = true;
108
+ // Add 1 to fails for the caught error
109
+ this.fails += 1;
110
+ // Also add any failures from the given itself
111
+ if (giver.fails) {
112
+ this.fails += giver.fails;
113
+ }
114
+ console.error(`Error in given ${gKey}:`, e);
115
+ // Don't re-throw to continue with other givens
116
+ }
117
+ }
118
+ // Mark the suite as failed if there are any failures
119
+ if (this.fails > 0) {
120
+ this.failed = true;
121
+ }
122
+ try {
123
+ // Ensure addArtifact is properly bound to 'this'
124
+ this.afterAll(this.store);
125
+ }
126
+ catch (e) {
127
+ console.error(JSON.stringify(e));
128
+ // this.fails.push(this);
129
+ // return this;
130
+ }
131
+ return this;
132
+ }
133
+ }
134
+ exports.BaseSuite = BaseSuite;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseThen = void 0;
4
+ class BaseThen {
5
+ constructor(name, thenCB) {
6
+ this.artifacts = [];
7
+ this.name = name;
8
+ this.thenCB = thenCB;
9
+ this.error = false;
10
+ this.artifacts = [];
11
+ }
12
+ addArtifact(path) {
13
+ if (typeof path !== "string") {
14
+ throw new Error(`[ARTIFACT ERROR] Expected string, got ${typeof path}: ${JSON.stringify(path)}`);
15
+ }
16
+ const normalizedPath = path.replace(/\\/g, "/"); // Normalize path separators
17
+ this.artifacts.push(normalizedPath);
18
+ }
19
+ toObj() {
20
+ const obj = {
21
+ name: this.name,
22
+ error: this.error,
23
+ artifacts: this.artifacts,
24
+ status: this.status,
25
+ };
26
+ return obj;
27
+ }
28
+ async test(store, testResourceConfiguration,
29
+ // tLog: ITLog,
30
+ // pm: IPM,
31
+ filepath) {
32
+ // Ensure addArtifact is properly bound to 'this'
33
+ const addArtifact = this.addArtifact.bind(this);
34
+ // const proxiedPm = butThenProxy(pm, filepath, addArtifact);
35
+ try {
36
+ const x = await this.butThen(store, async (s) => {
37
+ try {
38
+ if (typeof this.thenCB === "function") {
39
+ const result = await this.thenCB(s);
40
+ return result;
41
+ }
42
+ else {
43
+ return this.thenCB;
44
+ }
45
+ }
46
+ catch (e) {
47
+ // Mark this then step as failed
48
+ this.error = true;
49
+ // Re-throw to be caught by the outer catch block
50
+ throw e;
51
+ }
52
+ }, testResourceConfiguration
53
+ // proxiedPm
54
+ );
55
+ this.status = true;
56
+ return x;
57
+ }
58
+ catch (e) {
59
+ this.status = false;
60
+ this.error = true;
61
+ throw e;
62
+ }
63
+ }
64
+ }
65
+ exports.BaseThen = BaseThen;
@@ -0,0 +1,192 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const index_js_1 = require("./index.js");
4
+ const BaseGiven_1 = require("./BaseGiven");
5
+ const BaseSuite_1 = require("./BaseSuite");
6
+ const BaseThen_1 = require("./BaseThen");
7
+ const BaseWhen_1 = require("./BaseWhen");
8
+ const types_js_1 = require("./types.js");
9
+ class BaseTiposkripto {
10
+ constructor(webOrNode, input, testSpecification, testImplementation, testResourceRequirement = types_js_1.defaultTestResourceRequirement, testAdapter = {}, testResourceConfiguration, wsPort = "3456", wsHost = "localhost") {
11
+ this.totalTests = 0;
12
+ this.artifacts = [];
13
+ this.testResourceConfiguration = testResourceConfiguration;
14
+ const fullAdapter = (0, index_js_1.DefaultAdapter)(testAdapter);
15
+ if (!testImplementation.suites ||
16
+ typeof testImplementation.suites !== "object") {
17
+ throw new Error(`testImplementation.suites must be an object, got ${typeof testImplementation.suites}: ${JSON.stringify(testImplementation.suites)}`);
18
+ }
19
+ const classySuites = Object.entries(testImplementation.suites).reduce((a, [key], index) => {
20
+ a[key] = (somestring, givens) => {
21
+ return new (class extends BaseSuite_1.BaseSuite {
22
+ afterAll(store) {
23
+ return fullAdapter.afterAll(store);
24
+ }
25
+ assertThat(t) {
26
+ return fullAdapter.assertThis(t);
27
+ }
28
+ async setup(s, tr) {
29
+ var _a, _b;
30
+ return ((_b = (_a = fullAdapter.beforeAll) === null || _a === void 0 ? void 0 : _a.call(fullAdapter, s, tr)) !== null && _b !== void 0 ? _b : s);
31
+ }
32
+ })(somestring, index, givens);
33
+ };
34
+ return a;
35
+ }, {});
36
+ const classyGivens = Object.entries(testImplementation.givens).reduce((a, [key, g]) => {
37
+ a[key] = (features, whens, thens, gcb, initialValues) => {
38
+ // WTF
39
+ // Ensure parameters are arrays and create copies to avoid reference issues
40
+ const safeFeatures = Array.isArray(features) ? [...features] : [];
41
+ const safeWhens = Array.isArray(whens) ? [...whens] : [];
42
+ const safeThens = Array.isArray(thens) ? [...thens] : [];
43
+ return new (class extends BaseGiven_1.BaseGiven {
44
+ async givenThat(subject, testResource, initializer, initialValues) {
45
+ return fullAdapter.beforeEach(subject, initializer, testResource, initialValues);
46
+ }
47
+ afterEach(store, key) {
48
+ return Promise.resolve(fullAdapter.afterEach(store, key));
49
+ }
50
+ })(safeFeatures, safeWhens, safeThens, testImplementation.givens[key], initialValues);
51
+ };
52
+ return a;
53
+ }, {});
54
+ const classyWhens = Object.entries(testImplementation.whens).reduce((a, [key, whEn]) => {
55
+ a[key] = (...payload) => {
56
+ const whenInstance = new (class extends BaseWhen_1.BaseWhen {
57
+ async andWhen(store, whenCB, testResource) {
58
+ return await fullAdapter.andWhen(store, whenCB, testResource);
59
+ }
60
+ })(`${key}: ${payload && payload.toString()}`, whEn(...payload));
61
+ return whenInstance;
62
+ };
63
+ return a;
64
+ }, {});
65
+ const classyThens = Object.entries(testImplementation.thens).reduce((a, [key, thEn]) => {
66
+ a[key] = (...args) => {
67
+ const thenInstance = new (class extends BaseThen_1.BaseThen {
68
+ async butThen(store, thenCB, testResource) {
69
+ return await fullAdapter.butThen(store, thenCB, testResource);
70
+ }
71
+ })(`${key}: ${args && args.toString()}`, thEn(...args));
72
+ return thenInstance;
73
+ };
74
+ return a;
75
+ }, {});
76
+ this.suitesOverrides = classySuites;
77
+ this.givenOverrides = classyGivens;
78
+ this.whenOverrides = classyWhens;
79
+ this.thenOverrides = classyThens;
80
+ this.testResourceRequirement = testResourceRequirement;
81
+ this.testSpecification = testSpecification;
82
+ this.specs = testSpecification(this.Suites(), this.Given(), this.When(), this.Then());
83
+ this.totalTests = this.calculateTotalTests();
84
+ this.testJobs = this.specs.map((suite) => {
85
+ const suiteRunner = (suite) => async (testResourceConfiguration) => {
86
+ try {
87
+ const x = await suite.run(input, testResourceConfiguration || {
88
+ name: suite.name,
89
+ fs: process.cwd(),
90
+ ports: [],
91
+ timeout: 30000,
92
+ retries: 3,
93
+ environment: {},
94
+ files: []
95
+ });
96
+ return x;
97
+ }
98
+ catch (e) {
99
+ console.error(e.stack);
100
+ throw e;
101
+ }
102
+ };
103
+ const runner = suiteRunner(suite);
104
+ const totalTests = this.totalTests;
105
+ const testJob = {
106
+ test: suite,
107
+ toObj: () => {
108
+ return suite.toObj();
109
+ },
110
+ runner,
111
+ receiveTestResourceConfig: async (testResourceConfiguration) => {
112
+ try {
113
+ const suiteDone = await runner(testResourceConfiguration);
114
+ const fails = suiteDone.fails;
115
+ return {
116
+ failed: fails > 0,
117
+ fails,
118
+ artifacts: [], // this.artifacts is not accessible here
119
+ features: suiteDone.features(),
120
+ tests: 0,
121
+ runTimeTests: totalTests,
122
+ testJob: testJob.toObj(),
123
+ };
124
+ }
125
+ catch (e) {
126
+ console.error(e.stack);
127
+ return {
128
+ failed: true,
129
+ fails: -1,
130
+ artifacts: [],
131
+ features: [],
132
+ tests: 0,
133
+ runTimeTests: -1,
134
+ testJob: testJob.toObj(),
135
+ };
136
+ }
137
+ },
138
+ };
139
+ return testJob;
140
+ });
141
+ this.testJobs[0].receiveTestResourceConfig(testResourceConfiguration).then((results) => {
142
+ this.writeFileSync(`testeranto/reports/${this.testResourceConfiguration.fs}`, JSON.stringify(results));
143
+ });
144
+ }
145
+ async receiveTestResourceConfig(testResourceConfig) {
146
+ if (this.testJobs && this.testJobs.length > 0) {
147
+ return this.testJobs[0].receiveTestResourceConfig(testResourceConfig);
148
+ }
149
+ else {
150
+ throw new Error("No test jobs available");
151
+ }
152
+ }
153
+ Specs() {
154
+ return this.specs;
155
+ }
156
+ Suites() {
157
+ if (!this.suitesOverrides) {
158
+ throw new Error(`suitesOverrides is undefined. classySuites: ${JSON.stringify(Object.keys(this.suitesOverrides || {}))}`);
159
+ }
160
+ return this.suitesOverrides;
161
+ }
162
+ Given() {
163
+ return this.givenOverrides;
164
+ }
165
+ When() {
166
+ return this.whenOverrides;
167
+ }
168
+ Then() {
169
+ return this.thenOverrides;
170
+ }
171
+ // Add a method to access test jobs which can be used by receiveTestResourceConfig
172
+ getTestJobs() {
173
+ return this.testJobs;
174
+ }
175
+ calculateTotalTests() {
176
+ let total = 0;
177
+ for (const suite of this.specs) {
178
+ if (suite && typeof suite === "object") {
179
+ // Access the givens property which should be a record of test names to BaseGiven instances
180
+ // The givens property is typically on the suite instance
181
+ if ("givens" in suite) {
182
+ const givens = suite.givens;
183
+ if (givens && typeof givens === "object") {
184
+ total += Object.keys(givens).length;
185
+ }
186
+ }
187
+ }
188
+ }
189
+ return total;
190
+ }
191
+ }
192
+ exports.default = BaseTiposkripto;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseWhen = void 0;
4
+ class BaseWhen {
5
+ addArtifact(path) {
6
+ if (typeof path !== "string") {
7
+ throw new Error(`[ARTIFACT ERROR] Expected string, got ${typeof path}: ${JSON.stringify(path)}`);
8
+ }
9
+ const normalizedPath = path.replace(/\\/g, "/"); // Normalize path separators
10
+ this.artifacts.push(normalizedPath);
11
+ }
12
+ constructor(name, whenCB) {
13
+ this.artifacts = [];
14
+ this.name = name;
15
+ this.whenCB = whenCB;
16
+ }
17
+ toObj() {
18
+ const obj = {
19
+ name: this.name,
20
+ status: this.status,
21
+ error: this.error
22
+ ? `${this.error.name}: ${this.error.message}\n${this.error.stack}`
23
+ : null,
24
+ artifacts: this.artifacts,
25
+ };
26
+ return obj;
27
+ }
28
+ async test(store, testResourceConfiguration) {
29
+ try {
30
+ // Ensure addArtifact is properly bound to 'this'
31
+ // const addArtifact = this.addArtifact.bind(this);
32
+ // const proxiedPm = andWhenProxy(pm, filepath, addArtifact);
33
+ const result = await this.andWhen(store, this.whenCB, testResourceConfiguration
34
+ // proxiedPm
35
+ );
36
+ this.status = true;
37
+ return result;
38
+ }
39
+ catch (e) {
40
+ this.status = false;
41
+ this.error = e;
42
+ throw e;
43
+ }
44
+ }
45
+ }
46
+ exports.BaseWhen = BaseWhen;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,37 @@
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
+ exports.NodeTiposkripto = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const BaseTiposkripto_1 = __importDefault(require("./BaseTiposkripto"));
9
+ const types_1 = require("./types");
10
+ console.log(`[NodeTiposkripto] ${process.argv}`);
11
+ const config = process.argv0[2];
12
+ class NodeTiposkripto extends BaseTiposkripto_1.default {
13
+ constructor(input, testSpecification, testImplementation, testResourceRequirement, testAdapter) {
14
+ super("node", input, testSpecification, testImplementation, testResourceRequirement, testAdapter, config);
15
+ }
16
+ writeFileSync(filename, payload) {
17
+ // console.log('writeFileSync', filename)
18
+ // const dir = `testeranto/reports/${this.testResourceConfiguration.fs}`;
19
+ // if (!fs.existsSync(dir)) {
20
+ // fs.mkdirSync(dir, { recursive: true });
21
+ // }
22
+ fs_1.default.writeFileSync(filename, payload);
23
+ }
24
+ }
25
+ exports.NodeTiposkripto = NodeTiposkripto;
26
+ const tiposkripto = async (input, testSpecification, testImplementation, testAdapter, testResourceRequirement = types_1.defaultTestResourceRequirement) => {
27
+ try {
28
+ const t = new NodeTiposkripto(input, testSpecification, testImplementation, testResourceRequirement, testAdapter);
29
+ return t;
30
+ }
31
+ catch (e) {
32
+ console.error(`[Node] Error creating Tiposkripto:`, e);
33
+ console.error(e.stack);
34
+ process.exit(-1);
35
+ }
36
+ };
37
+ exports.default = tiposkripto;
@@ -0,0 +1,62 @@
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
+ exports.WebTiposkripto = void 0;
7
+ const BaseTiposkripto_js_1 = __importDefault(require("./BaseTiposkripto.js"));
8
+ const types_js_1 = require("./types.js");
9
+ const config = process.argv0[2];
10
+ class WebTiposkripto extends BaseTiposkripto_js_1.default {
11
+ constructor(input, testSpecification, testImplementation, testResourceRequirement, testAdapter) {
12
+ const urlParams = new URLSearchParams(window.location.search);
13
+ const encodedConfig = urlParams.get("config");
14
+ const testResourceConfig = encodedConfig
15
+ ? decodeURIComponent(encodedConfig)
16
+ : "{}";
17
+ super("web", input, testSpecification, testImplementation, testResourceRequirement, testAdapter,
18
+ // JSON.parse(testResourceConfig)
19
+ config);
20
+ }
21
+ writeFileSync(filename, payload) {
22
+ // Store files in a global object that can be accessed via Puppeteer
23
+ if (!window.__testeranto_files__) {
24
+ window.__testeranto_files__ = {};
25
+ }
26
+ window.__testeranto_files__[filename] = payload;
27
+ // Also try to use the File System Access API if available
28
+ if (navigator.storage && navigator.storage.getDirectory) {
29
+ (async () => {
30
+ try {
31
+ const root = await navigator.storage.getDirectory();
32
+ const fileHandle = await root.getFileHandle(filename, { create: true });
33
+ const writable = await fileHandle.createWritable();
34
+ await writable.write(payload);
35
+ await writable.close();
36
+ }
37
+ catch (e) {
38
+ console.warn('Could not write to browser storage:', e);
39
+ }
40
+ })();
41
+ }
42
+ }
43
+ }
44
+ exports.WebTiposkripto = WebTiposkripto;
45
+ const tiposkripto = async (input, testSpecification, testImplementation, testAdapter, testResourceRequirement = types_js_1.defaultTestResourceRequirement) => {
46
+ try {
47
+ const t = new WebTiposkripto(input, testSpecification, testImplementation, testResourceRequirement, testAdapter);
48
+ // const data = navigator.storage.
49
+ const root = await navigator.storage.getDirectory();
50
+ // 1. Create (or get) a file handle
51
+ const fileHandle = await root.getFileHandle(`${config.fs}/tests.json`);
52
+ return t;
53
+ }
54
+ catch (e) {
55
+ console.error(e);
56
+ // Dispatch an error event
57
+ const errorEvent = new CustomEvent("test-error", { detail: e });
58
+ window.dispatchEvent(errorEvent);
59
+ throw e;
60
+ }
61
+ };
62
+ exports.default = tiposkripto;