testeranto 0.62.0 → 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/README.md +42 -21
- package/dist/cjs-shim.js +2 -2
- package/dist/common/Node.js +7 -24
- package/dist/common/NodeWriter.js +7 -9
- package/dist/common/Project.js +103 -266
- package/dist/common/SubPackages/puppeteer.js +1 -1
- package/dist/common/SubPackages/react-dom/component/web.js +1 -1
- 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 -2
- 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 -18
- package/dist/common/electron.js +177 -107
- 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 +14 -11
- package/dist/common/lib/abstractBase.js +13 -6
- package/dist/common/lib/basebuilder.js +11 -11
- package/dist/common/lib/classBuilder.js +2 -3
- package/dist/common/lib/core.js +37 -8
- package/dist/common/lib/index.js +10 -8
- package/dist/common/lib/types.js +2 -0
- package/dist/common/preload.js +15 -25
- package/dist/common/puppeteerConfiger.js +24 -0
- package/dist/common/tsconfig.common.tsbuildinfo +1 -1
- package/dist/module/Node.js +7 -24
- package/dist/module/NodeWriter.js +7 -9
- package/dist/module/Project.js +104 -267
- package/dist/module/SubPackages/puppeteer.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 +1 -1
- 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 -2
- 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 -19
- package/dist/module/electron.js +179 -109
- 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 +14 -11
- package/dist/module/lib/abstractBase.js +13 -6
- package/dist/module/lib/basebuilder.js +11 -11
- package/dist/module/lib/classBuilder.js +2 -3
- package/dist/module/lib/core.js +39 -10
- package/dist/module/lib/index.js +10 -8
- package/dist/module/lib/types.js +1 -0
- package/dist/module/preload.js +12 -25
- package/dist/module/puppeteerConfiger.js +19 -0
- package/dist/module/tsconfig.module.tsbuildinfo +1 -1
- package/dist/types/Node.d.ts +3 -2
- package/dist/types/Project.d.ts +1 -2
- 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 +25 -24
- package/dist/types/lib/basebuilder.d.ts +8 -7
- package/dist/types/lib/classBuilder.d.ts +3 -2
- package/dist/types/lib/core.d.ts +3 -2
- package/dist/types/lib/index.d.ts +4 -3
- package/dist/types/lib/types.d.ts +70 -0
- package/dist/types/puppeteerConfiger.d.ts +4 -0
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +4 -3
- package/src/Node.ts +24 -54
- package/src/NodeWriter.ts +21 -18
- package/src/Project.ts +165 -620
- package/src/Report.tsx +1 -1
- 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/web.ts +10 -8
- package/src/SubPackages/react-dom/component/node.ts +17 -23
- package/src/SubPackages/react-dom/component/web.ts +30 -50
- 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 +16 -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 +54 -53
- package/src/cjs-shim.js +2 -2
- package/src/electron.ts +258 -191
- 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 +18 -18
- package/src/lib/abstractBase.ts +78 -125
- package/src/lib/basebuilder.ts +109 -134
- package/src/lib/classBuilder.ts +26 -45
- package/src/lib/core.ts +101 -69
- package/src/lib/index.ts +53 -52
- package/src/lib/types.ts +206 -0
- package/src/preload.ts +12 -28
- package/src/puppeteerConfiger.ts +26 -0
- package/src/web.html.ts +1 -1
- package/dist/common/lib/browser.js +0 -26
- package/dist/common/nodeWriterElectron.js +0 -55
- package/dist/module/lib/browser.js +0 -22
- package/dist/module/nodeWriterElectron.js +0 -52
- package/dist/types/lib/browser.d.ts +0 -6
- package/dist/types/nodeWriterElectron.d.ts +0 -2
- package/src/lib/browser.ts +0 -34
- package/src/nodeWriterElectron.ts +0 -71
package/src/lib/core.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { IStore } from "../SubPackages/react/jsx";
|
|
2
|
+
import {
|
|
3
|
+
IBaseTest,
|
|
4
|
+
ITestSpecification,
|
|
5
|
+
ITestImplementation,
|
|
6
|
+
} from "../Types.js";
|
|
4
7
|
|
|
8
|
+
import { ITestInterface, IUtils } from "./types.js";
|
|
5
9
|
import {
|
|
6
10
|
DefaultTestInterface,
|
|
7
11
|
ILogWriter,
|
|
@@ -9,24 +13,27 @@ import {
|
|
|
9
13
|
ITTestResourceRequest,
|
|
10
14
|
ITestArtifactory,
|
|
11
15
|
ITestJob,
|
|
12
|
-
defaultTestResourceRequirement
|
|
16
|
+
defaultTestResourceRequirement,
|
|
13
17
|
} from "./index.js";
|
|
14
18
|
import {
|
|
15
|
-
BaseSuite,
|
|
19
|
+
BaseSuite,
|
|
20
|
+
BaseGiven,
|
|
21
|
+
BaseWhen,
|
|
22
|
+
BaseThen,
|
|
23
|
+
BaseCheck,
|
|
16
24
|
} from "./abstractBase.js";
|
|
17
|
-
import {
|
|
18
|
-
ClassBuilder
|
|
19
|
-
} from "./classBuilder.js";
|
|
20
|
-
import { IStore } from "../SubPackages/react/jsx";
|
|
25
|
+
import { ClassBuilder } from "./classBuilder.js";
|
|
21
26
|
|
|
22
|
-
export default abstract class Testeranto<
|
|
27
|
+
export default abstract class Testeranto<
|
|
28
|
+
ITestShape extends IBaseTest
|
|
29
|
+
> extends ClassBuilder<ITestShape> {
|
|
23
30
|
constructor(
|
|
24
|
-
input: ITestShape[
|
|
31
|
+
input: ITestShape["iinput"],
|
|
25
32
|
testSpecification: ITestSpecification<ITestShape>,
|
|
26
|
-
testImplementation: ITestImplementation<ITestShape
|
|
33
|
+
testImplementation: ITestImplementation<ITestShape>,
|
|
27
34
|
testResourceRequirement: ITTestResourceRequest = defaultTestResourceRequirement,
|
|
28
35
|
logWriter: ILogWriter,
|
|
29
|
-
testInterface: Partial<ITestInterface<ITestShape
|
|
36
|
+
testInterface: Partial<ITestInterface<ITestShape>>
|
|
30
37
|
) {
|
|
31
38
|
const fullTestInterface = DefaultTestInterface(testInterface);
|
|
32
39
|
|
|
@@ -35,39 +42,30 @@ export default abstract class Testeranto<ITestShape extends IBaseTest> extends C
|
|
|
35
42
|
testSpecification,
|
|
36
43
|
input,
|
|
37
44
|
|
|
38
|
-
class extends BaseSuite<
|
|
39
|
-
ITestShape
|
|
40
|
-
> {
|
|
41
|
-
|
|
45
|
+
class extends BaseSuite<ITestShape> {
|
|
42
46
|
assertThat(t) {
|
|
43
47
|
fullTestInterface.assertThis(t);
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
async setup(
|
|
47
|
-
s: ITestShape[
|
|
51
|
+
s: ITestShape["iinput"],
|
|
48
52
|
artifactory: ITestArtifactory,
|
|
49
53
|
tr,
|
|
50
|
-
|
|
51
|
-
): Promise<
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
this.testResourceConfiguration,
|
|
62
|
-
artifactory
|
|
63
|
-
);
|
|
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);
|
|
64
65
|
}
|
|
65
66
|
} as any,
|
|
66
67
|
|
|
67
|
-
class Given extends BaseGiven<
|
|
68
|
-
ITestShape
|
|
69
|
-
> {
|
|
70
|
-
|
|
68
|
+
class Given extends BaseGiven<ITestShape> {
|
|
71
69
|
async givenThat(subject, testResource, artifactory, initializer) {
|
|
72
70
|
return fullTestInterface.beforeEach(
|
|
73
71
|
subject,
|
|
@@ -76,61 +74,87 @@ export default abstract class Testeranto<ITestShape extends IBaseTest> extends C
|
|
|
76
74
|
// TODO does not work?
|
|
77
75
|
artifactory(`beforeEach/${fPath}`, value),
|
|
78
76
|
testResource,
|
|
79
|
-
this.initialValues
|
|
77
|
+
this.initialValues
|
|
80
78
|
// utils,
|
|
81
79
|
);
|
|
82
80
|
}
|
|
83
81
|
|
|
84
82
|
afterEach(
|
|
85
|
-
store: ITestShape[
|
|
83
|
+
store: ITestShape["istore"],
|
|
86
84
|
key: string,
|
|
87
|
-
artifactory
|
|
85
|
+
artifactory,
|
|
86
|
+
utils
|
|
88
87
|
): Promise<unknown> {
|
|
89
88
|
return new Promise((res) =>
|
|
90
|
-
res(
|
|
91
|
-
|
|
89
|
+
res(
|
|
90
|
+
fullTestInterface.afterEach(
|
|
91
|
+
store,
|
|
92
|
+
key,
|
|
93
|
+
(fPath: string, value: unknown) =>
|
|
94
|
+
artifactory(`after/${fPath}`, value),
|
|
95
|
+
utils
|
|
96
|
+
)
|
|
97
|
+
)
|
|
92
98
|
);
|
|
93
99
|
}
|
|
94
|
-
afterAll(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
+
},
|
|
102
128
|
utils
|
|
129
|
+
// {
|
|
130
|
+
// ...utils,
|
|
131
|
+
// browser: proxy,
|
|
132
|
+
// }
|
|
103
133
|
);
|
|
104
134
|
}
|
|
105
135
|
} as any,
|
|
106
136
|
|
|
107
|
-
class When extends BaseWhen<
|
|
108
|
-
ITestShape
|
|
109
|
-
> {
|
|
137
|
+
class When extends BaseWhen<ITestShape> {
|
|
110
138
|
async andWhen(store, whenCB, testResource) {
|
|
111
139
|
return await fullTestInterface.andWhen(store, whenCB, testResource);
|
|
112
140
|
}
|
|
113
141
|
} as any,
|
|
114
142
|
|
|
115
|
-
class Then extends BaseThen<
|
|
116
|
-
ITestShape
|
|
117
|
-
> {
|
|
118
|
-
|
|
143
|
+
class Then extends BaseThen<ITestShape> {
|
|
119
144
|
async butThen(
|
|
120
145
|
store: any,
|
|
121
146
|
thenCB,
|
|
122
147
|
testResourceConfiguration?: any
|
|
123
|
-
): Promise<ITestShape[
|
|
148
|
+
): Promise<ITestShape["iselection"]> {
|
|
124
149
|
return await fullTestInterface.butThen(
|
|
125
150
|
store,
|
|
126
151
|
thenCB,
|
|
127
|
-
testResourceConfiguration
|
|
152
|
+
testResourceConfiguration
|
|
153
|
+
);
|
|
128
154
|
}
|
|
129
155
|
} as any,
|
|
130
156
|
|
|
131
|
-
class Check extends BaseCheck<
|
|
132
|
-
ITestShape
|
|
133
|
-
> {
|
|
157
|
+
class Check extends BaseCheck<ITestShape> {
|
|
134
158
|
initialValues: any;
|
|
135
159
|
|
|
136
160
|
constructor(
|
|
@@ -149,27 +173,36 @@ export default abstract class Testeranto<ITestShape extends IBaseTest> extends C
|
|
|
149
173
|
return fullTestInterface.beforeEach(
|
|
150
174
|
subject,
|
|
151
175
|
this.initialValues,
|
|
152
|
-
(fPath: string, value: unknown) =>
|
|
176
|
+
(fPath: string, value: unknown) =>
|
|
177
|
+
artifactory(`before/${fPath}`, value),
|
|
153
178
|
testResourceConfiguration,
|
|
154
179
|
this.initialValues
|
|
155
180
|
);
|
|
156
181
|
}
|
|
157
182
|
|
|
158
183
|
afterEach(
|
|
159
|
-
store: ITestShape[
|
|
184
|
+
store: ITestShape["istore"],
|
|
160
185
|
key: string,
|
|
161
|
-
artifactory
|
|
186
|
+
artifactory,
|
|
187
|
+
utils
|
|
162
188
|
): Promise<unknown> {
|
|
163
189
|
return new Promise((res) =>
|
|
164
|
-
res(
|
|
165
|
-
|
|
166
|
-
|
|
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
|
+
)
|
|
167
200
|
);
|
|
168
201
|
}
|
|
169
202
|
} as any,
|
|
170
203
|
|
|
171
204
|
testResourceRequirement,
|
|
172
|
-
logWriter
|
|
205
|
+
logWriter
|
|
173
206
|
);
|
|
174
207
|
}
|
|
175
208
|
|
|
@@ -178,5 +211,4 @@ export default abstract class Testeranto<ITestShape extends IBaseTest> extends C
|
|
|
178
211
|
partialTestResource: ITTestResourceConfiguration,
|
|
179
212
|
utils: IUtils
|
|
180
213
|
);
|
|
181
|
-
|
|
182
214
|
}
|
package/src/lib/index.ts
CHANGED
|
@@ -1,23 +1,39 @@
|
|
|
1
|
+
import { IBaseTest } from "../Types.js";
|
|
1
2
|
|
|
2
|
-
import {
|
|
3
|
-
|
|
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";
|
|
4
12
|
|
|
5
13
|
export const BaseTestInterface: ITestInterface<IBaseTest> = {
|
|
6
|
-
beforeAll:
|
|
7
|
-
beforeEach: async function (
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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,
|
|
13
27
|
};
|
|
14
28
|
|
|
15
|
-
export const DefaultTestInterface = (
|
|
29
|
+
export const DefaultTestInterface = (
|
|
30
|
+
p: Partial<ITestInterface<any>>
|
|
31
|
+
): ITestInterface<any> => {
|
|
16
32
|
return {
|
|
17
33
|
...BaseTestInterface,
|
|
18
|
-
...p
|
|
19
|
-
}
|
|
20
|
-
}
|
|
34
|
+
...p,
|
|
35
|
+
};
|
|
36
|
+
};
|
|
21
37
|
|
|
22
38
|
export type ITTestResourceConfiguration = {
|
|
23
39
|
name: string;
|
|
@@ -39,51 +55,47 @@ export type ITTestResourceRequest = {
|
|
|
39
55
|
export type ITLog = (...string) => void;
|
|
40
56
|
|
|
41
57
|
export type ILogWriter = {
|
|
42
|
-
createWriteStream: (line: string) => any | any
|
|
43
|
-
writeFileSync: (fp: string, contents: string) => any
|
|
44
|
-
mkdirSync: (fp: string) => any
|
|
45
|
-
testArtiFactoryfileWriter: (
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
+
};
|
|
49
66
|
|
|
50
67
|
export type ITestArtificer = (key: string, data: any) => void;
|
|
51
68
|
|
|
52
69
|
type ITest = {
|
|
53
70
|
toObj(): object;
|
|
54
71
|
name: string;
|
|
55
|
-
givens: IGivens<
|
|
56
|
-
|
|
57
|
-
>;
|
|
58
|
-
checks: BaseCheck<
|
|
59
|
-
IBaseTest
|
|
60
|
-
>[];
|
|
72
|
+
givens: IGivens<IBaseTest>;
|
|
73
|
+
checks: BaseCheck<IBaseTest>[];
|
|
61
74
|
testResourceConfiguration: ITTestResourceConfiguration;
|
|
62
75
|
};
|
|
63
76
|
|
|
64
|
-
export type ITestJob = {
|
|
77
|
+
export type ITestJob<T = INodeUtils | IWebUtils> = {
|
|
65
78
|
toObj(): object;
|
|
66
79
|
test: ITest;
|
|
67
|
-
runner: (
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
>;
|
|
80
|
+
runner: (
|
|
81
|
+
x: ITTestResourceConfiguration,
|
|
82
|
+
t: ITLog
|
|
83
|
+
) => Promise<BaseSuite<IBaseTest>>;
|
|
72
84
|
testResourceRequirement: ITTestResourceRequirement;
|
|
73
85
|
receiveTestResourceConfig: (
|
|
74
86
|
testResource,
|
|
75
|
-
utils:
|
|
87
|
+
utils: T
|
|
76
88
|
) => Promise<{
|
|
77
|
-
failed: number
|
|
78
|
-
artifacts: Promise<unknown>[]
|
|
79
|
-
logPromise: Promise<unknown
|
|
80
|
-
}
|
|
89
|
+
failed: number;
|
|
90
|
+
artifacts: Promise<unknown>[];
|
|
91
|
+
logPromise: Promise<unknown>;
|
|
92
|
+
}>;
|
|
81
93
|
};
|
|
82
94
|
|
|
83
95
|
export type ITestResults = Promise<{ test: ITest }>[];
|
|
84
96
|
|
|
85
97
|
export const defaultTestResourceRequirement: ITTestResourceRequest = {
|
|
86
|
-
ports: 0
|
|
98
|
+
ports: 0,
|
|
87
99
|
};
|
|
88
100
|
|
|
89
101
|
export type ITestArtifactory = (key: string, value: unknown) => unknown;
|
|
@@ -94,23 +106,12 @@ export type ITestCheckCallback<ITestShape extends IBaseTest> = {
|
|
|
94
106
|
features: string[],
|
|
95
107
|
callbackA: (
|
|
96
108
|
whens: {
|
|
97
|
-
[K in keyof ITestShape["whens"]]: (
|
|
98
|
-
...unknown
|
|
99
|
-
) => BaseWhen<
|
|
100
|
-
ITestShape
|
|
101
|
-
>;
|
|
109
|
+
[K in keyof ITestShape["whens"]]: (...unknown) => BaseWhen<ITestShape>;
|
|
102
110
|
},
|
|
103
111
|
thens: {
|
|
104
|
-
[K in keyof ITestShape["thens"]]: (
|
|
105
|
-
...unknown
|
|
106
|
-
) => BaseThen<
|
|
107
|
-
ITestShape
|
|
108
|
-
>;
|
|
112
|
+
[K in keyof ITestShape["thens"]]: (...unknown) => BaseThen<ITestShape>;
|
|
109
113
|
}
|
|
110
114
|
) => Promise<any>,
|
|
111
115
|
...xtrasA: ITestShape["checks"][K]
|
|
112
|
-
) => BaseCheck<
|
|
113
|
-
ITestShape
|
|
114
|
-
>;
|
|
116
|
+
) => BaseCheck<ITestShape>;
|
|
115
117
|
};
|
|
116
|
-
|
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,33 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import puppeteer from "puppeteer-core";
|
|
2
2
|
|
|
3
|
-
console.log("hello preloader");
|
|
4
3
|
import { NodeWriter } from "./NodeWriter";
|
|
4
|
+
import puppeteerConfiger from "./puppeteerConfiger";
|
|
5
5
|
|
|
6
6
|
(window as any).NodeWriter = NodeWriter;
|
|
7
|
-
(window as any).exit = (x) => {
|
|
8
|
-
ipcRenderer.invoke('quit-app', x);
|
|
9
|
-
}
|
|
10
7
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
// };
|
|
22
|
-
|
|
23
|
-
// var oldLog = console.warn;
|
|
24
|
-
// console.warn = function (message) {
|
|
25
|
-
// ipcRenderer.invoke('web-warn', message.toString());
|
|
26
|
-
// oldLog.apply(console, arguments);
|
|
27
|
-
// };
|
|
28
|
-
|
|
29
|
-
// var oldLog = console.info;
|
|
30
|
-
// console.info = function (message) {
|
|
31
|
-
// ipcRenderer.invoke('web-info', message.toString());
|
|
32
|
-
// oldLog.apply(console, arguments);
|
|
33
|
-
// };
|
|
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
|
+
});
|