testeranto 0.146.2 → 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/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,37 @@
|
|
|
1
|
+
export const specification = (Suite, Given, When, Then, Check) => {
|
|
2
|
+
return [
|
|
3
|
+
Suite.Default("Basic ClassBuilder Functionality", {
|
|
4
|
+
// Basic initialization tests
|
|
5
|
+
initialization: Given.Default(["ClassBuilder should initialize with default values"], [], [Then.initializedProperly()]),
|
|
6
|
+
customInput: Given.WithCustomInput({ custom: "input" }, [], [Then.initializedProperly()]),
|
|
7
|
+
resourceRequirements: Given.WithResourceRequirements({ ports: [3000, 3001] }, [], [Then.resourceRequirementsSet()]),
|
|
8
|
+
// Core functionality tests
|
|
9
|
+
specGeneration: Given.Default(["Should generate specs from test specification"], [], [Then.specsGenerated()]),
|
|
10
|
+
jobCreation: Given.Default(["Should create test jobs from specs"], [], [Then.jobsCreated()]),
|
|
11
|
+
artifactTracking: Given.Default(["Should track artifacts"], [When.addArtifact(Promise.resolve("test"))], [Then.artifactsTracked()]),
|
|
12
|
+
// Configuration tests
|
|
13
|
+
overridesConfiguration: Given.Default(["Should properly configure all overrides"], [], [
|
|
14
|
+
Then.suitesOverridesConfigured(),
|
|
15
|
+
Then.givensOverridesConfigured(),
|
|
16
|
+
Then.whensOverridesConfigured(),
|
|
17
|
+
Then.thensOverridesConfigured(),
|
|
18
|
+
Then.checksOverridesConfigured(),
|
|
19
|
+
]),
|
|
20
|
+
}, []),
|
|
21
|
+
Suite.ExtendedSuite("Advanced ClassBuilder Functionality", {
|
|
22
|
+
// Custom implementations
|
|
23
|
+
customImplementation: Given.WithCustomImplementation(implementation, [], [Then.specsGenerated(), Then.jobsCreated()]),
|
|
24
|
+
customSpecification: Given.WithCustomSpecification(specification, [], [Then.specsGenerated(), Then.jobsCreated()]),
|
|
25
|
+
// Dynamic modification tests
|
|
26
|
+
modifySpecs: Given.Default(["Should allow modifying specs"], [When.modifySpecs((specs) => [...specs, "extra"])], [Then.specsModified(1)]),
|
|
27
|
+
modifyJobs: Given.Default(["Should allow modifying jobs"], [When.modifyJobs((jobs) => [...jobs, {}])], [Then.jobsModified(1)]),
|
|
28
|
+
// Error handling
|
|
29
|
+
errorHandling: Given.Default(["Should properly handle errors"], [When.triggerError("test error")], [Then.errorThrown("test error")]),
|
|
30
|
+
// Full test run
|
|
31
|
+
testRun: Given.Default(["Should complete a full test run successfully"], [], [Then.testRunSuccessful()]),
|
|
32
|
+
}, [
|
|
33
|
+
Check.ImplementationCheck((impl) => impl !== null),
|
|
34
|
+
Check.SpecificationCheck((spec) => spec !== null),
|
|
35
|
+
]),
|
|
36
|
+
];
|
|
37
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
3
|
import { DefaultTestInterface, defaultTestResourceRequirement, } from "./index.js";
|
|
4
|
-
import {
|
|
4
|
+
import { BaseGiven, BaseWhen, BaseThen, BaseCheck } from "./abstractBase.js";
|
|
5
5
|
import { ClassBuilder } from "./classBuilder.js";
|
|
6
|
-
|
|
6
|
+
import { BaseSuite } from "./BaseSuite.js";
|
|
7
|
+
export default class TesterantoCore extends ClassBuilder {
|
|
7
8
|
constructor(input, testSpecification, testImplementation, testResourceRequirement = defaultTestResourceRequirement, testInterface, uberCatcher) {
|
|
8
9
|
const fullTestInterface = DefaultTestInterface(testInterface);
|
|
9
10
|
super(testImplementation, testSpecification, input, class extends BaseSuite {
|
|
@@ -33,16 +34,6 @@ export default class Testeranto extends ClassBuilder {
|
|
|
33
34
|
}, class When extends BaseWhen {
|
|
34
35
|
async andWhen(store, whenCB, testResource, pm) {
|
|
35
36
|
return await fullTestInterface.andWhen(store, whenCB, testResource, pm);
|
|
36
|
-
// try {
|
|
37
|
-
// return await fullTestInterface.andWhen(
|
|
38
|
-
// store,
|
|
39
|
-
// whenCB,
|
|
40
|
-
// testResource,
|
|
41
|
-
// pm
|
|
42
|
-
// );
|
|
43
|
-
// } catch (e) {
|
|
44
|
-
// console.log("mark22", e);
|
|
45
|
-
// }
|
|
46
37
|
}
|
|
47
38
|
}, class Then extends BaseThen {
|
|
48
39
|
async butThen(store, thenCB, testResource, pm) {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import TesterantoCore from "../core";
|
|
2
|
+
/**
|
|
3
|
+
* Concrete implementation of Testeranto for testing purposes
|
|
4
|
+
*/
|
|
5
|
+
export class MockCore extends TesterantoCore {
|
|
6
|
+
constructor(input, testSpecification, testImplementation, testResourceRequirement = { ports: [] }, testInterface = {}, uberCatcher = (cb) => cb()) {
|
|
7
|
+
super(input, testSpecification, testImplementation, testResourceRequirement, testInterface, uberCatcher);
|
|
8
|
+
}
|
|
9
|
+
async receiveTestResourceConfig(partialTestResource) {
|
|
10
|
+
return {
|
|
11
|
+
failed: false,
|
|
12
|
+
fails: 0,
|
|
13
|
+
artifacts: [],
|
|
14
|
+
logPromise: Promise.resolve(),
|
|
15
|
+
features: [],
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { MockCore } from "./MockCore";
|
|
2
|
+
import { PassThrough } from "stream";
|
|
3
|
+
export const implementation = {
|
|
4
|
+
suites: {
|
|
5
|
+
Default: "Testeranto test suite",
|
|
6
|
+
ExtendedSuite: "Extended Testeranto test suite",
|
|
7
|
+
},
|
|
8
|
+
givens: {
|
|
9
|
+
Default: () => {
|
|
10
|
+
return new MockCore({}, // input
|
|
11
|
+
specification, // testSpecification
|
|
12
|
+
implementation, // testImplementation
|
|
13
|
+
{ ports: [] }, // testResourceRequirement
|
|
14
|
+
testInterface, // testInterface
|
|
15
|
+
(cb) => cb() // uberCatcher
|
|
16
|
+
);
|
|
17
|
+
},
|
|
18
|
+
WithCustomInput: (input) => {
|
|
19
|
+
return new MockCore(input, specification, implementation, { ports: [] }, testInterface, (cb) => cb());
|
|
20
|
+
},
|
|
21
|
+
WithResourceRequirements: (requirements) => {
|
|
22
|
+
return new MockCore({}, specification, implementation, requirements, testInterface, (cb) => cb());
|
|
23
|
+
},
|
|
24
|
+
WithCustomInterface: (customInterface) => {
|
|
25
|
+
return new MockCore({}, specification, implementation, { ports: [] }, Object.assign(Object.assign({}, testInterface), customInterface), (cb) => cb());
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
whens: {
|
|
29
|
+
addArtifact: (artifact) => (builder) => {
|
|
30
|
+
builder.artifacts.push(artifact);
|
|
31
|
+
return builder;
|
|
32
|
+
},
|
|
33
|
+
setTestJobs: (jobs) => (builder) => {
|
|
34
|
+
builder.testJobs = jobs;
|
|
35
|
+
return builder;
|
|
36
|
+
},
|
|
37
|
+
modifySpecs: (modifier) => (builder) => {
|
|
38
|
+
builder.specs = modifier(builder.specs || []);
|
|
39
|
+
return builder;
|
|
40
|
+
},
|
|
41
|
+
triggerError: (message) => (builder) => {
|
|
42
|
+
throw new Error(message);
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
thens: {
|
|
46
|
+
initializedProperly: () => (builder) => {
|
|
47
|
+
if (!(builder instanceof MockCore)) {
|
|
48
|
+
throw new Error("Builder was not properly initialized");
|
|
49
|
+
}
|
|
50
|
+
return builder;
|
|
51
|
+
},
|
|
52
|
+
specsGenerated: () => (builder) => {
|
|
53
|
+
if (!Array.isArray(builder.specs)) {
|
|
54
|
+
throw new Error("Specs were not generated");
|
|
55
|
+
}
|
|
56
|
+
return builder;
|
|
57
|
+
},
|
|
58
|
+
jobsCreated: () => (builder) => {
|
|
59
|
+
if (!Array.isArray(builder.testJobs)) {
|
|
60
|
+
throw new Error("Test jobs were not created");
|
|
61
|
+
}
|
|
62
|
+
return builder;
|
|
63
|
+
},
|
|
64
|
+
artifactsTracked: () => (builder) => {
|
|
65
|
+
if (!Array.isArray(builder.artifacts)) {
|
|
66
|
+
throw new Error("Artifacts array not initialized");
|
|
67
|
+
}
|
|
68
|
+
return builder;
|
|
69
|
+
},
|
|
70
|
+
resourceRequirementsSet: () => (builder) => {
|
|
71
|
+
if (!builder.testResourceRequirement) {
|
|
72
|
+
throw new Error("Resource requirements not set");
|
|
73
|
+
}
|
|
74
|
+
return builder;
|
|
75
|
+
},
|
|
76
|
+
interfaceConfigured: () => (builder) => {
|
|
77
|
+
if (!builder.testInterface) {
|
|
78
|
+
throw new Error("Test interface not configured");
|
|
79
|
+
}
|
|
80
|
+
return builder;
|
|
81
|
+
},
|
|
82
|
+
errorThrown: (expectedMessage) => (builder) => {
|
|
83
|
+
// Handled by test runner
|
|
84
|
+
return builder;
|
|
85
|
+
},
|
|
86
|
+
testRunSuccessful: () => async (builder) => {
|
|
87
|
+
try {
|
|
88
|
+
await builder.receiveTestResourceConfig("");
|
|
89
|
+
return builder;
|
|
90
|
+
}
|
|
91
|
+
catch (e) {
|
|
92
|
+
throw new Error(`Test run failed: ${e.message}`);
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
checks: {
|
|
97
|
+
Default: () => new PassThrough(),
|
|
98
|
+
},
|
|
99
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const testInterface = {
|
|
2
|
+
beforeEach: async (subject, initializer, testResource, initialValues, pm) => {
|
|
3
|
+
return initializer();
|
|
4
|
+
},
|
|
5
|
+
andWhen: async (store, whenCB, testResource, pm) => {
|
|
6
|
+
return whenCB(store, pm);
|
|
7
|
+
},
|
|
8
|
+
butThen: async (store, thenCB, testResource, pm) => {
|
|
9
|
+
return thenCB(store, pm);
|
|
10
|
+
},
|
|
11
|
+
afterEach: (store) => store,
|
|
12
|
+
afterAll: (store, pm) => { },
|
|
13
|
+
assertThis: (result) => !!result,
|
|
14
|
+
beforeAll: async (input, testResource, pm) => input
|
|
15
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import Testeranto from "../../Pure";
|
|
2
|
+
import { specification } from "./core.test.specification";
|
|
3
|
+
import { implementation } from "./core.test.implementation";
|
|
4
|
+
import { testInterface } from "./core.test.interface";
|
|
5
|
+
import { MockCore } from "./MockCore";
|
|
6
|
+
export default Testeranto(MockCore.prototype, // test subject
|
|
7
|
+
specification, // test scenarios
|
|
8
|
+
implementation, // test operations
|
|
9
|
+
testInterface, // test lifecycle hooks
|
|
10
|
+
{ ports: [] }, // resource requirements
|
|
11
|
+
(cb) => cb() // error handler
|
|
12
|
+
);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export const specification = (Suite, Given, When, Then, Check) => {
|
|
2
|
+
return [
|
|
3
|
+
Suite.Default("Testeranto Core Functionality", {
|
|
4
|
+
// Initialization tests
|
|
5
|
+
defaultInitialization: Given.Default(["Should initialize with default values"], [], [Then.initializedProperly()]),
|
|
6
|
+
customInputInitialization: Given.WithCustomInput({ test: "input" }, [], [Then.initializedProperly()]),
|
|
7
|
+
// Configuration tests
|
|
8
|
+
resourceConfig: Given.WithResourceRequirements({ ports: [3000, 3001] }, [], [Then.resourceRequirementsSet()]),
|
|
9
|
+
interfaceConfig: Given.WithCustomInterface({
|
|
10
|
+
assertThis: (x) => !!x,
|
|
11
|
+
beforeEach: async (s, i) => i()
|
|
12
|
+
}, [], [Then.interfaceConfigured()]),
|
|
13
|
+
// Core operations
|
|
14
|
+
specGeneration: Given.Default(["Should generate test specs"], [], [Then.specsGenerated()]),
|
|
15
|
+
jobCreation: Given.Default(["Should create test jobs"], [], [Then.jobsCreated()]),
|
|
16
|
+
artifactHandling: Given.Default(["Should track artifacts"], [When.addArtifact(Promise.resolve("test"))], [Then.artifactsTracked()])
|
|
17
|
+
}, []),
|
|
18
|
+
Suite.ExtendedSuite("Testeranto Advanced Features", {
|
|
19
|
+
// Error handling
|
|
20
|
+
errorPropagation: Given.Default(["Should propagate errors properly"], [When.triggerError("test error")], [Then.errorThrown("test error")]),
|
|
21
|
+
// Dynamic behavior
|
|
22
|
+
specModification: Given.Default(["Should allow spec modification"], [When.modifySpecs((specs) => [...specs, { name: "extra" }])], [Then.specsModified(1)]),
|
|
23
|
+
// Full lifecycle
|
|
24
|
+
testExecution: Given.Default(["Should execute full test lifecycle"], [], [Then.testRunSuccessful()]),
|
|
25
|
+
// Custom implementations
|
|
26
|
+
customImpl: Given.WithCustomImplementation(Object.assign(Object.assign({}, implementation), { suites: { Default: "Custom suite" } }), [], [Then.specsGenerated()])
|
|
27
|
+
}, [])
|
|
28
|
+
];
|
|
29
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
|
+
const baseProxy = function (pm, mappings) {
|
|
2
4
|
return new Proxy(pm, {
|
|
3
5
|
get: (target, prop, receiver) => {
|
|
4
6
|
for (const mapping of mappings) {
|
|
@@ -12,7 +14,7 @@ const prxy = function (pm, mappings) {
|
|
|
12
14
|
},
|
|
13
15
|
});
|
|
14
16
|
};
|
|
15
|
-
export const butThenProxy = (pm, filepath) =>
|
|
17
|
+
export const butThenProxy = (pm, filepath) => baseProxy(pm, [
|
|
16
18
|
[
|
|
17
19
|
"screencast",
|
|
18
20
|
(opts, p) => [
|
|
@@ -33,7 +35,7 @@ export const butThenProxy = (pm, filepath) => prxy(pm, [
|
|
|
33
35
|
],
|
|
34
36
|
],
|
|
35
37
|
]);
|
|
36
|
-
export const andWhenProxy = (pm, filepath) =>
|
|
38
|
+
export const andWhenProxy = (pm, filepath) => baseProxy(pm, [
|
|
37
39
|
[
|
|
38
40
|
"screencast",
|
|
39
41
|
(opts, p) => [
|
|
@@ -51,7 +53,7 @@ export const andWhenProxy = (pm, filepath) => prxy(pm, [
|
|
|
51
53
|
],
|
|
52
54
|
],
|
|
53
55
|
]);
|
|
54
|
-
export const afterEachProxy = (pm, suite, given) =>
|
|
56
|
+
export const afterEachProxy = (pm, suite, given) => baseProxy(pm, [
|
|
55
57
|
[
|
|
56
58
|
"screencast",
|
|
57
59
|
(opts, p) => [
|
|
@@ -75,7 +77,7 @@ export const afterEachProxy = (pm, suite, given) => prxy(pm, [
|
|
|
75
77
|
],
|
|
76
78
|
],
|
|
77
79
|
]);
|
|
78
|
-
export const beforeEachProxy = (pm, suite) =>
|
|
80
|
+
export const beforeEachProxy = (pm, suite) => baseProxy(pm, [
|
|
79
81
|
[
|
|
80
82
|
"screencast",
|
|
81
83
|
(opts, p) => [
|
|
@@ -96,7 +98,7 @@ export const beforeEachProxy = (pm, suite) => prxy(pm, [
|
|
|
96
98
|
],
|
|
97
99
|
["createWriteStream", (fp) => [`suite-${suite}/beforeEach/${fp}`]],
|
|
98
100
|
]);
|
|
99
|
-
export const beforeAllProxy = (pm, suite) =>
|
|
101
|
+
export const beforeAllProxy = (pm, suite) => baseProxy(pm, [
|
|
100
102
|
[
|
|
101
103
|
"writeFileSync",
|
|
102
104
|
(fp, contents) => [`suite-${suite}/beforeAll/${fp}`, contents],
|
|
@@ -110,7 +112,7 @@ export const beforeAllProxy = (pm, suite) => prxy(pm, [
|
|
|
110
112
|
],
|
|
111
113
|
["createWriteStream", (fp) => [`suite-${suite}/beforeAll/${fp}`]],
|
|
112
114
|
]);
|
|
113
|
-
export const afterAllProxy = (pm, suite) =>
|
|
115
|
+
export const afterAllProxy = (pm, suite) => baseProxy(pm, [
|
|
114
116
|
["createWriteStream", (fp) => [`suite-${suite}/afterAll/${fp}`]],
|
|
115
117
|
[
|
|
116
118
|
"writeFileSync",
|
|
@@ -124,162 +126,3 @@ export const afterAllProxy = (pm, suite) => prxy(pm, [
|
|
|
124
126
|
],
|
|
125
127
|
],
|
|
126
128
|
]);
|
|
127
|
-
/////////////////////////////////////////////////
|
|
128
|
-
// export const butThenProxy = (pm: IPM, filepath: string) => {
|
|
129
|
-
// return new Proxy(pm, {
|
|
130
|
-
// get: (target, prop, receiver) => {
|
|
131
|
-
// if (prop === "customScreenShot") {
|
|
132
|
-
// return (opts, p) =>
|
|
133
|
-
// target.customScreenShot(
|
|
134
|
-
// {
|
|
135
|
-
// ...opts,
|
|
136
|
-
// path: `${filepath}/${opts.path}`,
|
|
137
|
-
// },
|
|
138
|
-
// p
|
|
139
|
-
// );
|
|
140
|
-
// }
|
|
141
|
-
// if (prop === "writeFileSync") {
|
|
142
|
-
// return (fp, contents) => target[prop](`${filepath}/${fp}`, contents);
|
|
143
|
-
// }
|
|
144
|
-
// },
|
|
145
|
-
// });
|
|
146
|
-
// };
|
|
147
|
-
// export const andWhenProxy = (pm: IPM, filepath: string) => {
|
|
148
|
-
// return new Proxy(pm, {
|
|
149
|
-
// get(target, prop, receiver) {
|
|
150
|
-
// if (prop === "customScreenShot") {
|
|
151
|
-
// return (opts, p) =>
|
|
152
|
-
// target.customScreenShot(
|
|
153
|
-
// {
|
|
154
|
-
// ...opts,
|
|
155
|
-
// path: `${filepath}/${opts.path}`,
|
|
156
|
-
// },
|
|
157
|
-
// p
|
|
158
|
-
// );
|
|
159
|
-
// }
|
|
160
|
-
// if (prop === "writeFileSync") {
|
|
161
|
-
// return (fp, contents) =>
|
|
162
|
-
// target[prop](`${filepath}/andWhen/${fp}`, contents);
|
|
163
|
-
// }
|
|
164
|
-
// /* @ts-ignore:next-line */
|
|
165
|
-
// return Reflect.get(...arguments);
|
|
166
|
-
// },
|
|
167
|
-
// });
|
|
168
|
-
// };
|
|
169
|
-
// export const afterEachProxy = (pm: IPM, suite: string, given: string): IPM => {
|
|
170
|
-
// return new Proxy(pm, {
|
|
171
|
-
// get(target, prop, receiver) {
|
|
172
|
-
// if (prop === "customScreenShot") {
|
|
173
|
-
// return (opts, p) =>
|
|
174
|
-
// target.customScreenShot(
|
|
175
|
-
// {
|
|
176
|
-
// ...opts,
|
|
177
|
-
// path: `suite-${suite}/given-${given}/afterEach/${opts.path}`,
|
|
178
|
-
// },
|
|
179
|
-
// p
|
|
180
|
-
// );
|
|
181
|
-
// }
|
|
182
|
-
// if (prop === "writeFileSync") {
|
|
183
|
-
// return (fp, contents) =>
|
|
184
|
-
// target[prop](
|
|
185
|
-
// `suite-${suite}/given-${given}/afterEach/${fp}`,
|
|
186
|
-
// contents
|
|
187
|
-
// );
|
|
188
|
-
// }
|
|
189
|
-
// /* @ts-ignore:next-line */
|
|
190
|
-
// return Reflect.get(...arguments);
|
|
191
|
-
// },
|
|
192
|
-
// });
|
|
193
|
-
// };
|
|
194
|
-
// export const beforeAllProxy = (pm: IPM, suite: string): IPM => {
|
|
195
|
-
// return new Proxy(pm, {
|
|
196
|
-
// get(target, prop, receiver) {
|
|
197
|
-
// if (prop === "customScreenShot") {
|
|
198
|
-
// return (opts, p) =>
|
|
199
|
-
// target.customScreenShot(
|
|
200
|
-
// {
|
|
201
|
-
// ...opts,
|
|
202
|
-
// // path: `${filepath}/${opts.path}`,
|
|
203
|
-
// path: `suite-${suite}/beforeAll/${opts.path}`,
|
|
204
|
-
// },
|
|
205
|
-
// p
|
|
206
|
-
// );
|
|
207
|
-
// }
|
|
208
|
-
// if (prop === "writeFileSync") {
|
|
209
|
-
// return (fp, contents) =>
|
|
210
|
-
// target[prop](`suite-${suite}/beforeAll/${fp}`, contents);
|
|
211
|
-
// }
|
|
212
|
-
// /* @ts-ignore:next-line */
|
|
213
|
-
// return Reflect.get(...arguments);
|
|
214
|
-
// },
|
|
215
|
-
// });
|
|
216
|
-
// };
|
|
217
|
-
// export const beforeEachProxy = (pm: IPM, suite: string, given: string): IPM => {
|
|
218
|
-
// return new Proxy(pm, {
|
|
219
|
-
// get(target, prop, receiver) {
|
|
220
|
-
// // if (prop === "write") {
|
|
221
|
-
// // return (handle, contents) =>
|
|
222
|
-
// // target[prop](
|
|
223
|
-
// // `suite-${suiteNdx}/given-${key}/when/beforeEach/${fp}`,
|
|
224
|
-
// // contents
|
|
225
|
-
// // );
|
|
226
|
-
// // }
|
|
227
|
-
// if (prop === "createWriteStream") {
|
|
228
|
-
// return (fp) =>
|
|
229
|
-
// target[prop](`suite-${suite}/given-${given}/when/beforeEach/${fp}`);
|
|
230
|
-
// }
|
|
231
|
-
// if (prop === "writeFileSync") {
|
|
232
|
-
// return (fp, contents) =>
|
|
233
|
-
// target[prop](
|
|
234
|
-
// `suite-${suite}/given-${given}/when/beforeEach/${fp}`,
|
|
235
|
-
// contents
|
|
236
|
-
// );
|
|
237
|
-
// }
|
|
238
|
-
// if (prop === "customScreenShot") {
|
|
239
|
-
// return (opts, p) =>
|
|
240
|
-
// target.customScreenShot(
|
|
241
|
-
// {
|
|
242
|
-
// ...opts,
|
|
243
|
-
// path: `suite-${suite}/given-${given}/when/beforeEach/${opts.path}`,
|
|
244
|
-
// },
|
|
245
|
-
// p
|
|
246
|
-
// );
|
|
247
|
-
// }
|
|
248
|
-
// if (prop === "screencast") {
|
|
249
|
-
// return (opts, p) =>
|
|
250
|
-
// target.screencast(
|
|
251
|
-
// {
|
|
252
|
-
// ...opts,
|
|
253
|
-
// path: `suite-${suite}/given-${given}/when/beforeEach/${opts.path}`,
|
|
254
|
-
// },
|
|
255
|
-
// p
|
|
256
|
-
// );
|
|
257
|
-
// }
|
|
258
|
-
// /* @ts-ignore:next-line */
|
|
259
|
-
// return Reflect.get(...arguments);
|
|
260
|
-
// },
|
|
261
|
-
// });
|
|
262
|
-
// };
|
|
263
|
-
// export const afterAllProxy = (pm: IPM, suite: string): IPM => {
|
|
264
|
-
// return new Proxy(pm, {
|
|
265
|
-
// get(target, prop, receiver) {
|
|
266
|
-
// if (prop === "customScreenShot") {
|
|
267
|
-
// return (opts, p) =>
|
|
268
|
-
// target.customScreenShot(
|
|
269
|
-
// {
|
|
270
|
-
// ...opts,
|
|
271
|
-
// // path: `${filepath}/${opts.path}`,
|
|
272
|
-
// path: `suite-${suite}/afterAll/${opts.path}`,
|
|
273
|
-
// },
|
|
274
|
-
// p
|
|
275
|
-
// );
|
|
276
|
-
// }
|
|
277
|
-
// if (prop === "writeFileSync") {
|
|
278
|
-
// return (fp, contents) =>
|
|
279
|
-
// target[prop](`suite-${suite}/afterAll/${fp}`, contents);
|
|
280
|
-
// }
|
|
281
|
-
// /* @ts-ignore:next-line */
|
|
282
|
-
// return Reflect.get(...arguments);
|
|
283
|
-
// },
|
|
284
|
-
// });
|
|
285
|
-
// };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { MockPMBase } from "./mockPMBase";
|
|
2
|
+
export const implementation = {
|
|
3
|
+
suites: {
|
|
4
|
+
Default: "PM Proxy Tests",
|
|
5
|
+
},
|
|
6
|
+
givens: {
|
|
7
|
+
SomeBaseString: (s) => s,
|
|
8
|
+
},
|
|
9
|
+
whens: {
|
|
10
|
+
// functions have no mutations
|
|
11
|
+
},
|
|
12
|
+
thens: {
|
|
13
|
+
theButTheProxyReturns: (method, expectedPath) => (store) => {
|
|
14
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
15
|
+
const mockPm = new MockPMBase();
|
|
16
|
+
const filepath = "test/path";
|
|
17
|
+
const proxiedPm = store.butThenProxy(mockPm, filepath);
|
|
18
|
+
let actualPath;
|
|
19
|
+
let actualContent;
|
|
20
|
+
try {
|
|
21
|
+
switch (method) {
|
|
22
|
+
case "writeFileSync":
|
|
23
|
+
const content = expectedPath.includes('content') ?
|
|
24
|
+
"test content" : "default content";
|
|
25
|
+
proxiedPm.writeFileSync(expectedPath.includes('empty') ? "" :
|
|
26
|
+
expectedPath.includes('nested') ? "nested/folder/test.txt" :
|
|
27
|
+
expectedPath.includes('spaces') ? "file with spaces.txt" :
|
|
28
|
+
expectedPath.includes('invalid') ? "../invalid.txt" :
|
|
29
|
+
"test.txt", content);
|
|
30
|
+
actualPath = (_a = mockPm.getLastCall("writeFileSync")) === null || _a === void 0 ? void 0 : _a.path;
|
|
31
|
+
actualContent = (_b = mockPm.getLastCall("writeFileSync")) === null || _b === void 0 ? void 0 : _b.content;
|
|
32
|
+
break;
|
|
33
|
+
case "createWriteStream":
|
|
34
|
+
proxiedPm.createWriteStream(expectedPath.includes('empty') ? "" : "stream.txt");
|
|
35
|
+
actualPath = (_c = mockPm.getLastCall("createWriteStream")) === null || _c === void 0 ? void 0 : _c.path;
|
|
36
|
+
break;
|
|
37
|
+
case "screencast":
|
|
38
|
+
proxiedPm.screencast({
|
|
39
|
+
path: "screen.png",
|
|
40
|
+
quality: 80,
|
|
41
|
+
fullPage: true
|
|
42
|
+
}, "test");
|
|
43
|
+
actualPath = (_e = (_d = mockPm.getLastCall("screencast")) === null || _d === void 0 ? void 0 : _d.opts) === null || _e === void 0 ? void 0 : _e.path;
|
|
44
|
+
actualContent = (_f = mockPm.getLastCall("screencast")) === null || _f === void 0 ? void 0 : _f.opts;
|
|
45
|
+
break;
|
|
46
|
+
case "customScreenShot":
|
|
47
|
+
proxiedPm.customScreenShot({ path: "shot.png" }, "test");
|
|
48
|
+
actualPath = (_h = (_g = mockPm.getLastCall("customScreenShot")) === null || _g === void 0 ? void 0 : _g.opts) === null || _h === void 0 ? void 0 : _h.path;
|
|
49
|
+
break;
|
|
50
|
+
default:
|
|
51
|
+
throw new Error(`Unknown method: ${method}`);
|
|
52
|
+
}
|
|
53
|
+
if (expectedPath === undefined) {
|
|
54
|
+
return [undefined, undefined];
|
|
55
|
+
}
|
|
56
|
+
return [actualPath, expectedPath, actualContent];
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
return [error.message, expectedPath];
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
verifyContent: (expectedContent) => (result) => {
|
|
63
|
+
const actualContent = result[2];
|
|
64
|
+
if (JSON.stringify(actualContent) !== JSON.stringify(expectedContent)) {
|
|
65
|
+
throw new Error(`Content mismatch. Expected: ${JSON.stringify(expectedContent)}, Got: ${JSON.stringify(actualContent)}`);
|
|
66
|
+
}
|
|
67
|
+
return result;
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
checks: {
|
|
71
|
+
Default: (s) => s,
|
|
72
|
+
},
|
|
73
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import Testeranto from "../../Node";
|
|
2
|
+
import { implementation } from "./implementation";
|
|
3
|
+
import { specification } from "./specification";
|
|
4
|
+
import { testInterface } from "./interface";
|
|
5
|
+
import { butThenProxy } from "../pmProxy";
|
|
6
|
+
export default Testeranto(
|
|
7
|
+
// because of the nature of testeranto, we must add all the testable items here
|
|
8
|
+
{
|
|
9
|
+
butThenProxy,
|
|
10
|
+
}, specification, implementation, testInterface);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { assert } from "chai";
|
|
2
|
+
import { andWhenProxy, butThenProxy } from "../pmProxy";
|
|
3
|
+
import { MockPMBase } from "./mockPMBase";
|
|
4
|
+
// import { butThenProxy, andWhenProxy, beforeEachProxy } from "../pmProxy";
|
|
5
|
+
export const testInterface = {
|
|
6
|
+
beforeEach: async (subject, initializer, testResource, initialValues, pm) => {
|
|
7
|
+
return subject;
|
|
8
|
+
// const mockPM = MockPMBase();
|
|
9
|
+
// return {
|
|
10
|
+
// beforeEachProxy: subject.butThenProxy(
|
|
11
|
+
// new MockPMBase() as unknown as IPM,
|
|
12
|
+
// initializer
|
|
13
|
+
// ),
|
|
14
|
+
// };
|
|
15
|
+
},
|
|
16
|
+
andWhen: async (store, whenCB, testResource, pm) => {
|
|
17
|
+
const proxiedPM = andWhenProxy(pm, "some/path");
|
|
18
|
+
return whenCB(store, proxiedPM);
|
|
19
|
+
},
|
|
20
|
+
butThen: async (store, thenCB, testResource, pm) => {
|
|
21
|
+
const proxiedPM = butThenProxy(pm, "some/path");
|
|
22
|
+
return thenCB(store, proxiedPM);
|
|
23
|
+
},
|
|
24
|
+
afterEach: async (store, key, pm) => store,
|
|
25
|
+
afterAll: async (store, pm) => { },
|
|
26
|
+
beforeAll: async (input, testResource, pm, theGivenString) => {
|
|
27
|
+
return {
|
|
28
|
+
beforeEachProxy: input.butThenProxy(new MockPMBase(), theGivenString),
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
assertThis: (returnedFilePath, expectation) => {
|
|
32
|
+
assert.equal(returnedFilePath, expectation);
|
|
33
|
+
},
|
|
34
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { MockPMBase } from "./mockPMBase";
|
|
2
|
+
export class MockPM extends MockPMBase {
|
|
3
|
+
constructor(configs) {
|
|
4
|
+
super(configs);
|
|
5
|
+
this.server = {};
|
|
6
|
+
this.testResourceConfiguration = {};
|
|
7
|
+
}
|
|
8
|
+
// PM-specific methods
|
|
9
|
+
start() {
|
|
10
|
+
this.trackCall("start", {});
|
|
11
|
+
return Promise.resolve();
|
|
12
|
+
}
|
|
13
|
+
stop() {
|
|
14
|
+
this.trackCall("stop", {});
|
|
15
|
+
return Promise.resolve();
|
|
16
|
+
}
|
|
17
|
+
launchSideCar(n) {
|
|
18
|
+
this.trackCall("launchSideCar", { n });
|
|
19
|
+
return Promise.resolve([n, this.testResourceConfiguration]);
|
|
20
|
+
}
|
|
21
|
+
stopSideCar(n) {
|
|
22
|
+
this.trackCall("stopSideCar", { n });
|
|
23
|
+
return Promise.resolve();
|
|
24
|
+
}
|
|
25
|
+
// Override any methods that need different behavior from MockPMBase
|
|
26
|
+
// For example:
|
|
27
|
+
writeFileSync(path, content) {
|
|
28
|
+
return super.writeFileSync(path, content, "default-test-name");
|
|
29
|
+
}
|
|
30
|
+
}
|