testeranto 0.62.0 → 0.73.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -26
- package/dist/cjs-shim.js +2 -2
- package/dist/common/Node.js +14 -51
- package/dist/common/PM/index.js +71 -0
- package/dist/common/PM/main.js +361 -0
- package/dist/common/PM/node.js +176 -0
- package/dist/common/PM/web.js +174 -0
- package/dist/common/Project.js +121 -266
- package/dist/common/Puppeteer.js +109 -0
- package/dist/common/Reporter.js +119 -0
- package/dist/common/Scheduler.js +1 -0
- package/dist/common/SubPackages/puppeteer.js +3 -1
- package/dist/common/SubPackages/react-dom/component/web.js +98 -45
- package/dist/common/SubPackages/react-dom/jsx/web.js +15 -7
- package/dist/common/SubPackages/react-test-renderer/MemoExoticComponent/node.js +1 -1
- package/dist/common/SubPackages/react-test-renderer/component/index.js +0 -1
- package/dist/common/SubPackages/react-test-renderer/fc/web.js +1 -1
- package/dist/common/SubPackages/react-test-renderer/jsx/index.js +1 -3
- package/dist/common/SubPackages/react-test-renderer/jsx/web.js +1 -1
- package/dist/common/SubPackages/react-test-renderer/jsx-promised/index.js +1 -1
- package/dist/common/Types.js +2 -32
- package/dist/common/Web.js +25 -37
- package/dist/common/esbuildConfigs/index.js +5 -5
- package/dist/common/esbuildConfigs/node.js +17 -15
- package/dist/common/esbuildConfigs/report.js +12 -47
- package/dist/common/esbuildConfigs/tests.js +0 -1
- package/dist/common/esbuildConfigs/web.js +17 -12
- package/dist/common/lib/abstractBase.js +190 -35
- package/dist/common/lib/basebuilder.js +56 -29
- package/dist/common/lib/classBuilder.js +8 -5
- package/dist/common/lib/core.js +42 -17
- package/dist/common/lib/index.js +11 -8
- package/dist/common/lib/types.js +2 -0
- package/dist/common/preload.js +14 -28
- package/dist/common/puppeteerConfiger.js +24 -0
- package/dist/common/tsconfig.common.tsbuildinfo +1 -1
- package/dist/module/Node.js +14 -51
- package/dist/module/PM/index.js +67 -0
- package/dist/module/PM/main.js +331 -0
- package/dist/module/PM/node.js +168 -0
- package/dist/module/PM/web.js +167 -0
- package/dist/module/Project.js +122 -267
- package/dist/module/Puppeteer.js +104 -0
- package/dist/module/Reporter.js +114 -0
- package/dist/module/Scheduler.js +1 -0
- package/dist/module/SubPackages/puppeteer.js +3 -1
- package/dist/module/SubPackages/react/jsx/node.js +1 -1
- package/dist/module/SubPackages/react/jsx/web.js +1 -1
- package/dist/module/SubPackages/react-dom/component/node.js +2 -2
- package/dist/module/SubPackages/react-dom/component/web.js +98 -45
- package/dist/module/SubPackages/react-dom/jsx/web.js +17 -9
- package/dist/module/SubPackages/react-test-renderer/MemoExoticComponent/node.js +1 -1
- package/dist/module/SubPackages/react-test-renderer/component/index.js +0 -1
- package/dist/module/SubPackages/react-test-renderer/fc/web.js +1 -1
- package/dist/module/SubPackages/react-test-renderer/jsx/index.js +1 -3
- package/dist/module/SubPackages/react-test-renderer/jsx/web.js +1 -1
- package/dist/module/SubPackages/react-test-renderer/jsx-promised/index.js +1 -1
- package/dist/module/Types.js +3 -30
- package/dist/module/Web.js +26 -38
- package/dist/module/esbuildConfigs/index.js +5 -5
- package/dist/module/esbuildConfigs/node.js +17 -15
- package/dist/module/esbuildConfigs/report.js +11 -48
- package/dist/module/esbuildConfigs/tests.js +0 -1
- package/dist/module/esbuildConfigs/web.js +17 -12
- package/dist/module/lib/abstractBase.js +190 -35
- package/dist/module/lib/basebuilder.js +56 -29
- package/dist/module/lib/classBuilder.js +8 -5
- package/dist/module/lib/core.js +44 -19
- package/dist/module/lib/index.js +11 -8
- package/dist/module/preload.js +15 -27
- package/dist/module/puppeteerConfiger.js +19 -0
- package/dist/module/tsconfig.module.tsbuildinfo +1 -1
- package/dist/prebuild/Report.css +1616 -584
- package/dist/prebuild/Report.js +2635 -2506
- package/dist/types/Node.d.ts +3 -2
- package/dist/types/PM/index.d.ts +19 -0
- package/dist/types/PM/main.d.ts +28 -0
- package/dist/types/PM/node.d.ts +26 -0
- package/dist/types/PM/web.d.ts +24 -0
- package/dist/types/Project.d.ts +1 -2
- package/dist/types/Puppeteer.d.ts +1 -0
- package/dist/types/Reporter.d.ts +1 -0
- package/dist/types/Scheduler.d.ts +0 -0
- package/dist/types/SubPackages/puppeteer.d.ts +3 -3
- package/dist/types/SubPackages/react/component/node.d.ts +1 -1
- package/dist/types/SubPackages/react/component/web.d.ts +1 -1
- package/dist/types/SubPackages/react/jsx/index.d.ts +1 -1
- package/dist/types/SubPackages/react/jsx/node.d.ts +1 -1
- package/dist/types/SubPackages/react/jsx/web.d.ts +2 -2
- package/dist/types/SubPackages/react-dom/component/node.d.ts +2 -2
- package/dist/types/SubPackages/react-dom/component/web.d.ts +1 -1
- package/dist/types/SubPackages/react-dom/jsx/node.d.ts +1 -1
- package/dist/types/SubPackages/react-dom/jsx/web.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/MemoExoticComponent/node.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/component/index.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/component/node.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/component/web.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/fc/node.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/fc/web.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/jsx/node.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/jsx/web.d.ts +3 -3
- package/dist/types/SubPackages/react-test-renderer/jsx-promised/index.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/jsx-promised/node.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/jsx-promised/web.d.ts +1 -1
- package/dist/types/Types.d.ts +19 -100
- package/dist/types/Web.d.ts +3 -2
- package/dist/types/esbuildConfigs/features.d.ts +1 -1
- package/dist/types/esbuildConfigs/index.d.ts +1 -1
- package/dist/types/esbuildConfigs/node.d.ts +1 -1
- package/dist/types/esbuildConfigs/report.d.ts +4 -0
- package/dist/types/esbuildConfigs/tests.d.ts +1 -1
- package/dist/types/esbuildConfigs/web.d.ts +1 -1
- package/dist/types/lib/abstractBase.d.ts +26 -24
- package/dist/types/lib/basebuilder.d.ts +10 -7
- package/dist/types/lib/classBuilder.d.ts +4 -3
- package/dist/types/lib/core.d.ts +5 -4
- package/dist/types/lib/index.d.ts +7 -5
- package/dist/types/lib/types.d.ts +62 -0
- package/dist/types/preload.d.ts +0 -1
- package/dist/types/puppeteerConfiger.d.ts +4 -0
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +6 -7
- package/src/Node.ts +30 -85
- package/src/PM/index.ts +102 -0
- package/src/PM/main.ts +420 -0
- package/src/PM/node.ts +515 -0
- package/src/PM/web.ts +497 -0
- package/src/Project.ts +183 -619
- package/src/Puppeteer.ts +131 -0
- package/src/Report.tsx +158 -44
- package/src/Reporter.ts +134 -0
- package/src/Scheduler.ts +0 -0
- package/src/SubPackages/puppeteer.ts +19 -14
- package/src/SubPackages/react/component/node.ts +20 -32
- package/src/SubPackages/react/component/web.ts +20 -30
- package/src/SubPackages/react/jsx/index.ts +13 -24
- package/src/SubPackages/react/jsx/node.ts +5 -8
- package/src/SubPackages/react/jsx/web.ts +10 -8
- package/src/SubPackages/react-dom/component/node.ts +17 -23
- package/src/SubPackages/react-dom/component/web.ts +134 -95
- package/src/SubPackages/react-dom/jsx/web.ts +41 -48
- package/src/SubPackages/react-test-renderer/MemoExoticComponent/node.ts +27 -37
- package/src/SubPackages/react-test-renderer/component/index.ts +16 -30
- package/src/SubPackages/react-test-renderer/component/node.ts +5 -11
- package/src/SubPackages/react-test-renderer/component/web.ts +5 -11
- package/src/SubPackages/react-test-renderer/fc/node.ts +36 -50
- package/src/SubPackages/react-test-renderer/fc/web.ts +37 -50
- package/src/SubPackages/react-test-renderer/jsx/index.ts +15 -21
- package/src/SubPackages/react-test-renderer/jsx/node.ts +6 -10
- package/src/SubPackages/react-test-renderer/jsx/web.ts +7 -7
- package/src/SubPackages/react-test-renderer/jsx-promised/index.ts +13 -16
- package/src/Types.ts +73 -307
- package/src/Web.ts +40 -81
- package/src/cjs-shim.js +2 -2
- package/src/esbuildConfigs/features.ts +3 -4
- package/src/esbuildConfigs/index.ts +8 -8
- package/src/esbuildConfigs/node.ts +21 -20
- package/src/esbuildConfigs/report.ts +15 -51
- package/src/esbuildConfigs/tests.ts +3 -9
- package/src/esbuildConfigs/web.ts +22 -20
- package/src/lib/abstractBase.ts +312 -164
- package/src/lib/basebuilder.ts +123 -127
- package/src/lib/classBuilder.ts +30 -48
- package/src/lib/core.ts +115 -84
- package/src/lib/index.ts +58 -56
- package/src/lib/types.ts +197 -0
- package/src/preload.ts +14 -30
- package/src/puppeteerConfiger.ts +26 -0
- package/src/web.html.ts +1 -1
- package/dist/common/NodeWriter.js +0 -56
- package/dist/common/electron.js +0 -196
- package/dist/common/lib/browser.js +0 -26
- package/dist/common/nodeWriterElectron.js +0 -55
- package/dist/module/NodeWriter.js +0 -50
- package/dist/module/electron.js +0 -191
- package/dist/module/lib/browser.js +0 -22
- package/dist/module/nodeWriterElectron.js +0 -52
- package/dist/types/NodeWriter.d.ts +0 -2
- package/dist/types/lib/browser.d.ts +0 -6
- package/dist/types/nodeWriterElectron.d.ts +0 -2
- package/src/NodeWriter.ts +0 -69
- package/src/electron.ts +0 -250
- package/src/lib/browser.ts +0 -34
- package/src/nodeWriterElectron.ts +0 -71
- package/yarn-error.log +0 -3144
- /package/dist/{types/electron.d.ts → module/lib/types.js} +0 -0
package/src/lib/abstractBase.ts
CHANGED
|
@@ -1,41 +1,28 @@
|
|
|
1
|
+
import { IBaseTest } from "../Types";
|
|
2
|
+
|
|
1
3
|
import { ITTestResourceConfiguration, ITestArtifactory, ITLog } from ".";
|
|
2
|
-
import {
|
|
4
|
+
import { PM } from "../PM/index.js";
|
|
5
|
+
// import { IUtils } from "./types";
|
|
3
6
|
|
|
4
|
-
export type IGivens<
|
|
5
|
-
ITestShape extends IBaseTest
|
|
6
|
-
> = Record<
|
|
7
|
+
export type IGivens<ITestShape extends IBaseTest> = Record<
|
|
7
8
|
string,
|
|
8
|
-
BaseGiven<
|
|
9
|
-
ITestShape
|
|
10
|
-
>
|
|
9
|
+
BaseGiven<ITestShape>
|
|
11
10
|
>;
|
|
12
11
|
|
|
13
|
-
export abstract class BaseSuite<
|
|
14
|
-
ITestShape extends IBaseTest
|
|
15
|
-
> {
|
|
12
|
+
export abstract class BaseSuite<ITestShape extends IBaseTest> {
|
|
16
13
|
name: string;
|
|
17
|
-
givens: IGivens<
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
ITestShape
|
|
22
|
-
>[];
|
|
23
|
-
store: ITestShape['istore'];
|
|
24
|
-
fails: BaseGiven<
|
|
25
|
-
ITestShape
|
|
26
|
-
>[];
|
|
14
|
+
givens: IGivens<ITestShape>;
|
|
15
|
+
checks: BaseCheck<ITestShape>[];
|
|
16
|
+
store: ITestShape["istore"];
|
|
17
|
+
fails: BaseGiven<ITestShape>[];
|
|
27
18
|
testResourceConfiguration: ITTestResourceConfiguration;
|
|
28
19
|
index: number;
|
|
29
20
|
|
|
30
21
|
constructor(
|
|
31
22
|
name: string,
|
|
32
23
|
index: number,
|
|
33
|
-
givens: IGivens<
|
|
34
|
-
|
|
35
|
-
> = {},
|
|
36
|
-
checks: BaseCheck<
|
|
37
|
-
ITestShape
|
|
38
|
-
>[] = []
|
|
24
|
+
givens: IGivens<ITestShape> = {},
|
|
25
|
+
checks: BaseCheck<ITestShape>[] = []
|
|
39
26
|
) {
|
|
40
27
|
this.name = name;
|
|
41
28
|
this.index = index;
|
|
@@ -53,114 +40,180 @@ export abstract class BaseSuite<
|
|
|
53
40
|
}
|
|
54
41
|
|
|
55
42
|
setup(
|
|
56
|
-
s: ITestShape[
|
|
43
|
+
s: ITestShape["iinput"],
|
|
57
44
|
artifactory: ITestArtifactory,
|
|
58
45
|
tr: ITTestResourceConfiguration,
|
|
59
|
-
|
|
60
|
-
): Promise<ITestShape[
|
|
61
|
-
return new Promise((res) => res(s as unknown as ITestShape[
|
|
46
|
+
pm: PM
|
|
47
|
+
): Promise<ITestShape["isubject"]> {
|
|
48
|
+
return new Promise((res) => res(s as unknown as ITestShape["isubject"]));
|
|
62
49
|
}
|
|
63
50
|
|
|
64
|
-
assertThat(t: ITestShape[
|
|
65
|
-
// console.log("base assertThat")
|
|
51
|
+
assertThat(t: ITestShape["then"]): unknown {
|
|
66
52
|
return t;
|
|
67
53
|
}
|
|
68
54
|
|
|
55
|
+
afterAll(store: ITestShape["istore"], artifactory: ITestArtifactory, pm: PM) {
|
|
56
|
+
return store;
|
|
57
|
+
}
|
|
58
|
+
|
|
69
59
|
async run(
|
|
70
|
-
input: ITestShape[
|
|
60
|
+
input: ITestShape["iinput"],
|
|
71
61
|
testResourceConfiguration: ITTestResourceConfiguration,
|
|
72
|
-
artifactory: (
|
|
73
|
-
fPath: string,
|
|
74
|
-
value: unknown
|
|
75
|
-
) => void,
|
|
62
|
+
artifactory: (fPath: string, value: unknown) => void,
|
|
76
63
|
tLog: (...string) => void,
|
|
77
|
-
|
|
78
|
-
): Promise<
|
|
79
|
-
BaseSuite<
|
|
80
|
-
ITestShape
|
|
81
|
-
>
|
|
82
|
-
> {
|
|
64
|
+
pm: PM
|
|
65
|
+
): Promise<BaseSuite<ITestShape>> {
|
|
83
66
|
this.testResourceConfiguration = testResourceConfiguration;
|
|
84
|
-
tLog("test resources: ", testResourceConfiguration);
|
|
67
|
+
tLog("test resources: ", JSON.stringify(testResourceConfiguration));
|
|
85
68
|
|
|
86
69
|
const suiteArtifactory = (fPath: string, value: unknown) =>
|
|
87
|
-
artifactory(`suite-${this.index}-${this.name}/${fPath}`, value)
|
|
88
|
-
const subject = await this.setup(
|
|
89
|
-
input,
|
|
90
|
-
suiteArtifactory,
|
|
91
|
-
testResourceConfiguration,
|
|
92
|
-
utils
|
|
93
|
-
);
|
|
70
|
+
artifactory(`suite-${this.index}-${this.name}/${fPath}`, value);
|
|
94
71
|
|
|
72
|
+
console.log("\nSuite:", this.index, this.name);
|
|
95
73
|
tLog("\nSuite:", this.index, this.name);
|
|
96
|
-
|
|
97
|
-
|
|
74
|
+
const sNdx = this.index;
|
|
75
|
+
const sName = this.name;
|
|
76
|
+
|
|
77
|
+
for (const [gNdx, g] of Object.entries(this.givens)) {
|
|
78
|
+
const subject = await this.setup(
|
|
79
|
+
input,
|
|
80
|
+
suiteArtifactory,
|
|
81
|
+
testResourceConfiguration,
|
|
82
|
+
pm
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
const giver = this.givens[gNdx];
|
|
98
86
|
try {
|
|
99
87
|
this.store = await giver.give(
|
|
100
88
|
subject,
|
|
101
|
-
|
|
89
|
+
gNdx,
|
|
102
90
|
testResourceConfiguration,
|
|
103
91
|
this.assertThat,
|
|
104
92
|
suiteArtifactory,
|
|
105
93
|
tLog,
|
|
106
|
-
|
|
94
|
+
pm,
|
|
95
|
+
sNdx
|
|
107
96
|
);
|
|
108
97
|
} catch (e) {
|
|
109
98
|
console.error(e);
|
|
110
99
|
this.fails.push(giver);
|
|
111
|
-
return this;
|
|
100
|
+
// return this;
|
|
112
101
|
}
|
|
113
102
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
103
|
+
|
|
104
|
+
const afterAllProxy = new Proxy(pm, {
|
|
105
|
+
get(target, prop, receiver) {
|
|
106
|
+
if (prop === "writeFileSync") {
|
|
107
|
+
return (fp, contents) =>
|
|
108
|
+
target[prop](`suite-${sNdx}/afterAll/${fp}`, contents);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (prop === "browser") {
|
|
112
|
+
return new Proxy(target[prop], {
|
|
113
|
+
get(bTarget, bProp, bReceiver) {
|
|
114
|
+
if (bProp === "pages") {
|
|
115
|
+
return async () => {
|
|
116
|
+
return bTarget.pages().then((pages) => {
|
|
117
|
+
return pages.map((page) => {
|
|
118
|
+
return new Proxy(page, {
|
|
119
|
+
get(pTarget, pProp, pReciever) {
|
|
120
|
+
if (pProp === "screenshot") {
|
|
121
|
+
return async (x) => {
|
|
122
|
+
// console.log(
|
|
123
|
+
// "custom-screenshot-MARK-afterAllProxy",
|
|
124
|
+
// // arguments,
|
|
125
|
+
// // x,
|
|
126
|
+
// window["custom-screenshot"].toString()
|
|
127
|
+
// );
|
|
128
|
+
return await window["custom-screenshot"]({
|
|
129
|
+
...x,
|
|
130
|
+
path:
|
|
131
|
+
`${testResourceConfiguration.fs}/suite-${sNdx}/afterAll` +
|
|
132
|
+
"/" +
|
|
133
|
+
x.path,
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
// else if (pProp === "mainFrame") {
|
|
138
|
+
// return () => target[pProp](...arguments);
|
|
139
|
+
// }
|
|
140
|
+
else {
|
|
141
|
+
return Reflect.get(...arguments);
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
// return (await target.pages()).map((page) => {
|
|
148
|
+
// return new Proxy(page, handler2);
|
|
149
|
+
// });
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return Reflect.get(...arguments);
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
// pm.browser
|
|
161
|
+
try {
|
|
162
|
+
this.afterAll(this.store, artifactory, afterAllProxy);
|
|
163
|
+
} catch (e) {
|
|
164
|
+
console.error(e);
|
|
165
|
+
// this.fails.push(this);
|
|
166
|
+
// return this;
|
|
124
167
|
}
|
|
125
168
|
|
|
169
|
+
// for (const [ndx, thater] of this.checks.entries()) {
|
|
170
|
+
// await thater.check(
|
|
171
|
+
// subject,
|
|
172
|
+
// thater.name,
|
|
173
|
+
// testResourceConfiguration,
|
|
174
|
+
// this.assertThat,
|
|
175
|
+
// suiteArtifactory,
|
|
176
|
+
// tLog,
|
|
177
|
+
// pm
|
|
178
|
+
// );
|
|
179
|
+
// }
|
|
180
|
+
|
|
126
181
|
// @TODO fix me
|
|
127
|
-
for (const k of Object.keys(this.givens)) {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
182
|
+
// for (const k of Object.keys(this.givens)) {
|
|
183
|
+
// const giver = this.givens[k];
|
|
184
|
+
|
|
185
|
+
// try {
|
|
186
|
+
// giver.afterAll(this.store, artifactory, pm);
|
|
187
|
+
// } catch (e) {
|
|
188
|
+
// console.error(e);
|
|
189
|
+
// this.fails.push(giver);
|
|
190
|
+
// return this;
|
|
191
|
+
// }
|
|
192
|
+
// }
|
|
131
193
|
////////////////
|
|
132
194
|
|
|
133
195
|
return this;
|
|
134
196
|
}
|
|
135
197
|
}
|
|
136
198
|
|
|
137
|
-
export abstract class BaseGiven<
|
|
138
|
-
ITestShape extends IBaseTest
|
|
139
|
-
> {
|
|
199
|
+
export abstract class BaseGiven<ITestShape extends IBaseTest> {
|
|
140
200
|
name: string;
|
|
141
201
|
features: string[];
|
|
142
|
-
whens: BaseWhen<
|
|
143
|
-
|
|
144
|
-
>[];
|
|
145
|
-
thens: BaseThen<
|
|
146
|
-
ITestShape
|
|
147
|
-
>[];
|
|
202
|
+
whens: BaseWhen<ITestShape>[];
|
|
203
|
+
thens: BaseThen<ITestShape>[];
|
|
148
204
|
error: Error;
|
|
149
|
-
|
|
205
|
+
fail: any;
|
|
206
|
+
store: ITestShape["istore"];
|
|
150
207
|
recommendedFsPath: string;
|
|
151
|
-
givenCB: ITestShape[
|
|
208
|
+
givenCB: ITestShape["given"];
|
|
152
209
|
initialValues: any;
|
|
153
210
|
|
|
154
211
|
constructor(
|
|
155
212
|
name: string,
|
|
156
213
|
features: string[],
|
|
157
|
-
whens: BaseWhen<
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
thens: BaseThen<
|
|
161
|
-
ITestShape
|
|
162
|
-
>[],
|
|
163
|
-
givenCB: ITestShape['given'],
|
|
214
|
+
whens: BaseWhen<ITestShape>[],
|
|
215
|
+
thens: BaseThen<ITestShape>[],
|
|
216
|
+
givenCB: ITestShape["given"],
|
|
164
217
|
initialValues: any
|
|
165
218
|
) {
|
|
166
219
|
this.name = name;
|
|
@@ -171,19 +224,7 @@ export abstract class BaseGiven<
|
|
|
171
224
|
this.initialValues = initialValues;
|
|
172
225
|
}
|
|
173
226
|
|
|
174
|
-
beforeAll(
|
|
175
|
-
store: ITestShape['istore'],
|
|
176
|
-
artifactory: ITestArtifactory,
|
|
177
|
-
|
|
178
|
-
) {
|
|
179
|
-
return store;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
afterAll(
|
|
183
|
-
store: ITestShape['istore'],
|
|
184
|
-
artifactory: ITestArtifactory,
|
|
185
|
-
utils: IUtils
|
|
186
|
-
) {
|
|
227
|
+
beforeAll(store: ITestShape["istore"], artifactory: ITestArtifactory) {
|
|
187
228
|
return store;
|
|
188
229
|
}
|
|
189
230
|
|
|
@@ -193,61 +234,84 @@ export abstract class BaseGiven<
|
|
|
193
234
|
whens: this.whens.map((w) => w.toObj()),
|
|
194
235
|
thens: this.thens.map((t) => t.toObj()),
|
|
195
236
|
error: this.error ? [this.error, this.error.stack] : null,
|
|
237
|
+
// fail: this.fail ? [this.fail] : false,
|
|
196
238
|
features: this.features,
|
|
197
239
|
};
|
|
198
240
|
}
|
|
199
241
|
|
|
200
242
|
abstract givenThat(
|
|
201
|
-
subject: ITestShape[
|
|
243
|
+
subject: ITestShape["isubject"],
|
|
202
244
|
testResourceConfiguration,
|
|
203
245
|
artifactory: ITestArtifactory,
|
|
204
|
-
givenCB: ITestShape[
|
|
205
|
-
|
|
246
|
+
givenCB: ITestShape["given"],
|
|
247
|
+
pm: PM
|
|
248
|
+
): Promise<ITestShape["istore"]>;
|
|
206
249
|
|
|
207
250
|
async afterEach(
|
|
208
|
-
store: ITestShape[
|
|
251
|
+
store: ITestShape["istore"],
|
|
209
252
|
key: string,
|
|
210
|
-
artifactory: ITestArtifactory
|
|
253
|
+
artifactory: ITestArtifactory,
|
|
254
|
+
pm: PM
|
|
211
255
|
): Promise<unknown> {
|
|
212
256
|
return store;
|
|
213
257
|
}
|
|
214
258
|
|
|
215
259
|
async give(
|
|
216
|
-
subject: ITestShape[
|
|
260
|
+
subject: ITestShape["isubject"],
|
|
217
261
|
key: string,
|
|
218
262
|
testResourceConfiguration,
|
|
219
|
-
tester,
|
|
263
|
+
tester: (t: Awaited<ITestShape["then"]> | undefined) => boolean,
|
|
220
264
|
artifactory: ITestArtifactory,
|
|
221
265
|
tLog: ITLog,
|
|
222
|
-
|
|
266
|
+
pm: PM,
|
|
267
|
+
suiteNdx: number
|
|
223
268
|
) {
|
|
224
269
|
tLog(`\n Given: ${this.name}`);
|
|
225
270
|
|
|
226
271
|
const givenArtifactory = (fPath: string, value: unknown) =>
|
|
227
|
-
artifactory(`given-${key}/${fPath}`, value)
|
|
272
|
+
artifactory(`given-${key}/${fPath}`, value);
|
|
228
273
|
try {
|
|
274
|
+
// tLog(`\n Given this.store`, this.store);
|
|
275
|
+
|
|
276
|
+
const beforeEachProxy = new Proxy(pm, {
|
|
277
|
+
get(target, prop, receiver) {
|
|
278
|
+
if (prop === "writeFileSync") {
|
|
279
|
+
console.log("beforeEachProx", arguments, target[prop]);
|
|
280
|
+
return (fp, contents) =>
|
|
281
|
+
target[prop](
|
|
282
|
+
`suite-${suiteNdx}/given-${key}/when/beforeEach/${fp}`,
|
|
283
|
+
contents
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
return Reflect.get(...arguments);
|
|
288
|
+
},
|
|
289
|
+
});
|
|
290
|
+
|
|
229
291
|
this.store = await this.givenThat(
|
|
230
292
|
subject,
|
|
231
293
|
testResourceConfiguration,
|
|
232
294
|
givenArtifactory,
|
|
233
|
-
this.givenCB
|
|
295
|
+
this.givenCB,
|
|
296
|
+
beforeEachProxy
|
|
234
297
|
);
|
|
235
298
|
|
|
236
|
-
|
|
237
|
-
for (const whenStep of this.whens) {
|
|
299
|
+
for (const [whenNdx, whenStep] of this.whens.entries()) {
|
|
238
300
|
await whenStep.test(
|
|
239
301
|
this.store,
|
|
240
302
|
testResourceConfiguration,
|
|
241
303
|
tLog,
|
|
242
|
-
|
|
304
|
+
pm,
|
|
305
|
+
`suite-${suiteNdx}/given-${key}/when/${whenNdx}`
|
|
243
306
|
);
|
|
244
307
|
}
|
|
308
|
+
|
|
245
309
|
for (const thenStep of this.thens) {
|
|
246
310
|
const t = await thenStep.test(
|
|
247
311
|
this.store,
|
|
248
312
|
testResourceConfiguration,
|
|
249
313
|
tLog,
|
|
250
|
-
|
|
314
|
+
pm
|
|
251
315
|
);
|
|
252
316
|
tester(t);
|
|
253
317
|
}
|
|
@@ -258,7 +322,82 @@ export abstract class BaseGiven<
|
|
|
258
322
|
// throw e;
|
|
259
323
|
} finally {
|
|
260
324
|
try {
|
|
261
|
-
|
|
325
|
+
// const afterEachProxy = new Proxy(pm, {
|
|
326
|
+
// get(target, prop, receiver) {
|
|
327
|
+
// if (prop === "writeFileSync") {
|
|
328
|
+
// console.log("afterEachProxy", arguments, target[prop]);
|
|
329
|
+
// return (fp, contents) =>
|
|
330
|
+
// // target[prop](`${key}/andWhen/${fp}`, contents);
|
|
331
|
+
// target[prop](`${key}/afterEach/${fp}`, contents);
|
|
332
|
+
// }
|
|
333
|
+
|
|
334
|
+
// return Reflect.get(...arguments);
|
|
335
|
+
// },
|
|
336
|
+
// });
|
|
337
|
+
|
|
338
|
+
// await this.afterEach(this.store, key, givenArtifactory, afterEachProxy);
|
|
339
|
+
|
|
340
|
+
// await this.afterEach(this.store, key, givenArtifactory, pm);
|
|
341
|
+
|
|
342
|
+
const afterEachProxy = new Proxy(pm, {
|
|
343
|
+
get(target, prop, receiver) {
|
|
344
|
+
if (prop === "writeFileSync") {
|
|
345
|
+
return (fp, contents) =>
|
|
346
|
+
target[prop](
|
|
347
|
+
`suite-${suiteNdx}/given-${key}/afterAll/${fp}`,
|
|
348
|
+
contents
|
|
349
|
+
);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
if (prop === "browser") {
|
|
353
|
+
return new Proxy(target[prop], {
|
|
354
|
+
get(bTarget, bProp, bReceiver) {
|
|
355
|
+
if (bProp === "pages") {
|
|
356
|
+
return async () => {
|
|
357
|
+
return bTarget.pages().then((pages) => {
|
|
358
|
+
return pages.map((page) => {
|
|
359
|
+
return new Proxy(page, {
|
|
360
|
+
get(pTarget, pProp, pReciever) {
|
|
361
|
+
if (pProp === "screenshot") {
|
|
362
|
+
return async (x) => {
|
|
363
|
+
// console.log(
|
|
364
|
+
// "custom-screenshot-MARK-afterEachProxy",
|
|
365
|
+
// window["custom-screenshot"].toString()
|
|
366
|
+
// );
|
|
367
|
+
|
|
368
|
+
return await window["custom-screenshot"]({
|
|
369
|
+
...x,
|
|
370
|
+
path:
|
|
371
|
+
`${testResourceConfiguration.fs}/suite-${suiteNdx}/given-${key}/afterEach` +
|
|
372
|
+
"/" +
|
|
373
|
+
x.path,
|
|
374
|
+
});
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
// else if (pProp === "mainFrame") {
|
|
378
|
+
// return () => target[pProp](...arguments);
|
|
379
|
+
// }
|
|
380
|
+
else {
|
|
381
|
+
return Reflect.get(...arguments);
|
|
382
|
+
}
|
|
383
|
+
},
|
|
384
|
+
});
|
|
385
|
+
});
|
|
386
|
+
});
|
|
387
|
+
// return (await target.pages()).map((page) => {
|
|
388
|
+
// return new Proxy(page, handler2);
|
|
389
|
+
// });
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
},
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
return Reflect.get(...arguments);
|
|
397
|
+
},
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
await this.afterEach(this.store, key, givenArtifactory, afterEachProxy);
|
|
262
401
|
} catch (e) {
|
|
263
402
|
console.error("afterEach failed! no error will be recorded!", e);
|
|
264
403
|
}
|
|
@@ -267,24 +406,24 @@ export abstract class BaseGiven<
|
|
|
267
406
|
}
|
|
268
407
|
}
|
|
269
408
|
|
|
270
|
-
export abstract class BaseWhen<
|
|
271
|
-
ITestShape extends IBaseTest
|
|
272
|
-
> {
|
|
409
|
+
export abstract class BaseWhen<ITestShape extends IBaseTest> {
|
|
273
410
|
public name: string;
|
|
274
|
-
whenCB: (x: ITestShape[
|
|
411
|
+
whenCB: (x: ITestShape["iselection"]) => ITestShape["then"];
|
|
275
412
|
error: boolean;
|
|
276
413
|
|
|
277
414
|
constructor(
|
|
278
415
|
name: string,
|
|
279
|
-
whenCB: (xyz: ITestShape[
|
|
416
|
+
whenCB: (xyz: ITestShape["iselection"]) => ITestShape["then"]
|
|
417
|
+
) {
|
|
280
418
|
this.name = name;
|
|
281
419
|
this.whenCB = whenCB;
|
|
282
420
|
}
|
|
283
421
|
|
|
284
422
|
abstract andWhen(
|
|
285
|
-
store: ITestShape[
|
|
286
|
-
whenCB: (x: ITestShape[
|
|
287
|
-
testResource
|
|
423
|
+
store: ITestShape["istore"],
|
|
424
|
+
whenCB: (x: ITestShape["iselection"]) => ITestShape["then"],
|
|
425
|
+
testResource,
|
|
426
|
+
pm: PM
|
|
288
427
|
);
|
|
289
428
|
|
|
290
429
|
toObj() {
|
|
@@ -295,17 +434,34 @@ export abstract class BaseWhen<
|
|
|
295
434
|
}
|
|
296
435
|
|
|
297
436
|
async test(
|
|
298
|
-
store: ITestShape[
|
|
437
|
+
store: ITestShape["istore"],
|
|
299
438
|
testResourceConfiguration,
|
|
300
439
|
tLog: ITLog,
|
|
301
|
-
|
|
440
|
+
pm: PM,
|
|
441
|
+
key: string
|
|
302
442
|
) {
|
|
303
443
|
tLog(" When:", this.name);
|
|
444
|
+
|
|
445
|
+
const name = this.name;
|
|
446
|
+
const andWhenProxy = new Proxy(pm, {
|
|
447
|
+
get(target, prop, receiver) {
|
|
448
|
+
if (prop === "writeFileSync") {
|
|
449
|
+
console.log("andWhenProxy", arguments, target[prop]);
|
|
450
|
+
return (fp, contents) =>
|
|
451
|
+
// target[prop](`${key}/andWhen/${fp}`, contents);
|
|
452
|
+
target[prop](`${key}/andWhen/${fp}`, contents);
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
return Reflect.get(...arguments);
|
|
456
|
+
},
|
|
457
|
+
});
|
|
458
|
+
|
|
304
459
|
try {
|
|
305
460
|
return await this.andWhen(
|
|
306
461
|
store,
|
|
307
462
|
this.whenCB,
|
|
308
|
-
testResourceConfiguration
|
|
463
|
+
testResourceConfiguration,
|
|
464
|
+
andWhenProxy
|
|
309
465
|
);
|
|
310
466
|
} catch (e) {
|
|
311
467
|
this.error = true;
|
|
@@ -314,16 +470,18 @@ export abstract class BaseWhen<
|
|
|
314
470
|
}
|
|
315
471
|
}
|
|
316
472
|
|
|
317
|
-
export abstract class BaseThen<
|
|
318
|
-
ITestShape extends IBaseTest
|
|
319
|
-
> {
|
|
473
|
+
export abstract class BaseThen<ITestShape extends IBaseTest> {
|
|
320
474
|
public name: string;
|
|
321
|
-
thenCB: (storeState: ITestShape[
|
|
475
|
+
thenCB: (storeState: ITestShape["iselection"]) => ITestShape["then"];
|
|
322
476
|
error: boolean;
|
|
323
477
|
|
|
324
|
-
constructor(
|
|
478
|
+
constructor(
|
|
479
|
+
name: string,
|
|
480
|
+
thenCB: (val: ITestShape["iselection"]) => ITestShape["then"]
|
|
481
|
+
) {
|
|
325
482
|
this.name = name;
|
|
326
483
|
this.thenCB = thenCB;
|
|
484
|
+
this.error = false;
|
|
327
485
|
}
|
|
328
486
|
|
|
329
487
|
toObj() {
|
|
@@ -334,54 +492,42 @@ export abstract class BaseThen<
|
|
|
334
492
|
}
|
|
335
493
|
|
|
336
494
|
abstract butThen(
|
|
337
|
-
store: ITestShape[
|
|
495
|
+
store: ITestShape["istore"],
|
|
338
496
|
thenCB,
|
|
339
497
|
testResourceConfiguration?
|
|
340
|
-
): Promise<ITestShape[
|
|
498
|
+
): Promise<ITestShape["iselection"]>;
|
|
341
499
|
|
|
342
500
|
async test(
|
|
343
|
-
store: ITestShape[
|
|
501
|
+
store: ITestShape["istore"],
|
|
344
502
|
testResourceConfiguration,
|
|
345
503
|
tLog: ITLog,
|
|
346
|
-
|
|
347
|
-
): Promise<ITestShape[
|
|
504
|
+
pm: PM
|
|
505
|
+
): Promise<ITestShape["then"] | undefined> {
|
|
348
506
|
tLog(" Then:", this.name);
|
|
349
507
|
try {
|
|
350
|
-
const x =
|
|
508
|
+
const x = await this.butThen(
|
|
351
509
|
store,
|
|
352
510
|
this.thenCB,
|
|
353
511
|
testResourceConfiguration
|
|
354
|
-
)
|
|
512
|
+
);
|
|
355
513
|
return x;
|
|
356
514
|
} catch (e) {
|
|
357
515
|
console.log("test failed", e);
|
|
358
|
-
this.error =
|
|
516
|
+
this.error = e.message;
|
|
359
517
|
throw e;
|
|
360
518
|
}
|
|
361
519
|
}
|
|
362
520
|
}
|
|
363
521
|
|
|
364
|
-
export abstract class BaseCheck<
|
|
365
|
-
ITestShape extends IBaseTest
|
|
366
|
-
> {
|
|
522
|
+
export abstract class BaseCheck<ITestShape extends IBaseTest> {
|
|
367
523
|
name: string;
|
|
368
524
|
features: string[];
|
|
369
525
|
checkCB: (whens, thens) => any;
|
|
370
526
|
whens: {
|
|
371
|
-
[K in keyof ITestShape["whens"]]: (
|
|
372
|
-
p,
|
|
373
|
-
tc
|
|
374
|
-
) => BaseWhen<
|
|
375
|
-
ITestShape
|
|
376
|
-
>;
|
|
527
|
+
[K in keyof ITestShape["whens"]]: (p, tc) => BaseWhen<ITestShape>;
|
|
377
528
|
};
|
|
378
529
|
thens: {
|
|
379
|
-
[K in keyof ITestShape["thens"]]: (
|
|
380
|
-
p,
|
|
381
|
-
tc
|
|
382
|
-
) => BaseThen<
|
|
383
|
-
ITestShape
|
|
384
|
-
>;
|
|
530
|
+
[K in keyof ITestShape["thens"]]: (p, tc) => BaseThen<ITestShape>;
|
|
385
531
|
};
|
|
386
532
|
|
|
387
533
|
constructor(
|
|
@@ -399,27 +545,28 @@ export abstract class BaseCheck<
|
|
|
399
545
|
}
|
|
400
546
|
|
|
401
547
|
abstract checkThat(
|
|
402
|
-
subject: ITestShape[
|
|
548
|
+
subject: ITestShape["isubject"],
|
|
403
549
|
testResourceConfiguration,
|
|
404
550
|
artifactory: ITestArtifactory
|
|
405
|
-
): Promise<ITestShape[
|
|
551
|
+
): Promise<ITestShape["istore"]>;
|
|
406
552
|
|
|
407
553
|
async afterEach(
|
|
408
|
-
store: ITestShape[
|
|
554
|
+
store: ITestShape["istore"],
|
|
409
555
|
key: string,
|
|
410
|
-
cb
|
|
556
|
+
cb,
|
|
557
|
+
pm: PM
|
|
411
558
|
): Promise<unknown> {
|
|
412
559
|
return;
|
|
413
560
|
}
|
|
414
561
|
|
|
415
562
|
async check(
|
|
416
|
-
subject: ITestShape[
|
|
563
|
+
subject: ITestShape["isubject"],
|
|
417
564
|
key: string,
|
|
418
565
|
testResourceConfiguration,
|
|
419
566
|
tester,
|
|
420
567
|
artifactory: ITestArtifactory,
|
|
421
568
|
tLog: ITLog,
|
|
422
|
-
|
|
569
|
+
pm: PM
|
|
423
570
|
) {
|
|
424
571
|
tLog(`\n Check: ${this.name}`);
|
|
425
572
|
const store = await this.checkThat(
|
|
@@ -434,7 +581,8 @@ export abstract class BaseCheck<
|
|
|
434
581
|
store,
|
|
435
582
|
testResourceConfiguration,
|
|
436
583
|
tLog,
|
|
437
|
-
|
|
584
|
+
pm,
|
|
585
|
+
"x"
|
|
438
586
|
);
|
|
439
587
|
};
|
|
440
588
|
return a;
|
|
@@ -445,7 +593,7 @@ export abstract class BaseCheck<
|
|
|
445
593
|
store,
|
|
446
594
|
testResourceConfiguration,
|
|
447
595
|
tLog,
|
|
448
|
-
|
|
596
|
+
pm
|
|
449
597
|
);
|
|
450
598
|
tester(t);
|
|
451
599
|
};
|
|
@@ -453,7 +601,7 @@ export abstract class BaseCheck<
|
|
|
453
601
|
}, {})
|
|
454
602
|
);
|
|
455
603
|
|
|
456
|
-
await this.afterEach(store, key);
|
|
604
|
+
await this.afterEach(store, key, () => {}, pm);
|
|
457
605
|
return;
|
|
458
606
|
}
|
|
459
607
|
}
|