testeranto 0.49.10 → 0.70.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/.nvmrc +1 -0
- package/README.md +92 -9
- package/dist/cjs-shim.js +12 -0
- package/dist/common/Features.js +2 -3
- package/dist/common/Node.js +37 -62
- package/dist/common/NodeWriter.js +7 -9
- package/dist/common/Project.js +130 -627
- package/dist/common/SubPackages/puppeteer.js +19 -0
- package/dist/common/{subPackages → SubPackages}/react/component/node.js +4 -4
- package/dist/common/{subPackages → SubPackages}/react/component/web.js +4 -4
- package/dist/common/SubPackages/react/jsx/index.js +13 -0
- package/dist/common/SubPackages/react/jsx/node.js +10 -0
- package/dist/common/SubPackages/react/jsx/web.js +10 -0
- package/dist/common/{subPackages → SubPackages}/react-dom/component/node.js +6 -6
- package/dist/common/{subPackages → SubPackages}/react-dom/component/web.js +11 -12
- package/dist/common/SubPackages/react-dom/jsx/node.js +39 -0
- package/dist/common/{subPackages → SubPackages}/react-dom/jsx/web.js +19 -20
- package/dist/common/{subPackages → SubPackages}/react-test-renderer/MemoExoticComponent/node.js +3 -3
- package/dist/common/{subPackages → SubPackages}/react-test-renderer/component/index.js +25 -15
- package/dist/common/{subPackages/react-test-renderer/jsx → SubPackages/react-test-renderer/component}/node.js +3 -5
- package/dist/common/{subPackages/react-test-renderer/jsx → SubPackages/react-test-renderer/component}/web.js +3 -5
- package/dist/common/{subPackages → SubPackages}/react-test-renderer/fc/node.js +4 -4
- package/dist/common/{subPackages → SubPackages}/react-test-renderer/fc/web.js +4 -4
- package/dist/common/{subPackages → SubPackages}/react-test-renderer/jsx/index.js +8 -3
- package/dist/common/{subPackages/react-test-renderer/jsx-promised → SubPackages/react-test-renderer/jsx}/node.js +4 -4
- package/dist/common/{subPackages/react → SubPackages/react-test-renderer}/jsx/web.js +4 -4
- package/dist/common/{subPackages → SubPackages}/react-test-renderer/jsx-promised/index.js +3 -3
- package/dist/common/{subPackages/react/jsx → SubPackages/react-test-renderer/jsx-promised}/node.js +2 -2
- package/dist/common/Types.js +2 -0
- package/dist/common/Web.js +49 -113
- package/dist/common/electron.js +256 -42
- package/dist/common/esbuildConfigs/features.js +14 -0
- package/dist/common/esbuildConfigs/index.js +20 -0
- package/dist/common/esbuildConfigs/node.js +37 -0
- package/dist/common/esbuildConfigs/report.js +13 -0
- package/dist/common/esbuildConfigs/tests.js +13 -0
- package/dist/common/esbuildConfigs/web.js +53 -0
- package/dist/common/lib/abstractBase.js +200 -0
- package/dist/common/lib/basebuilder.js +86 -0
- package/dist/common/lib/classBuilder.js +40 -0
- package/dist/common/lib/core.js +81 -0
- package/dist/common/lib/index.js +21 -0
- package/dist/common/lib/types.js +2 -0
- package/dist/common/preload.js +15 -24
- package/dist/common/puppeteerConfiger.js +24 -0
- package/dist/common/report.html.js +31 -0
- package/dist/common/tsconfig.common.tsbuildinfo +1 -1
- package/dist/common/web.html.js +22 -0
- package/dist/module/Features.js +2 -3
- package/dist/module/Node.js +37 -62
- package/dist/module/NodeWriter.js +7 -9
- package/dist/module/Project.js +131 -605
- package/dist/module/SubPackages/puppeteer.js +14 -0
- package/dist/module/{subPackages → SubPackages}/react/component/node.js +3 -3
- package/dist/module/{subPackages → SubPackages}/react/component/web.js +3 -3
- package/dist/module/SubPackages/react/jsx/index.js +10 -0
- package/dist/module/SubPackages/react/jsx/node.js +5 -0
- package/dist/module/SubPackages/react/jsx/web.js +5 -0
- package/dist/module/{subPackages → SubPackages}/react-dom/component/node.js +7 -7
- package/dist/module/{subPackages → SubPackages}/react-dom/component/web.js +10 -11
- package/dist/module/SubPackages/react-dom/jsx/node.js +31 -0
- package/dist/module/{subPackages → SubPackages}/react-dom/jsx/web.js +20 -21
- package/dist/module/{subPackages → SubPackages}/react-test-renderer/MemoExoticComponent/node.js +3 -3
- package/dist/module/{subPackages → SubPackages}/react-test-renderer/component/index.js +22 -15
- package/dist/module/{subPackages → SubPackages}/react-test-renderer/component/node.js +2 -2
- package/dist/module/{subPackages → SubPackages}/react-test-renderer/component/web.js +2 -2
- package/dist/module/{subPackages → SubPackages}/react-test-renderer/fc/node.js +3 -3
- package/dist/module/{subPackages → SubPackages}/react-test-renderer/fc/web.js +3 -3
- package/dist/module/{subPackages → SubPackages}/react-test-renderer/jsx/index.js +8 -3
- package/dist/module/SubPackages/react-test-renderer/jsx/node.js +5 -0
- package/dist/module/SubPackages/react-test-renderer/jsx/web.js +5 -0
- package/dist/module/{subPackages → SubPackages}/react-test-renderer/jsx-promised/index.js +3 -3
- package/dist/module/{subPackages/react-test-renderer/jsx → SubPackages/react-test-renderer/jsx-promised}/node.js +1 -1
- package/dist/module/Types.js +2 -0
- package/dist/module/Web.js +49 -113
- package/dist/module/electron.js +257 -43
- package/dist/module/esbuildConfigs/features.js +12 -0
- package/dist/module/esbuildConfigs/index.js +18 -0
- package/dist/module/esbuildConfigs/node.js +32 -0
- package/dist/module/esbuildConfigs/report.js +11 -0
- package/dist/module/esbuildConfigs/tests.js +11 -0
- package/dist/module/esbuildConfigs/web.js +48 -0
- package/dist/module/lib/abstractBase.js +192 -0
- package/dist/module/lib/basebuilder.js +82 -0
- package/dist/module/lib/classBuilder.js +36 -0
- package/dist/module/lib/core.js +78 -0
- package/dist/module/lib/index.js +17 -0
- package/dist/module/lib/types.js +1 -0
- package/dist/module/preload.js +12 -24
- package/dist/module/puppeteerConfiger.js +19 -0
- package/dist/module/report.html.js +29 -0
- package/dist/module/tsconfig.module.tsbuildinfo +1 -1
- package/dist/module/web.html.js +20 -0
- package/dist/prebuild/Report.css +10326 -0
- package/dist/prebuild/Report.js +37456 -0
- package/dist/types/Features.d.ts +5 -5
- package/dist/types/Node.d.ts +5 -11
- package/dist/types/NodeWriter.d.ts +1 -1
- package/dist/types/Project.d.ts +2 -28
- package/dist/types/SubPackages/puppeteer.d.ts +6 -0
- package/dist/types/SubPackages/react/component/node.d.ts +7 -0
- package/dist/types/SubPackages/react/component/web.d.ts +7 -0
- package/dist/types/SubPackages/react/jsx/index.d.ts +15 -0
- package/dist/types/SubPackages/react/jsx/node.d.ts +4 -0
- package/dist/types/SubPackages/react/jsx/web.d.ts +4 -0
- package/dist/types/SubPackages/react-dom/component/node.d.ts +12 -0
- package/dist/types/SubPackages/react-dom/component/web.d.ts +5 -0
- package/dist/types/SubPackages/react-dom/jsx/node.d.ts +6 -0
- package/dist/types/SubPackages/react-dom/jsx/web.d.ts +5 -0
- package/dist/types/SubPackages/react-test-renderer/MemoExoticComponent/node.d.ts +5 -0
- package/dist/types/{subPackages → SubPackages}/react-test-renderer/component/index.d.ts +6 -6
- package/dist/types/{subPackages → SubPackages}/react-test-renderer/component/node.d.ts +4 -4
- package/dist/types/SubPackages/react-test-renderer/component/web.d.ts +4 -0
- package/dist/types/SubPackages/react-test-renderer/fc/node.d.ts +8 -0
- package/dist/types/SubPackages/react-test-renderer/fc/web.d.ts +8 -0
- package/dist/types/{subPackages → SubPackages}/react-test-renderer/jsx/index.d.ts +5 -4
- package/dist/types/SubPackages/react-test-renderer/jsx/node.d.ts +9 -0
- package/dist/types/SubPackages/react-test-renderer/jsx/web.d.ts +9 -0
- package/dist/types/{subPackages → SubPackages}/react-test-renderer/jsx-promised/index.d.ts +4 -4
- package/dist/types/SubPackages/react-test-renderer/jsx-promised/node.d.ts +5 -0
- package/dist/types/SubPackages/react-test-renderer/jsx-promised/web.d.ts +5 -0
- package/dist/types/Types.d.ts +49 -17
- package/dist/types/Web.d.ts +5 -11
- package/dist/types/esbuildConfigs/features.d.ts +4 -0
- package/dist/types/esbuildConfigs/index.d.ts +4 -0
- package/dist/types/esbuildConfigs/node.d.ts +4 -0
- package/dist/types/esbuildConfigs/report.d.ts +4 -0
- package/dist/types/esbuildConfigs/tests.d.ts +4 -0
- package/dist/types/esbuildConfigs/web.d.ts +4 -0
- package/dist/types/lib/abstractBase.d.ts +103 -0
- package/dist/types/lib/basebuilder.d.ts +25 -0
- package/dist/types/lib/classBuilder.d.ts +7 -0
- package/dist/types/lib/core.d.ts +8 -0
- package/dist/types/lib/index.d.ts +58 -0
- package/dist/types/lib/types.d.ts +70 -0
- package/dist/types/puppeteerConfiger.d.ts +4 -0
- package/dist/types/report.html.d.ts +2 -0
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/dist/types/web.html.d.ts +2 -0
- package/electronBuild.ts +32 -0
- package/index.html +30 -0
- package/package.json +123 -87
- package/src/Features.ts +2 -4
- package/src/Node.ts +79 -155
- package/src/NodeWriter.ts +22 -22
- package/src/Project.ts +185 -783
- package/src/Report.tsx +30 -15
- package/src/SubPackages/puppeteer.ts +51 -0
- package/src/SubPackages/react/component/node.ts +43 -0
- package/src/SubPackages/react/component/web.ts +43 -0
- package/src/SubPackages/react/jsx/index.ts +32 -0
- package/src/SubPackages/react/jsx/node.ts +29 -0
- package/src/SubPackages/react/jsx/web.ts +30 -0
- package/src/{subPackages → SubPackages}/react-dom/component/node.ts +24 -44
- package/src/SubPackages/react-dom/component/web.ts +104 -0
- package/src/{subPackages → SubPackages}/react-dom/jsx/index.ts +0 -1
- package/src/SubPackages/react-dom/jsx/node.ts +68 -0
- package/src/SubPackages/react-dom/jsx/web.ts +102 -0
- package/src/SubPackages/react-test-renderer/MemoExoticComponent/node.ts +38 -0
- package/src/{subPackages → SubPackages}/react-test-renderer/component/index.ts +37 -49
- package/src/SubPackages/react-test-renderer/component/node.ts +16 -0
- package/src/SubPackages/react-test-renderer/component/web.ts +16 -0
- package/src/SubPackages/react-test-renderer/fc/node.ts +49 -0
- package/src/SubPackages/react-test-renderer/fc/web.ts +48 -0
- package/src/SubPackages/react-test-renderer/jsx/index.ts +49 -0
- package/src/SubPackages/react-test-renderer/jsx/node.ts +20 -0
- package/src/SubPackages/react-test-renderer/jsx/web.ts +20 -0
- package/src/{subPackages → SubPackages}/react-test-renderer/jsx-promised/index.ts +15 -26
- package/src/SubPackages/react-test-renderer/jsx-promised/node.ts +19 -0
- package/src/SubPackages/react-test-renderer/jsx-promised/web.ts +22 -0
- package/src/Types.ts +114 -17
- package/src/Web.ts +100 -225
- package/src/cjs-shim.js +12 -0
- package/src/electron.ts +303 -45
- package/src/esbuildConfigs/features.ts +17 -0
- package/src/esbuildConfigs/index.ts +22 -0
- package/src/esbuildConfigs/node.ts +60 -0
- package/src/esbuildConfigs/report.ts +15 -0
- package/src/esbuildConfigs/tests.ts +14 -0
- package/src/esbuildConfigs/web.ts +73 -0
- package/src/lib/abstractBase.ts +412 -0
- package/src/lib/basebuilder.ts +228 -0
- package/src/lib/classBuilder.ts +118 -0
- package/src/lib/core.ts +214 -0
- package/src/lib/index.ts +117 -0
- package/src/lib/types.ts +206 -0
- package/src/preload.ts +13 -27
- package/src/puppeteerConfiger.ts +26 -0
- package/src/report.html.ts +29 -0
- package/src/web.html.ts +20 -0
- package/tests/Rectangle.test.ts +189 -0
- package/tsconfig.json +19 -6
- package/tsconfig.module.json +15 -4
- package/tsconfig.types.json +14 -4
- package/yarn-error.log +3144 -0
- package/dist/common/core.js +0 -397
- package/dist/common/subPackages/react/jsx/index.js +0 -26
- package/dist/common/subPackages/react-dom/jsx/node.js +0 -95
- package/dist/common/subPackages/react-test-renderer/component/node.js +0 -8
- package/dist/common/subPackages/react-test-renderer/component/web.js +0 -8
- package/dist/module/Report.js +0 -186
- package/dist/module/core.js +0 -388
- package/dist/module/subPackages/react/jsx/index.js +0 -22
- package/dist/module/subPackages/react/jsx/node.js +0 -5
- package/dist/module/subPackages/react/jsx/web.js +0 -5
- package/dist/module/subPackages/react-dom/jsx/node.js +0 -87
- package/dist/module/subPackages/react-test-renderer/jsx/web.js +0 -5
- package/dist/module/subPackages/react-test-renderer/jsx-promised/node.js +0 -5
- package/dist/types/core.d.ts +0 -220
- package/dist/types/subPackages/react/component/node.d.ts +0 -12
- package/dist/types/subPackages/react/component/web.d.ts +0 -12
- package/dist/types/subPackages/react/jsx/index.d.ts +0 -15
- package/dist/types/subPackages/react/jsx/node.d.ts +0 -4
- package/dist/types/subPackages/react/jsx/web.d.ts +0 -4
- package/dist/types/subPackages/react-dom/component/node.d.ts +0 -14
- package/dist/types/subPackages/react-dom/component/web.d.ts +0 -19
- package/dist/types/subPackages/react-dom/jsx/node.d.ts +0 -8
- package/dist/types/subPackages/react-dom/jsx/web.d.ts +0 -5
- package/dist/types/subPackages/react-test-renderer/MemoExoticComponent/node.d.ts +0 -8
- package/dist/types/subPackages/react-test-renderer/component/web.d.ts +0 -9
- package/dist/types/subPackages/react-test-renderer/fc/node.d.ts +0 -9
- package/dist/types/subPackages/react-test-renderer/fc/web.d.ts +0 -9
- package/dist/types/subPackages/react-test-renderer/jsx/node.d.ts +0 -4
- package/dist/types/subPackages/react-test-renderer/jsx/web.d.ts +0 -4
- package/dist/types/subPackages/react-test-renderer/jsx-promised/node.d.ts +0 -4
- package/dist/types/subPackages/react-test-renderer/jsx-promised/web.d.ts +0 -4
- package/src/core.ts +0 -1399
- package/src/subPackages/react/component/node.ts +0 -75
- package/src/subPackages/react/component/web.ts +0 -80
- package/src/subPackages/react/jsx/index.ts +0 -64
- package/src/subPackages/react/jsx/node.ts +0 -29
- package/src/subPackages/react/jsx/web.ts +0 -29
- package/src/subPackages/react-dom/component/web.ts +0 -129
- package/src/subPackages/react-dom/jsx/node.ts +0 -145
- package/src/subPackages/react-dom/jsx/web.ts +0 -145
- package/src/subPackages/react-test-renderer/MemoExoticComponent/node.ts +0 -67
- package/src/subPackages/react-test-renderer/component/node.ts +0 -30
- package/src/subPackages/react-test-renderer/component/web.ts +0 -30
- package/src/subPackages/react-test-renderer/fc/node.ts +0 -77
- package/src/subPackages/react-test-renderer/fc/web.ts +0 -77
- package/src/subPackages/react-test-renderer/jsx/index.ts +0 -51
- package/src/subPackages/react-test-renderer/jsx/node.ts +0 -31
- package/src/subPackages/react-test-renderer/jsx/web.ts +0 -31
- package/src/subPackages/react-test-renderer/jsx-promised/node.ts +0 -31
- package/src/subPackages/react-test-renderer/jsx-promised/web.ts +0 -31
- /package/dist/common/{subPackages → SubPackages}/react-dom/jsx/index.js +0 -0
- /package/dist/common/{subPackages → SubPackages}/react-test-renderer/jsx-promised/web.js +0 -0
- /package/dist/module/{subPackages → SubPackages}/react-dom/jsx/index.js +0 -0
- /package/dist/module/{subPackages → SubPackages}/react-test-renderer/jsx-promised/web.js +0 -0
- /package/dist/types/{subPackages → SubPackages}/react-dom/jsx/index.d.ts +0 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import {
|
|
2
|
+
IBaseTest,
|
|
3
|
+
ITestImplementation,
|
|
4
|
+
ITestSpecification,
|
|
5
|
+
} from "../Types.js";
|
|
6
|
+
|
|
7
|
+
import { BaseBuilder } from "./basebuilder.js";
|
|
8
|
+
|
|
9
|
+
import { ILogWriter, ITTestResourceRequest } from ".";
|
|
10
|
+
import {
|
|
11
|
+
ISuiteKlasser,
|
|
12
|
+
IGivenKlasser,
|
|
13
|
+
IWhenKlasser,
|
|
14
|
+
IThenKlasser,
|
|
15
|
+
ICheckKlasser,
|
|
16
|
+
} from "./types.js";
|
|
17
|
+
|
|
18
|
+
export abstract class ClassBuilder<
|
|
19
|
+
ITestShape extends IBaseTest
|
|
20
|
+
> extends BaseBuilder<ITestShape, any, any, any, any, any> {
|
|
21
|
+
constructor(
|
|
22
|
+
testImplementation: ITestImplementation<ITestShape, any>,
|
|
23
|
+
testSpecification: ITestSpecification<ITestShape>,
|
|
24
|
+
input: ITestShape["iinput"],
|
|
25
|
+
suiteKlasser: ISuiteKlasser<ITestShape>,
|
|
26
|
+
givenKlasser: IGivenKlasser<ITestShape>,
|
|
27
|
+
whenKlasser: IWhenKlasser<ITestShape>,
|
|
28
|
+
thenKlasser: IThenKlasser<ITestShape>,
|
|
29
|
+
checkKlasser: ICheckKlasser<ITestShape>,
|
|
30
|
+
testResourceRequirement: ITTestResourceRequest,
|
|
31
|
+
logWriter: ILogWriter
|
|
32
|
+
) {
|
|
33
|
+
const classySuites = Object.entries(testImplementation.suites).reduce(
|
|
34
|
+
(a, [key], index) => {
|
|
35
|
+
a[key] = (somestring, givens, checks) => {
|
|
36
|
+
return new suiteKlasser.prototype.constructor(
|
|
37
|
+
somestring,
|
|
38
|
+
index,
|
|
39
|
+
givens,
|
|
40
|
+
checks
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
return a;
|
|
44
|
+
},
|
|
45
|
+
{}
|
|
46
|
+
);
|
|
47
|
+
const classyGivens = Object.entries(testImplementation.givens).reduce(
|
|
48
|
+
(a, [key, givEn]) => {
|
|
49
|
+
a[key] = (features, whens, thens, givEn) => {
|
|
50
|
+
return new givenKlasser.prototype.constructor(
|
|
51
|
+
key,
|
|
52
|
+
features,
|
|
53
|
+
whens,
|
|
54
|
+
thens,
|
|
55
|
+
testImplementation.givens[key],
|
|
56
|
+
givEn
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
return a;
|
|
60
|
+
},
|
|
61
|
+
{}
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
const classyWhens = Object.entries(testImplementation.whens).reduce(
|
|
65
|
+
(a, [key, whEn]: [string, (x) => any]) => {
|
|
66
|
+
a[key] = (payload?: any) => {
|
|
67
|
+
return new whenKlasser.prototype.constructor(
|
|
68
|
+
`${whEn.name}: ${payload && payload.toString()}`,
|
|
69
|
+
whEn(payload)
|
|
70
|
+
);
|
|
71
|
+
};
|
|
72
|
+
return a;
|
|
73
|
+
},
|
|
74
|
+
{}
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
const classyThens = Object.entries(testImplementation.thens).reduce(
|
|
78
|
+
(a, [key, thEn]: [string, (x) => any]) => {
|
|
79
|
+
a[key] = (expected: any, x) => {
|
|
80
|
+
return new thenKlasser.prototype.constructor(
|
|
81
|
+
`${thEn.name}: ${expected && expected.toString()}`,
|
|
82
|
+
thEn(expected)
|
|
83
|
+
);
|
|
84
|
+
};
|
|
85
|
+
return a;
|
|
86
|
+
},
|
|
87
|
+
{}
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
const classyChecks = Object.entries(testImplementation.checks).reduce(
|
|
91
|
+
(a, [key, z]) => {
|
|
92
|
+
a[key] = (somestring, features, callback) => {
|
|
93
|
+
return new checkKlasser.prototype.constructor(
|
|
94
|
+
somestring,
|
|
95
|
+
features,
|
|
96
|
+
callback,
|
|
97
|
+
classyWhens,
|
|
98
|
+
classyThens
|
|
99
|
+
);
|
|
100
|
+
};
|
|
101
|
+
return a;
|
|
102
|
+
},
|
|
103
|
+
{}
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
super(
|
|
107
|
+
input,
|
|
108
|
+
classySuites,
|
|
109
|
+
classyGivens,
|
|
110
|
+
classyWhens,
|
|
111
|
+
classyThens,
|
|
112
|
+
classyChecks,
|
|
113
|
+
logWriter,
|
|
114
|
+
testResourceRequirement,
|
|
115
|
+
testSpecification
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
}
|
package/src/lib/core.ts
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { IStore } from "../SubPackages/react/jsx";
|
|
2
|
+
import {
|
|
3
|
+
IBaseTest,
|
|
4
|
+
ITestSpecification,
|
|
5
|
+
ITestImplementation,
|
|
6
|
+
} from "../Types.js";
|
|
7
|
+
|
|
8
|
+
import { ITestInterface, IUtils } from "./types.js";
|
|
9
|
+
import {
|
|
10
|
+
DefaultTestInterface,
|
|
11
|
+
ILogWriter,
|
|
12
|
+
ITTestResourceConfiguration,
|
|
13
|
+
ITTestResourceRequest,
|
|
14
|
+
ITestArtifactory,
|
|
15
|
+
ITestJob,
|
|
16
|
+
defaultTestResourceRequirement,
|
|
17
|
+
} from "./index.js";
|
|
18
|
+
import {
|
|
19
|
+
BaseSuite,
|
|
20
|
+
BaseGiven,
|
|
21
|
+
BaseWhen,
|
|
22
|
+
BaseThen,
|
|
23
|
+
BaseCheck,
|
|
24
|
+
} from "./abstractBase.js";
|
|
25
|
+
import { ClassBuilder } from "./classBuilder.js";
|
|
26
|
+
|
|
27
|
+
export default abstract class Testeranto<
|
|
28
|
+
ITestShape extends IBaseTest
|
|
29
|
+
> extends ClassBuilder<ITestShape> {
|
|
30
|
+
constructor(
|
|
31
|
+
input: ITestShape["iinput"],
|
|
32
|
+
testSpecification: ITestSpecification<ITestShape>,
|
|
33
|
+
testImplementation: ITestImplementation<ITestShape>,
|
|
34
|
+
testResourceRequirement: ITTestResourceRequest = defaultTestResourceRequirement,
|
|
35
|
+
logWriter: ILogWriter,
|
|
36
|
+
testInterface: Partial<ITestInterface<ITestShape>>
|
|
37
|
+
) {
|
|
38
|
+
const fullTestInterface = DefaultTestInterface(testInterface);
|
|
39
|
+
|
|
40
|
+
super(
|
|
41
|
+
testImplementation,
|
|
42
|
+
testSpecification,
|
|
43
|
+
input,
|
|
44
|
+
|
|
45
|
+
class extends BaseSuite<ITestShape> {
|
|
46
|
+
assertThat(t) {
|
|
47
|
+
fullTestInterface.assertThis(t);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async setup(
|
|
51
|
+
s: ITestShape["iinput"],
|
|
52
|
+
artifactory: ITestArtifactory,
|
|
53
|
+
tr,
|
|
54
|
+
utils
|
|
55
|
+
): Promise<ITestShape["isubject"]> {
|
|
56
|
+
return (
|
|
57
|
+
fullTestInterface.beforeAll ||
|
|
58
|
+
(async (
|
|
59
|
+
input: ITestShape["iinput"],
|
|
60
|
+
artifactory: ITestArtifactory,
|
|
61
|
+
tr,
|
|
62
|
+
utils: ITestInterface<ITestShape>
|
|
63
|
+
) => input as any)
|
|
64
|
+
)(s, this.testResourceConfiguration, artifactory, utils);
|
|
65
|
+
}
|
|
66
|
+
} as any,
|
|
67
|
+
|
|
68
|
+
class Given extends BaseGiven<ITestShape> {
|
|
69
|
+
async givenThat(subject, testResource, artifactory, initializer) {
|
|
70
|
+
return fullTestInterface.beforeEach(
|
|
71
|
+
subject,
|
|
72
|
+
initializer,
|
|
73
|
+
(fPath: string, value: unknown) =>
|
|
74
|
+
// TODO does not work?
|
|
75
|
+
artifactory(`beforeEach/${fPath}`, value),
|
|
76
|
+
testResource,
|
|
77
|
+
this.initialValues
|
|
78
|
+
// utils,
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
afterEach(
|
|
83
|
+
store: ITestShape["istore"],
|
|
84
|
+
key: string,
|
|
85
|
+
artifactory,
|
|
86
|
+
utils
|
|
87
|
+
): Promise<unknown> {
|
|
88
|
+
return new Promise((res) =>
|
|
89
|
+
res(
|
|
90
|
+
fullTestInterface.afterEach(
|
|
91
|
+
store,
|
|
92
|
+
key,
|
|
93
|
+
(fPath: string, value: unknown) =>
|
|
94
|
+
artifactory(`after/${fPath}`, value),
|
|
95
|
+
utils
|
|
96
|
+
)
|
|
97
|
+
)
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
afterAll(store: IStore, artifactory: ITestArtifactory, utils: IUtils) {
|
|
101
|
+
const pagesHandler = {
|
|
102
|
+
get(target, prop) {
|
|
103
|
+
console.log(`Getting pages property ${prop}`);
|
|
104
|
+
return target[prop];
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const browserHandler = {
|
|
109
|
+
get(target, prop) {
|
|
110
|
+
console.log(`Getting browser property ${prop}`);
|
|
111
|
+
if (prop === "pages") {
|
|
112
|
+
// return target[prop];
|
|
113
|
+
return new Proxy(target[prop], pagesHandler);
|
|
114
|
+
} else {
|
|
115
|
+
return target[prop];
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
const proxy = new Proxy(utils.browser, browserHandler);
|
|
120
|
+
|
|
121
|
+
return fullTestInterface.afterAll(
|
|
122
|
+
store,
|
|
123
|
+
(fPath: string, value: unknown) =>
|
|
124
|
+
// TODO does not work?
|
|
125
|
+
{
|
|
126
|
+
artifactory(`afterAll4-${this.name}/${fPath}`, value);
|
|
127
|
+
},
|
|
128
|
+
utils
|
|
129
|
+
// {
|
|
130
|
+
// ...utils,
|
|
131
|
+
// browser: proxy,
|
|
132
|
+
// }
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
} as any,
|
|
136
|
+
|
|
137
|
+
class When extends BaseWhen<ITestShape> {
|
|
138
|
+
async andWhen(store, whenCB, testResource) {
|
|
139
|
+
return await fullTestInterface.andWhen(store, whenCB, testResource);
|
|
140
|
+
}
|
|
141
|
+
} as any,
|
|
142
|
+
|
|
143
|
+
class Then extends BaseThen<ITestShape> {
|
|
144
|
+
async butThen(
|
|
145
|
+
store: any,
|
|
146
|
+
thenCB,
|
|
147
|
+
testResourceConfiguration?: any
|
|
148
|
+
): Promise<ITestShape["iselection"]> {
|
|
149
|
+
return await fullTestInterface.butThen(
|
|
150
|
+
store,
|
|
151
|
+
thenCB,
|
|
152
|
+
testResourceConfiguration
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
} as any,
|
|
156
|
+
|
|
157
|
+
class Check extends BaseCheck<ITestShape> {
|
|
158
|
+
initialValues: any;
|
|
159
|
+
|
|
160
|
+
constructor(
|
|
161
|
+
name: string,
|
|
162
|
+
features: string[],
|
|
163
|
+
checkCallback: (a, b) => any,
|
|
164
|
+
whens,
|
|
165
|
+
thens,
|
|
166
|
+
initialValues: any
|
|
167
|
+
) {
|
|
168
|
+
super(name, features, checkCallback, whens, thens);
|
|
169
|
+
this.initialValues = initialValues;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
async checkThat(subject, testResourceConfiguration, artifactory) {
|
|
173
|
+
return fullTestInterface.beforeEach(
|
|
174
|
+
subject,
|
|
175
|
+
this.initialValues,
|
|
176
|
+
(fPath: string, value: unknown) =>
|
|
177
|
+
artifactory(`before/${fPath}`, value),
|
|
178
|
+
testResourceConfiguration,
|
|
179
|
+
this.initialValues
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
afterEach(
|
|
184
|
+
store: ITestShape["istore"],
|
|
185
|
+
key: string,
|
|
186
|
+
artifactory,
|
|
187
|
+
utils
|
|
188
|
+
): Promise<unknown> {
|
|
189
|
+
return new Promise((res) =>
|
|
190
|
+
res(
|
|
191
|
+
fullTestInterface.afterEach(
|
|
192
|
+
store,
|
|
193
|
+
key,
|
|
194
|
+
(fPath: string, value: unknown) =>
|
|
195
|
+
// TODO does not work?
|
|
196
|
+
artifactory(`afterEach2-${this.name}/${fPath}`, value),
|
|
197
|
+
utils
|
|
198
|
+
)
|
|
199
|
+
)
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
} as any,
|
|
203
|
+
|
|
204
|
+
testResourceRequirement,
|
|
205
|
+
logWriter
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
abstract receiveTestResourceConfig(
|
|
210
|
+
t: ITestJob,
|
|
211
|
+
partialTestResource: ITTestResourceConfiguration,
|
|
212
|
+
utils: IUtils
|
|
213
|
+
);
|
|
214
|
+
}
|
package/src/lib/index.ts
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { IBaseTest } from "../Types.js";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
IGivens,
|
|
5
|
+
BaseCheck,
|
|
6
|
+
BaseSuite,
|
|
7
|
+
BaseWhen,
|
|
8
|
+
BaseThen,
|
|
9
|
+
} from "./abstractBase.js";
|
|
10
|
+
|
|
11
|
+
import { INodeUtils, ITestInterface, IUtils, IWebUtils } from "./types.js";
|
|
12
|
+
|
|
13
|
+
export const BaseTestInterface: ITestInterface<IBaseTest> = {
|
|
14
|
+
beforeAll: async (s) => s,
|
|
15
|
+
beforeEach: async function (
|
|
16
|
+
subject: any,
|
|
17
|
+
initialValues: any,
|
|
18
|
+
testResource: any
|
|
19
|
+
) {
|
|
20
|
+
return subject as any;
|
|
21
|
+
},
|
|
22
|
+
afterEach: async (s) => s,
|
|
23
|
+
afterAll: (store: IBaseTest["istore"]) => undefined,
|
|
24
|
+
butThen: async (store: IBaseTest["istore"], thenCb) => thenCb(store),
|
|
25
|
+
andWhen: (a) => a,
|
|
26
|
+
assertThis: () => null,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const DefaultTestInterface = (
|
|
30
|
+
p: Partial<ITestInterface<any>>
|
|
31
|
+
): ITestInterface<any> => {
|
|
32
|
+
return {
|
|
33
|
+
...BaseTestInterface,
|
|
34
|
+
...p,
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type ITTestResourceConfiguration = {
|
|
39
|
+
name: string;
|
|
40
|
+
fs: string;
|
|
41
|
+
ports: number[];
|
|
42
|
+
scheduled: boolean;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export type ITTestResourceRequirement = {
|
|
46
|
+
name: string;
|
|
47
|
+
ports: number;
|
|
48
|
+
fs: string;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export type ITTestResourceRequest = {
|
|
52
|
+
ports: number;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export type ITLog = (...string) => void;
|
|
56
|
+
|
|
57
|
+
export type ILogWriter = {
|
|
58
|
+
createWriteStream: (line: string) => any | any;
|
|
59
|
+
writeFileSync: (fp: string, contents: string) => any;
|
|
60
|
+
mkdirSync: (fp: string) => any;
|
|
61
|
+
testArtiFactoryfileWriter: (
|
|
62
|
+
tLog: ITLog,
|
|
63
|
+
n: (Promise) => void
|
|
64
|
+
) => (fPath: string, value: unknown) => void;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export type ITestArtificer = (key: string, data: any) => void;
|
|
68
|
+
|
|
69
|
+
type ITest = {
|
|
70
|
+
toObj(): object;
|
|
71
|
+
name: string;
|
|
72
|
+
givens: IGivens<IBaseTest>;
|
|
73
|
+
checks: BaseCheck<IBaseTest>[];
|
|
74
|
+
testResourceConfiguration: ITTestResourceConfiguration;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export type ITestJob<T = INodeUtils | IWebUtils> = {
|
|
78
|
+
toObj(): object;
|
|
79
|
+
test: ITest;
|
|
80
|
+
runner: (
|
|
81
|
+
x: ITTestResourceConfiguration,
|
|
82
|
+
t: ITLog
|
|
83
|
+
) => Promise<BaseSuite<IBaseTest>>;
|
|
84
|
+
testResourceRequirement: ITTestResourceRequirement;
|
|
85
|
+
receiveTestResourceConfig: (
|
|
86
|
+
testResource,
|
|
87
|
+
utils: T
|
|
88
|
+
) => Promise<{
|
|
89
|
+
failed: number;
|
|
90
|
+
artifacts: Promise<unknown>[];
|
|
91
|
+
logPromise: Promise<unknown>;
|
|
92
|
+
}>;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export type ITestResults = Promise<{ test: ITest }>[];
|
|
96
|
+
|
|
97
|
+
export const defaultTestResourceRequirement: ITTestResourceRequest = {
|
|
98
|
+
ports: 0,
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export type ITestArtifactory = (key: string, value: unknown) => unknown;
|
|
102
|
+
|
|
103
|
+
export type ITestCheckCallback<ITestShape extends IBaseTest> = {
|
|
104
|
+
[K in keyof ITestShape["checks"]]: (
|
|
105
|
+
name: string,
|
|
106
|
+
features: string[],
|
|
107
|
+
callbackA: (
|
|
108
|
+
whens: {
|
|
109
|
+
[K in keyof ITestShape["whens"]]: (...unknown) => BaseWhen<ITestShape>;
|
|
110
|
+
},
|
|
111
|
+
thens: {
|
|
112
|
+
[K in keyof ITestShape["thens"]]: (...unknown) => BaseThen<ITestShape>;
|
|
113
|
+
}
|
|
114
|
+
) => Promise<any>,
|
|
115
|
+
...xtrasA: ITestShape["checks"][K]
|
|
116
|
+
) => BaseCheck<ITestShape>;
|
|
117
|
+
};
|
package/src/lib/types.ts
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { IBaseTest } from "../Types";
|
|
2
|
+
|
|
3
|
+
import puppeteer from "puppeteer-core";
|
|
4
|
+
import {
|
|
5
|
+
IGivens,
|
|
6
|
+
BaseCheck,
|
|
7
|
+
BaseSuite,
|
|
8
|
+
BaseGiven,
|
|
9
|
+
BaseWhen,
|
|
10
|
+
BaseThen,
|
|
11
|
+
} from "./abstractBase";
|
|
12
|
+
import { ITTestResourceConfiguration, ITestArtificer } from ".";
|
|
13
|
+
|
|
14
|
+
export type IRunTime = `node` | `web`;
|
|
15
|
+
|
|
16
|
+
export type ITestTypes = [string, IRunTime, ITestTypes[]];
|
|
17
|
+
|
|
18
|
+
export type IJsonConfig = {
|
|
19
|
+
outdir: string;
|
|
20
|
+
tests: ITestTypes[];
|
|
21
|
+
features: string;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type IBaseConfig = {
|
|
25
|
+
clearScreen: boolean;
|
|
26
|
+
debugger: boolean;
|
|
27
|
+
devMode: boolean;
|
|
28
|
+
externals: string[];
|
|
29
|
+
features: string;
|
|
30
|
+
minify: boolean;
|
|
31
|
+
nodePlugins: any[];
|
|
32
|
+
outbase: string;
|
|
33
|
+
outdir: string;
|
|
34
|
+
ports: string[];
|
|
35
|
+
tests: ITestTypes[];
|
|
36
|
+
webPlugins: any[];
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export type IBuiltConfig = { buildDir: string } & IBaseConfig;
|
|
40
|
+
|
|
41
|
+
export type INodeUtils = {
|
|
42
|
+
browser: puppeteer.Browser;
|
|
43
|
+
ipc: Electron.ParentPort;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export type IWebUtils = {
|
|
47
|
+
browser: puppeteer.Browser;
|
|
48
|
+
ipc: Electron.IpcRenderer;
|
|
49
|
+
};
|
|
50
|
+
export type IUtils = INodeUtils | IWebUtils;
|
|
51
|
+
|
|
52
|
+
export type IWebTestInterface<ITestShape extends IBaseTest> = {
|
|
53
|
+
assertThis: (x: ITestShape["then"]) => void;
|
|
54
|
+
|
|
55
|
+
andWhen: (
|
|
56
|
+
store: ITestShape["istore"],
|
|
57
|
+
whenCB: ITestShape["when"],
|
|
58
|
+
testResource: ITTestResourceConfiguration
|
|
59
|
+
) => Promise<ITestShape["istore"]>;
|
|
60
|
+
butThen: (
|
|
61
|
+
store: ITestShape["istore"],
|
|
62
|
+
thenCB,
|
|
63
|
+
testResource: ITTestResourceConfiguration
|
|
64
|
+
) => Promise<ITestShape["iselection"]>;
|
|
65
|
+
|
|
66
|
+
afterAll: (
|
|
67
|
+
store: ITestShape["istore"],
|
|
68
|
+
artificer: ITestArtificer,
|
|
69
|
+
browser: IWebUtils
|
|
70
|
+
) => any;
|
|
71
|
+
afterEach: (
|
|
72
|
+
store: ITestShape["istore"],
|
|
73
|
+
key: string,
|
|
74
|
+
artificer: ITestArtificer,
|
|
75
|
+
utils: IWebUtils
|
|
76
|
+
) => Promise<unknown>;
|
|
77
|
+
beforeAll: (
|
|
78
|
+
input: ITestShape["iinput"],
|
|
79
|
+
testResource: ITTestResourceConfiguration,
|
|
80
|
+
artificer: ITestArtificer,
|
|
81
|
+
utils: IWebUtils
|
|
82
|
+
) => Promise<ITestShape["isubject"]>;
|
|
83
|
+
beforeEach: (
|
|
84
|
+
subject: ITestShape["isubject"],
|
|
85
|
+
initializer: (c?) => ITestShape["given"],
|
|
86
|
+
artificer: ITestArtificer,
|
|
87
|
+
testResource: ITTestResourceConfiguration,
|
|
88
|
+
initialValues
|
|
89
|
+
// utils: IUtils
|
|
90
|
+
) => Promise<ITestShape["istore"]>;
|
|
91
|
+
};
|
|
92
|
+
// & ITestInterface<ITestShape>;
|
|
93
|
+
|
|
94
|
+
export type INodeTestInterface<ITestShape extends IBaseTest> = {
|
|
95
|
+
assertThis: (x: ITestShape["then"]) => void;
|
|
96
|
+
andWhen: (
|
|
97
|
+
store: ITestShape["istore"],
|
|
98
|
+
whenCB: ITestShape["when"],
|
|
99
|
+
testResource: ITTestResourceConfiguration
|
|
100
|
+
) => Promise<ITestShape["istore"]>;
|
|
101
|
+
butThen: (
|
|
102
|
+
store: ITestShape["istore"],
|
|
103
|
+
thenCB,
|
|
104
|
+
testResource: ITTestResourceConfiguration
|
|
105
|
+
) => Promise<ITestShape["iselection"]>;
|
|
106
|
+
afterAll: (
|
|
107
|
+
store: ITestShape["istore"],
|
|
108
|
+
artificer: ITestArtificer,
|
|
109
|
+
utils: INodeUtils
|
|
110
|
+
) => any;
|
|
111
|
+
afterEach: (
|
|
112
|
+
store: ITestShape["istore"],
|
|
113
|
+
key: string,
|
|
114
|
+
artificer: ITestArtificer,
|
|
115
|
+
utils: INodeUtils
|
|
116
|
+
) => Promise<unknown>;
|
|
117
|
+
beforeAll: (
|
|
118
|
+
input: ITestShape["iinput"],
|
|
119
|
+
testResource: ITTestResourceConfiguration,
|
|
120
|
+
artificer: ITestArtificer,
|
|
121
|
+
utils: INodeUtils
|
|
122
|
+
) => Promise<ITestShape["isubject"]>;
|
|
123
|
+
beforeEach: (
|
|
124
|
+
subject: ITestShape["isubject"],
|
|
125
|
+
initializer: (c?) => ITestShape["given"],
|
|
126
|
+
artificer: ITestArtificer,
|
|
127
|
+
testResource: ITTestResourceConfiguration,
|
|
128
|
+
initialValues
|
|
129
|
+
// utils: IUtils
|
|
130
|
+
) => Promise<ITestShape["istore"]>;
|
|
131
|
+
};
|
|
132
|
+
// & ITestInterface<ITestShape>;
|
|
133
|
+
|
|
134
|
+
export type ITestInterface<ITestShape extends IBaseTest> = {
|
|
135
|
+
assertThis: (x: ITestShape["then"]) => void;
|
|
136
|
+
|
|
137
|
+
andWhen: (
|
|
138
|
+
store: ITestShape["istore"],
|
|
139
|
+
whenCB: ITestShape["when"],
|
|
140
|
+
testResource: ITTestResourceConfiguration
|
|
141
|
+
) => Promise<ITestShape["istore"]>;
|
|
142
|
+
butThen: (
|
|
143
|
+
store: ITestShape["istore"],
|
|
144
|
+
thenCB,
|
|
145
|
+
testResource: ITTestResourceConfiguration
|
|
146
|
+
) => Promise<ITestShape["iselection"]>;
|
|
147
|
+
|
|
148
|
+
afterAll: (
|
|
149
|
+
store: ITestShape["istore"],
|
|
150
|
+
artificer: ITestArtificer,
|
|
151
|
+
utils: IUtils
|
|
152
|
+
) => any;
|
|
153
|
+
afterEach: (
|
|
154
|
+
store: ITestShape["istore"],
|
|
155
|
+
key: string,
|
|
156
|
+
artificer: ITestArtificer,
|
|
157
|
+
utils: IUtils
|
|
158
|
+
) => Promise<unknown>;
|
|
159
|
+
beforeAll: (
|
|
160
|
+
input: ITestShape["iinput"],
|
|
161
|
+
testResource: ITTestResourceConfiguration,
|
|
162
|
+
artificer: ITestArtificer,
|
|
163
|
+
utils: IUtils
|
|
164
|
+
) => Promise<ITestShape["isubject"]>;
|
|
165
|
+
beforeEach: (
|
|
166
|
+
subject: ITestShape["isubject"],
|
|
167
|
+
initializer: (c?) => ITestShape["given"],
|
|
168
|
+
artificer: ITestArtificer,
|
|
169
|
+
testResource: ITTestResourceConfiguration,
|
|
170
|
+
initialValues
|
|
171
|
+
// utils: IUtils
|
|
172
|
+
) => Promise<ITestShape["istore"]>;
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
export type ISuiteKlasser<ITestShape extends IBaseTest> = (
|
|
176
|
+
name: string,
|
|
177
|
+
index: number,
|
|
178
|
+
givens: IGivens<ITestShape>,
|
|
179
|
+
checks: BaseCheck<ITestShape>[]
|
|
180
|
+
) => BaseSuite<ITestShape>;
|
|
181
|
+
|
|
182
|
+
export type IGivenKlasser<ITestShape extends IBaseTest> = (
|
|
183
|
+
name,
|
|
184
|
+
features,
|
|
185
|
+
whens,
|
|
186
|
+
thens,
|
|
187
|
+
givenCB
|
|
188
|
+
) => BaseGiven<ITestShape>;
|
|
189
|
+
|
|
190
|
+
export type IWhenKlasser<ITestShape extends IBaseTest> = (
|
|
191
|
+
s,
|
|
192
|
+
o
|
|
193
|
+
) => BaseWhen<ITestShape>;
|
|
194
|
+
|
|
195
|
+
export type IThenKlasser<ITestShape extends IBaseTest> = (
|
|
196
|
+
s,
|
|
197
|
+
o
|
|
198
|
+
) => BaseThen<ITestShape>;
|
|
199
|
+
|
|
200
|
+
export type ICheckKlasser<ITestShape extends IBaseTest> = (
|
|
201
|
+
n,
|
|
202
|
+
f,
|
|
203
|
+
cb,
|
|
204
|
+
w,
|
|
205
|
+
t
|
|
206
|
+
) => BaseCheck<ITestShape>;
|
package/src/preload.ts
CHANGED
|
@@ -1,31 +1,17 @@
|
|
|
1
|
+
import puppeteer from "puppeteer-core";
|
|
2
|
+
|
|
1
3
|
import { NodeWriter } from "./NodeWriter";
|
|
2
|
-
import
|
|
4
|
+
import puppeteerConfiger from "./puppeteerConfiger";
|
|
3
5
|
|
|
4
6
|
(window as any).NodeWriter = NodeWriter;
|
|
5
|
-
(window as any).exit = (x) => {
|
|
6
|
-
ipcRenderer.invoke('quit-app', x);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
var oldLog = console.log;
|
|
10
|
-
console.log = function (message) {
|
|
11
|
-
ipcRenderer.invoke('web-log', message.toString());
|
|
12
|
-
oldLog.apply(console, arguments);
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
var oldLog = console.error;
|
|
16
|
-
console.error = function (message) {
|
|
17
|
-
ipcRenderer.invoke('web-error', message.toString());
|
|
18
|
-
oldLog.apply(console, arguments);
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
var oldLog = console.warn;
|
|
22
|
-
console.warn = function (message) {
|
|
23
|
-
ipcRenderer.invoke('web-warn', message.toString());
|
|
24
|
-
oldLog.apply(console, arguments);
|
|
25
|
-
};
|
|
26
7
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
8
|
+
(window as any).browser = new Promise(async (res, rej) => {
|
|
9
|
+
const browser = await puppeteerConfiger("2999").then(async (json) => {
|
|
10
|
+
const b = await puppeteer.connect({
|
|
11
|
+
browserWSEndpoint: json.webSocketDebuggerUrl,
|
|
12
|
+
defaultViewport: null,
|
|
13
|
+
});
|
|
14
|
+
console.log("connected!", b.isConnected());
|
|
15
|
+
return res(b);
|
|
16
|
+
});
|
|
17
|
+
});
|