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
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import renderer, { act } from "react-test-renderer";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
IBaseTest,
|
|
5
|
+
ITestImplementation,
|
|
6
|
+
ITestSpecification,
|
|
7
|
+
} from "../../../Types";
|
|
4
8
|
|
|
5
9
|
export type IWhenShape = any;
|
|
6
10
|
export type IThenShape = any;
|
|
@@ -10,17 +14,11 @@ export type ISelection = renderer.ReactTestRenderer;
|
|
|
10
14
|
export type IStore = renderer.ReactTestRenderer;
|
|
11
15
|
export type ISubject = renderer.ReactTestRenderer;
|
|
12
16
|
|
|
13
|
-
export type ITestImpl<
|
|
14
|
-
ITestShape
|
|
15
|
-
> = ITestImplementation<
|
|
16
|
-
ITestShape, object
|
|
17
|
-
>
|
|
17
|
+
export type ITestImpl<ITestShape extends IBaseTest> =
|
|
18
|
+
ITestImplementation<ITestShape>;
|
|
18
19
|
|
|
19
|
-
export type ITestSpec<
|
|
20
|
-
ITestShape
|
|
21
|
-
> = ITestSpecification<
|
|
22
|
-
ITestShape
|
|
23
|
-
>
|
|
20
|
+
export type ITestSpec<ITestShape extends IBaseTest> =
|
|
21
|
+
ITestSpecification<ITestShape>;
|
|
24
22
|
|
|
25
23
|
export const testInterface = {
|
|
26
24
|
beforeEach: async (CComponent): Promise<renderer.ReactTestRenderer> => {
|
|
@@ -30,14 +28,13 @@ export const testInterface = {
|
|
|
30
28
|
component = renderer.create(CComponent);
|
|
31
29
|
});
|
|
32
30
|
res(component);
|
|
33
|
-
})
|
|
34
|
-
|
|
31
|
+
});
|
|
35
32
|
},
|
|
36
33
|
andWhen: async function (
|
|
37
34
|
renderer: renderer.ReactTestRenderer,
|
|
38
35
|
whenCB: () => (any) => any
|
|
39
36
|
): Promise<renderer.ReactTestRenderer> {
|
|
40
37
|
await act(() => whenCB()(renderer));
|
|
41
|
-
return renderer
|
|
42
|
-
}
|
|
43
|
-
}
|
|
38
|
+
return renderer;
|
|
39
|
+
},
|
|
40
|
+
};
|
package/src/Types.ts
CHANGED
|
@@ -1,351 +1,117 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Page, Browser, ScreenshotOptions } from "puppeteer-core";
|
|
3
|
-
|
|
1
|
+
import { ITTestResourceRequest, ITestCheckCallback } from "./lib/index.js";
|
|
4
2
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
IGivens,
|
|
4
|
+
BaseCheck,
|
|
5
|
+
BaseSuite,
|
|
6
|
+
BaseWhen,
|
|
7
|
+
BaseThen,
|
|
8
|
+
BaseGiven,
|
|
9
|
+
} from "./lib/abstractBase.js";
|
|
11
10
|
import Testeranto from "./lib/core.js";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
test: string,
|
|
18
|
-
runtime: IRunTime
|
|
19
|
-
}[]
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export type INodeUtils = TBrowser;
|
|
23
|
-
export type IWebUtils = BrowserWindow;
|
|
24
|
-
export type IUtils = INodeUtils | IWebUtils;
|
|
25
|
-
|
|
26
|
-
export type ISuiteKlasser<ITestShape extends IBaseTest> = (
|
|
27
|
-
name: string,
|
|
28
|
-
index: number,
|
|
29
|
-
givens: IGivens<ITestShape>,
|
|
30
|
-
checks: BaseCheck<ITestShape>[]
|
|
31
|
-
) => BaseSuite<ITestShape>;
|
|
32
|
-
|
|
33
|
-
export type IGivenKlasser<ITestShape extends IBaseTest> = (
|
|
34
|
-
name,
|
|
35
|
-
features,
|
|
36
|
-
whens,
|
|
37
|
-
thens,
|
|
38
|
-
givenCB
|
|
39
|
-
) => BaseGiven<ITestShape>;
|
|
40
|
-
|
|
41
|
-
export type IWhenKlasser<ITestShape extends IBaseTest> = (s, o) =>
|
|
42
|
-
BaseWhen<ITestShape>
|
|
43
|
-
|
|
44
|
-
export type IThenKlasser<ITestShape extends IBaseTest> = (s, o) =>
|
|
45
|
-
BaseThen<ITestShape>;
|
|
46
|
-
|
|
47
|
-
export type ICheckKlasser<ITestShape extends IBaseTest> = (
|
|
48
|
-
n,
|
|
49
|
-
f,
|
|
50
|
-
cb,
|
|
51
|
-
w,
|
|
52
|
-
t
|
|
53
|
-
) => BaseCheck<ITestShape>;
|
|
54
|
-
|
|
55
|
-
// export class TPage extends Page {
|
|
56
|
-
// // screenshot(options?: puppeteer.ScreenshotOptions) {
|
|
57
|
-
// // return super.screenshot({
|
|
58
|
-
// // ...options,
|
|
59
|
-
// // path: "dist/" + (options ? options : { path: "" }).path,
|
|
60
|
-
|
|
61
|
-
// // });
|
|
62
|
-
// // }
|
|
63
|
-
// }
|
|
64
|
-
|
|
65
|
-
export class TBrowser {
|
|
66
|
-
browser: Browser;
|
|
67
|
-
constructor(browser: Browser) {
|
|
68
|
-
this.browser = browser;
|
|
69
|
-
}
|
|
70
|
-
pages(): Promise<Page[]> {
|
|
71
|
-
|
|
72
|
-
return new Promise(async (res, rej) => {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
res(
|
|
76
|
-
(await this.browser.pages()).map((p) => {
|
|
77
|
-
// const handler = {
|
|
78
|
-
// apply: function (target, thisArg, argumentsList) {
|
|
79
|
-
// console.log('screenshot was called with ' + JSON.stringify(argumentsList));
|
|
80
|
-
// const x: ScreenshotOptions = argumentsList[0]
|
|
81
|
-
// x.path = "./dist/" + x.path;
|
|
82
|
-
// console.log('x.path' + x.path, target, thisArg);
|
|
83
|
-
// return target(...argumentsList);
|
|
84
|
-
// }
|
|
85
|
-
// };
|
|
86
|
-
// p.screenshot = new Proxy(p.screenshot, handler);
|
|
87
|
-
return p;
|
|
88
|
-
})
|
|
89
|
-
);
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
// pages(): Promise<TPage[]> {
|
|
94
|
-
// return super.pages();
|
|
95
|
-
// }
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export type ITTestShape = {
|
|
99
|
-
suites;
|
|
100
|
-
givens;
|
|
101
|
-
whens;
|
|
102
|
-
thens;
|
|
103
|
-
checks;
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
export type IJsonConfig = {
|
|
107
|
-
outdir: string,
|
|
108
|
-
tests: ITestTypes[]
|
|
109
|
-
features: string;
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
export type IBaseConfig = {
|
|
113
|
-
outdir: string,
|
|
114
|
-
tests: ITestTypes[]
|
|
115
|
-
features: string
|
|
116
|
-
externals: string[],
|
|
117
|
-
clearScreen: boolean;
|
|
118
|
-
devMode: boolean;
|
|
119
|
-
webPlugins: any[];
|
|
120
|
-
nodePlugins: any[];
|
|
121
|
-
minify: boolean;
|
|
122
|
-
outbase: string;
|
|
123
|
-
ports: string[];
|
|
124
|
-
debugger: boolean;
|
|
125
|
-
};
|
|
11
|
+
import {
|
|
12
|
+
INodeTestInterface,
|
|
13
|
+
ITestInterface,
|
|
14
|
+
IWebTestInterface,
|
|
15
|
+
} from "./lib/types.js";
|
|
126
16
|
|
|
127
17
|
export type IPartialInterface<I extends IBaseTest> = Partial<ITestInterface<I>>;
|
|
128
|
-
|
|
18
|
+
|
|
19
|
+
export type IPartialNodeInterface<I extends IBaseTest> = Partial<
|
|
20
|
+
INodeTestInterface<I>
|
|
21
|
+
>;
|
|
22
|
+
export type IPartialWebInterface<I extends IBaseTest> = Partial<
|
|
23
|
+
IWebTestInterface<I>
|
|
24
|
+
>;
|
|
129
25
|
|
|
130
26
|
export type IEntry<ITestShape extends IBaseTest> = (
|
|
131
|
-
input: ITestShape[
|
|
27
|
+
input: ITestShape["iinput"],
|
|
132
28
|
testSpecification: ITestSpecification<ITestShape>,
|
|
133
29
|
testImplementation: ITestImplementation<ITestShape, object>,
|
|
134
30
|
testInterface: IPartialInterface<ITestShape>,
|
|
135
|
-
testResourceRequirement: ITTestResourceRequest
|
|
31
|
+
testResourceRequirement: ITTestResourceRequest
|
|
136
32
|
) => Promise<Testeranto<ITestShape>>;
|
|
137
33
|
|
|
138
|
-
|
|
139
|
-
// (modulePath: string | URL, options?: childProcess.ForkOptions): childProcess.ChildProcess;
|
|
140
|
-
// (modulePath: string | URL, args?: readonly string[], options?: childProcess.ForkOptions): childProcess.ChildProcess
|
|
141
|
-
// };
|
|
142
|
-
|
|
143
|
-
// const f: If = childProcess.fork;
|
|
144
|
-
|
|
145
|
-
export type IRunTime = `node` | `web`;
|
|
146
|
-
|
|
147
|
-
export type ITestTypes = [
|
|
148
|
-
string,
|
|
149
|
-
IRunTime,
|
|
150
|
-
ITestTypes[]
|
|
151
|
-
];
|
|
152
|
-
|
|
153
|
-
export type ITestSpecification<
|
|
154
|
-
ITestShape extends IBaseTest
|
|
155
|
-
> = (
|
|
34
|
+
export type ITestSpecification<ITestShape extends IBaseTest> = (
|
|
156
35
|
Suite: {
|
|
157
36
|
[K in keyof ITestShape["suites"]]: (
|
|
158
37
|
name: string,
|
|
159
|
-
givens: IGivens<
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
checks: BaseCheck<
|
|
163
|
-
ITestShape
|
|
164
|
-
>[]
|
|
165
|
-
) => BaseSuite<
|
|
166
|
-
ITestShape
|
|
167
|
-
>;
|
|
38
|
+
givens: IGivens<ITestShape>,
|
|
39
|
+
checks: BaseCheck<ITestShape>[]
|
|
40
|
+
) => BaseSuite<ITestShape>;
|
|
168
41
|
},
|
|
169
42
|
Given: {
|
|
170
43
|
[K in keyof ITestShape["givens"]]: (
|
|
171
44
|
features: string[],
|
|
172
|
-
whens: BaseWhen<
|
|
173
|
-
|
|
174
|
-
>[],
|
|
175
|
-
thens: BaseThen<
|
|
176
|
-
ITestShape
|
|
177
|
-
>[],
|
|
45
|
+
whens: BaseWhen<ITestShape>[],
|
|
46
|
+
thens: BaseThen<ITestShape>[],
|
|
178
47
|
...xtrasB: ITestShape["givens"][K]
|
|
179
|
-
) => BaseGiven<
|
|
180
|
-
ITestShape
|
|
181
|
-
>;
|
|
48
|
+
) => BaseGiven<ITestShape>;
|
|
182
49
|
},
|
|
183
50
|
When: {
|
|
184
51
|
[K in keyof ITestShape["whens"]]: (
|
|
185
52
|
...xtrasC: ITestShape["whens"][K]
|
|
186
|
-
) => BaseWhen<
|
|
187
|
-
ITestShape
|
|
188
|
-
>;
|
|
53
|
+
) => BaseWhen<ITestShape>;
|
|
189
54
|
},
|
|
190
55
|
Then: {
|
|
191
56
|
[K in keyof ITestShape["thens"]]: (
|
|
192
57
|
...xtrasD: ITestShape["thens"][K]
|
|
193
|
-
) => BaseThen<
|
|
194
|
-
ITestShape
|
|
195
|
-
>;
|
|
58
|
+
) => BaseThen<ITestShape>;
|
|
196
59
|
},
|
|
197
60
|
Check: ITestCheckCallback<ITestShape>
|
|
198
61
|
) => any[];
|
|
199
62
|
|
|
200
63
|
export type ITestImplementation<
|
|
201
64
|
ITestShape extends IBaseTest,
|
|
65
|
+
IMod = object
|
|
66
|
+
> = Modify<
|
|
67
|
+
{
|
|
68
|
+
suites: {
|
|
69
|
+
[K in keyof ITestShape["suites"]]: string;
|
|
70
|
+
};
|
|
71
|
+
givens: {
|
|
72
|
+
[K in keyof ITestShape["givens"]]: (
|
|
73
|
+
...Ig: ITestShape["givens"][K]
|
|
74
|
+
) => ITestShape["given"];
|
|
75
|
+
};
|
|
76
|
+
whens: {
|
|
77
|
+
[K in keyof ITestShape["whens"]]: (
|
|
78
|
+
...Iw: ITestShape["whens"][K]
|
|
79
|
+
) => (zel: ITestShape["iselection"]) => ITestShape["when"];
|
|
80
|
+
};
|
|
81
|
+
thens: {
|
|
82
|
+
[K in keyof ITestShape["thens"]]: (
|
|
83
|
+
...It: ITestShape["thens"][K]
|
|
84
|
+
) => (ssel: ITestShape["iselection"]) => ITestShape["then"];
|
|
85
|
+
};
|
|
86
|
+
checks: {
|
|
87
|
+
[K in keyof ITestShape["checks"]]: (
|
|
88
|
+
...Ic: ITestShape["checks"][K]
|
|
89
|
+
) => ITestShape["given"];
|
|
90
|
+
};
|
|
91
|
+
},
|
|
202
92
|
IMod
|
|
203
|
-
|
|
204
|
-
suites: {
|
|
205
|
-
[K in keyof ITestShape["suites"]]: string;
|
|
206
|
-
};
|
|
207
|
-
givens: {
|
|
208
|
-
[K in keyof ITestShape["givens"]]: (
|
|
209
|
-
...Ig: ITestShape["givens"][K]
|
|
210
|
-
) => ITestShape['given'];
|
|
211
|
-
};
|
|
212
|
-
whens: {
|
|
213
|
-
[K in keyof ITestShape["whens"]]: (
|
|
214
|
-
...Iw: ITestShape["whens"][K]
|
|
215
|
-
) =>
|
|
216
|
-
(zel: ITestShape['iselection']) =>
|
|
217
|
-
ITestShape['when'];
|
|
218
|
-
};
|
|
219
|
-
thens: {
|
|
220
|
-
[K in keyof ITestShape["thens"]]: (
|
|
221
|
-
...It: ITestShape["thens"][K]
|
|
222
|
-
) => (ssel: ITestShape['iselection']) =>
|
|
223
|
-
ITestShape['then'];
|
|
224
|
-
};
|
|
225
|
-
checks: {
|
|
226
|
-
[K in keyof ITestShape["checks"]]: (
|
|
227
|
-
...Ic: ITestShape["checks"][K]
|
|
228
|
-
) => ITestShape['given'];
|
|
229
|
-
};
|
|
230
|
-
}, IMod>;
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
export type ITestInterface<
|
|
235
|
-
ITestShape extends IBaseTest
|
|
236
|
-
> = {
|
|
237
|
-
assertThis: (x: ITestShape['then']) => void,
|
|
238
|
-
|
|
239
|
-
andWhen: (
|
|
240
|
-
store: ITestShape['istore'],
|
|
241
|
-
whenCB: ITestShape['when'],
|
|
242
|
-
testResource: ITTestResourceConfiguration
|
|
243
|
-
) => Promise<ITestShape['istore']>;
|
|
244
|
-
butThen: (
|
|
245
|
-
store: ITestShape['istore'],
|
|
246
|
-
thenCB,
|
|
247
|
-
testResource: ITTestResourceConfiguration
|
|
248
|
-
) => Promise<ITestShape['iselection']>;
|
|
249
|
-
|
|
250
|
-
afterAll: (
|
|
251
|
-
store: ITestShape['istore'],
|
|
252
|
-
artificer: ITestArtificer,
|
|
253
|
-
utils: IUtils
|
|
254
|
-
) => any;
|
|
255
|
-
afterEach: (
|
|
256
|
-
store: ITestShape['istore'],
|
|
257
|
-
key: string,
|
|
258
|
-
artificer: ITestArtificer,
|
|
259
|
-
// utils: IUtils
|
|
260
|
-
) => Promise<unknown>;
|
|
261
|
-
beforeAll: (
|
|
262
|
-
input: ITestShape['iinput'],
|
|
263
|
-
testResource: ITTestResourceConfiguration,
|
|
264
|
-
artificer: ITestArtificer,
|
|
265
|
-
// utils: IUtils
|
|
266
|
-
) => Promise<ITestShape['isubject']>;
|
|
267
|
-
beforeEach: (
|
|
268
|
-
subject: ITestShape['isubject'],
|
|
269
|
-
initializer: (c?) => ITestShape['given'],
|
|
270
|
-
artificer: ITestArtificer,
|
|
271
|
-
testResource: ITTestResourceConfiguration,
|
|
272
|
-
initialValues,
|
|
273
|
-
// utils: IUtils
|
|
274
|
-
) => Promise<ITestShape['istore']>;
|
|
275
|
-
};
|
|
276
|
-
|
|
277
|
-
export type INodeTestInterface<
|
|
278
|
-
ITestShape extends IBaseTest
|
|
279
|
-
> = {
|
|
280
|
-
assertThis: (x: ITestShape['then']) => void,
|
|
281
|
-
|
|
282
|
-
andWhen: (
|
|
283
|
-
store: ITestShape['istore'],
|
|
284
|
-
whenCB: ITestShape['when'],
|
|
285
|
-
testResource: ITTestResourceConfiguration
|
|
286
|
-
) => Promise<ITestShape['istore']>;
|
|
287
|
-
butThen: (
|
|
288
|
-
store: ITestShape['istore'],
|
|
289
|
-
thenCB,
|
|
290
|
-
testResource: ITTestResourceConfiguration
|
|
291
|
-
) => Promise<ITestShape['iselection']>;
|
|
292
|
-
|
|
293
|
-
afterAll: (
|
|
294
|
-
store: ITestShape['istore'],
|
|
295
|
-
artificer: ITestArtificer,
|
|
296
|
-
browser: INodeUtils
|
|
297
|
-
) => any;
|
|
298
|
-
afterEach: (
|
|
299
|
-
store: ITestShape['istore'],
|
|
300
|
-
key: string,
|
|
301
|
-
artificer: ITestArtificer,
|
|
302
|
-
// utils: IUtils
|
|
303
|
-
) => Promise<unknown>;
|
|
304
|
-
beforeAll: (
|
|
305
|
-
input: ITestShape['iinput'],
|
|
306
|
-
testResource: ITTestResourceConfiguration,
|
|
307
|
-
artificer: ITestArtificer,
|
|
308
|
-
// utils: IUtils
|
|
309
|
-
) => Promise<ITestShape['isubject']>;
|
|
310
|
-
beforeEach: (
|
|
311
|
-
subject: ITestShape['isubject'],
|
|
312
|
-
initializer: (c?) => ITestShape['given'],
|
|
313
|
-
artificer: ITestArtificer,
|
|
314
|
-
testResource: ITTestResourceConfiguration,
|
|
315
|
-
initialValues,
|
|
316
|
-
// utils: IUtils
|
|
317
|
-
) => Promise<ITestShape['istore']>;
|
|
318
|
-
} & ITestInterface<ITestShape>;
|
|
93
|
+
>;
|
|
319
94
|
|
|
320
95
|
type Modify<T, R> = Omit<T, keyof R> & R;
|
|
321
96
|
|
|
322
|
-
export type IBaseTest = {
|
|
323
|
-
iinput;
|
|
324
|
-
isubject;
|
|
325
|
-
istore;
|
|
326
|
-
iselection;
|
|
97
|
+
export type IBaseTest<Shape = any, II = Shape> = {
|
|
98
|
+
iinput: II;
|
|
99
|
+
isubject: Shape;
|
|
100
|
+
istore: Shape;
|
|
101
|
+
iselection: Shape;
|
|
327
102
|
// iinitial;
|
|
328
103
|
|
|
329
104
|
given;
|
|
330
105
|
when;
|
|
331
106
|
then;
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
107
|
+
|
|
108
|
+
suites: Record<string, any>;
|
|
109
|
+
givens: Record<string, any>;
|
|
110
|
+
whens: Record<string, any>;
|
|
111
|
+
thens: Record<string, any>;
|
|
112
|
+
checks: Record<string, any>;
|
|
337
113
|
};
|
|
338
114
|
|
|
339
|
-
export type
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
> = {
|
|
343
|
-
given;
|
|
344
|
-
when;
|
|
345
|
-
then;
|
|
346
|
-
suites;
|
|
347
|
-
givens;
|
|
348
|
-
whens;
|
|
349
|
-
thens;
|
|
350
|
-
checks;
|
|
351
|
-
};
|
|
115
|
+
// export type ITTestShape = {
|
|
116
|
+
|
|
117
|
+
// };
|
package/src/Web.ts
CHANGED
|
@@ -1,115 +1,74 @@
|
|
|
1
|
+
import { PM_Web } from "./PM/web";
|
|
1
2
|
import type {
|
|
2
3
|
IBaseTest,
|
|
3
4
|
ITestImplementation,
|
|
4
|
-
|
|
5
|
-
ITestSpecification
|
|
5
|
+
ITestSpecification,
|
|
6
6
|
} from "./Types";
|
|
7
7
|
import Testeranto from "./lib/core.js";
|
|
8
8
|
import {
|
|
9
9
|
ITTestResourceConfiguration,
|
|
10
10
|
ITTestResourceRequest,
|
|
11
|
-
|
|
12
|
-
defaultTestResourceRequirement
|
|
11
|
+
defaultTestResourceRequirement,
|
|
13
12
|
} from "./lib/index.js";
|
|
13
|
+
import { ITestInterface, IWebTestInterface } from "./lib/types";
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class WebTesteranto<
|
|
18
|
-
TestShape extends IBaseTest,
|
|
19
|
-
> extends Testeranto<
|
|
20
|
-
TestShape
|
|
21
|
-
> {
|
|
15
|
+
class WebTesteranto<TestShape extends IBaseTest> extends Testeranto<TestShape> {
|
|
22
16
|
constructor(
|
|
23
17
|
input: TestShape["iinput"],
|
|
24
18
|
testSpecification: ITestSpecification<TestShape>,
|
|
25
|
-
testImplementation: ITestImplementation<TestShape
|
|
19
|
+
testImplementation: ITestImplementation<TestShape>,
|
|
26
20
|
testResourceRequirement: ITTestResourceRequest,
|
|
27
|
-
testInterface: Partial<ITestInterface<TestShape
|
|
21
|
+
testInterface: Partial<ITestInterface<TestShape>>
|
|
28
22
|
) {
|
|
29
23
|
super(
|
|
30
24
|
input,
|
|
31
25
|
testSpecification,
|
|
32
26
|
testImplementation,
|
|
33
27
|
testResourceRequirement,
|
|
34
|
-
|
|
35
|
-
testInterface,
|
|
36
|
-
// BrowserWindow
|
|
28
|
+
testInterface
|
|
37
29
|
);
|
|
38
|
-
|
|
39
|
-
if (process.argv[2]) {
|
|
40
|
-
const testResourceArg = decodeURIComponent(
|
|
41
|
-
new URLSearchParams(location.search).get('requesting') || ''
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
try {
|
|
45
|
-
const partialTestResource = JSON.parse(
|
|
46
|
-
testResourceArg
|
|
47
|
-
) as ITTestResourceConfiguration;
|
|
48
|
-
|
|
49
|
-
this.receiveTestResourceConfig(this.testJobs[0], partialTestResource);
|
|
50
|
-
|
|
51
|
-
} catch (e) {
|
|
52
|
-
console.error(e);
|
|
53
|
-
// process.exit(-1);
|
|
54
|
-
}
|
|
55
|
-
} else {
|
|
56
|
-
// no-op
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const requesting = new URLSearchParams(location.search).get('requesting');
|
|
60
|
-
if (requesting) {
|
|
61
|
-
const testResourceArg = decodeURIComponent(requesting);
|
|
62
|
-
|
|
63
|
-
try {
|
|
64
|
-
const partialTestResource = JSON.parse(
|
|
65
|
-
testResourceArg
|
|
66
|
-
) as ITTestResourceConfiguration;
|
|
67
|
-
|
|
68
|
-
console.log("initial test resource", partialTestResource);
|
|
69
|
-
this.receiveTestResourceConfig(this.testJobs[0], partialTestResource);
|
|
70
|
-
|
|
71
|
-
} catch (e) {
|
|
72
|
-
console.error(e);
|
|
73
|
-
// process.exit(-1);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
// const t: ITestJob = this.testJobs[0];
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
30
|
}
|
|
81
31
|
|
|
82
|
-
async receiveTestResourceConfig(
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
)
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
32
|
+
async receiveTestResourceConfig(partialTestResource: any) {
|
|
33
|
+
const t: ITTestResourceConfiguration = partialTestResource; //JSON.parse(partialTestResource);
|
|
34
|
+
const pm = new PM_Web(t);
|
|
35
|
+
const { failed, artifacts, logPromise } =
|
|
36
|
+
await this.testJobs[0].receiveTestResourceConfig(pm);
|
|
37
|
+
|
|
38
|
+
console.log("test is done, awaiting test result write to fs");
|
|
39
|
+
pm.customclose();
|
|
40
|
+
// Promise.all([...artifacts, logPromise]).then(async () => {
|
|
41
|
+
// console.log("hello world");
|
|
42
|
+
// pm.customclose();
|
|
43
|
+
// // we can't close the window becuase we might be taking a screenshot
|
|
44
|
+
// // window.close();
|
|
45
|
+
// // console.log(
|
|
46
|
+
// // "(window as any).browser",
|
|
47
|
+
// // JSON.stringify(await (window as any).browser)
|
|
48
|
+
// // );
|
|
49
|
+
// // var currentWindow = (await (window as any).browser).getCurrentWindow();
|
|
50
|
+
// // window.close();
|
|
51
|
+
// // var customWindow = window.open("", "_blank", "");
|
|
52
|
+
// // customWindow.close();
|
|
53
|
+
// // this.puppetMaster.browser.page
|
|
54
|
+
// // window["customclose"]();
|
|
55
|
+
// // console.log("goodbye", window["customclose"]());
|
|
56
|
+
// });
|
|
96
57
|
}
|
|
97
|
-
|
|
98
|
-
};
|
|
58
|
+
}
|
|
99
59
|
|
|
100
60
|
export default async <ITestShape extends IBaseTest>(
|
|
101
|
-
input: ITestShape[
|
|
61
|
+
input: ITestShape["iinput"],
|
|
102
62
|
testSpecification: ITestSpecification<ITestShape>,
|
|
103
|
-
testImplementation: ITestImplementation<ITestShape
|
|
104
|
-
testInterface: Partial<
|
|
105
|
-
testResourceRequirement: ITTestResourceRequest = defaultTestResourceRequirement
|
|
63
|
+
testImplementation: ITestImplementation<ITestShape>,
|
|
64
|
+
testInterface: Partial<IWebTestInterface<ITestShape>>,
|
|
65
|
+
testResourceRequirement: ITTestResourceRequest = defaultTestResourceRequirement
|
|
106
66
|
): Promise<Testeranto<ITestShape>> => {
|
|
107
67
|
return new WebTesteranto<ITestShape>(
|
|
108
68
|
input,
|
|
109
69
|
testSpecification,
|
|
110
70
|
testImplementation,
|
|
111
71
|
testResourceRequirement,
|
|
112
|
-
testInterface
|
|
113
|
-
)
|
|
114
|
-
|
|
72
|
+
testInterface
|
|
73
|
+
);
|
|
115
74
|
};
|
package/src/cjs-shim.js
CHANGED
|
@@ -3,8 +3,8 @@ import path from 'node:path';
|
|
|
3
3
|
import url from 'node:url';
|
|
4
4
|
|
|
5
5
|
// globalThis.require = createRequire(import.meta.url);
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
globalThis.__filename = url.fileURLToPath(import.meta.url);
|
|
7
|
+
globalThis.__dirname = path.dirname(__filename);
|
|
8
8
|
|
|
9
9
|
// const p = `${import.meta.url}/..`;
|
|
10
10
|
// globalThis.require = createRequire(`${import.meta.url}/..`);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { IBaseConfig } from "../Types";
|
|
2
|
-
|
|
3
1
|
import { BuildOptions } from "esbuild";
|
|
2
|
+
import { IBaseConfig } from "../lib/types";
|
|
4
3
|
|
|
5
4
|
export default (config: IBaseConfig): BuildOptions => {
|
|
6
5
|
return {
|
|
@@ -14,5 +13,5 @@ export default (config: IBaseConfig): BuildOptions => {
|
|
|
14
13
|
// external: ["graphology"],
|
|
15
14
|
|
|
16
15
|
format: "esm",
|
|
17
|
-
}
|
|
18
|
-
}
|
|
16
|
+
};
|
|
17
|
+
};
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { BuildOptions } from "esbuild";
|
|
2
|
-
|
|
3
|
-
import { IBaseConfig } from "../
|
|
2
|
+
|
|
3
|
+
import { IBaseConfig } from "../lib/types";
|
|
4
4
|
|
|
5
5
|
export default (config: IBaseConfig): BuildOptions => {
|
|
6
6
|
return {
|
|
7
7
|
target: "esnext",
|
|
8
8
|
format: "esm",
|
|
9
9
|
splitting: true,
|
|
10
|
-
outExtension: {
|
|
10
|
+
outExtension: { ".js": ".mjs" },
|
|
11
11
|
outbase: config.outbase,
|
|
12
|
-
jsx:
|
|
12
|
+
jsx: "transform",
|
|
13
13
|
bundle: true,
|
|
14
14
|
minify: config.minify === true,
|
|
15
15
|
write: true,
|
|
16
16
|
loader: {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
".js": "jsx",
|
|
18
|
+
".png": "binary",
|
|
19
|
+
".jpg": "binary",
|
|
20
20
|
},
|
|
21
21
|
};
|
|
22
|
-
}
|
|
22
|
+
};
|