testeranto 0.70.0 → 0.74.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 +9 -18
- package/dist/common/Node.js +7 -34
- package/dist/common/PM/index.js +71 -0
- package/dist/common/PM/main.js +370 -0
- package/dist/common/PM/node.js +84 -0
- package/dist/common/PM/web.js +129 -0
- package/dist/common/Project.js +20 -2
- 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/jsx/index.js +14 -2
- package/dist/common/SubPackages/react-dom/component/web.js +98 -45
- package/dist/common/SubPackages/react-test-renderer/jsx/index.js +0 -1
- package/dist/common/Web.js +24 -44
- package/dist/common/esbuildConfigs/web.js +3 -1
- package/dist/common/lib/abstractBase.js +189 -41
- package/dist/common/lib/basebuilder.js +56 -29
- package/dist/common/lib/classBuilder.js +6 -2
- package/dist/common/lib/core.js +41 -45
- package/dist/common/lib/index.js +2 -1
- package/dist/common/preload.js +14 -18
- package/dist/common/tsconfig.common.tsbuildinfo +1 -1
- package/dist/module/Node.js +7 -34
- package/dist/module/PM/index.js +67 -0
- package/dist/module/PM/main.js +340 -0
- package/dist/module/PM/node.js +77 -0
- package/dist/module/PM/web.js +122 -0
- package/dist/module/Project.js +20 -2
- 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/index.js +11 -2
- package/dist/module/SubPackages/react/jsx/node.js +1 -1
- package/dist/module/SubPackages/react-dom/component/web.js +98 -45
- package/dist/module/SubPackages/react-test-renderer/jsx/index.js +0 -1
- package/dist/module/Web.js +24 -44
- package/dist/module/esbuildConfigs/web.js +3 -1
- package/dist/module/lib/abstractBase.js +189 -41
- package/dist/module/lib/basebuilder.js +56 -29
- package/dist/module/lib/classBuilder.js +6 -2
- package/dist/module/lib/core.js +41 -45
- package/dist/module/lib/index.js +2 -1
- package/dist/module/preload.js +15 -14
- 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/PM/index.d.ts +19 -0
- package/dist/types/PM/main.d.ts +26 -0
- package/dist/types/PM/node.d.ts +25 -0
- package/dist/types/PM/web.d.ts +24 -0
- package/dist/types/Reporter.d.ts +1 -0
- package/dist/types/Scheduler.d.ts +0 -0
- package/dist/types/SubPackages/react/jsx/index.d.ts +2 -5
- package/dist/types/SubPackages/react-dom/component/web.d.ts +1 -1
- package/dist/types/lib/abstractBase.d.ts +13 -12
- package/dist/types/lib/basebuilder.d.ts +4 -2
- package/dist/types/lib/classBuilder.d.ts +2 -2
- package/dist/types/lib/core.d.ts +4 -4
- package/dist/types/lib/index.d.ts +6 -5
- package/dist/types/lib/types.d.ts +16 -24
- package/dist/types/preload.d.ts +0 -1
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +3 -5
- package/src/Node.ts +8 -47
- package/src/PM/index.ts +102 -0
- package/src/PM/main.ts +452 -0
- package/src/PM/node.ts +122 -0
- package/src/PM/web.ts +162 -0
- package/src/Project.ts +21 -2
- package/src/Puppeteer.ts +131 -0
- package/src/Report.tsx +160 -46
- package/src/Reporter.ts +134 -0
- package/src/Scheduler.ts +0 -0
- package/src/SubPackages/puppeteer.ts +3 -3
- package/src/SubPackages/react/jsx/index.ts +13 -3
- package/src/SubPackages/react/jsx/node.ts +5 -8
- package/src/SubPackages/react-dom/component/web.ts +126 -67
- package/src/SubPackages/react-test-renderer/jsx/index.ts +0 -1
- package/src/Web.ts +25 -69
- package/src/esbuildConfigs/web.ts +4 -2
- package/src/lib/abstractBase.ts +260 -65
- package/src/lib/basebuilder.ts +121 -100
- package/src/lib/classBuilder.ts +5 -4
- package/src/lib/core.ts +58 -59
- package/src/lib/index.ts +10 -9
- package/src/lib/types.ts +18 -27
- package/src/preload.ts +14 -14
- package/dist/common/NodeWriter.js +0 -54
- package/dist/common/electron.js +0 -266
- package/dist/module/NodeWriter.js +0 -48
- package/dist/module/electron.js +0 -261
- package/dist/types/NodeWriter.d.ts +0 -2
- package/src/NodeWriter.ts +0 -72
- package/src/electron.ts +0 -317
- package/yarn-error.log +0 -3144
- /package/dist/types/{electron.d.ts → Puppeteer.d.ts} +0 -0
|
@@ -18,10 +18,13 @@ type ISelection = {
|
|
|
18
18
|
type IStore = {
|
|
19
19
|
htmlElement: HTMLElement;
|
|
20
20
|
reactElement: any; //CElement<any, any>,
|
|
21
|
+
domRoot: ReactDom.Root;
|
|
21
22
|
};
|
|
22
23
|
|
|
23
24
|
type ISubject = {
|
|
24
25
|
htmlElement: HTMLElement;
|
|
26
|
+
reactElement: any; //CElement<any, any>,
|
|
27
|
+
domRoot: ReactDom.Root;
|
|
25
28
|
};
|
|
26
29
|
|
|
27
30
|
export default <ITestShape extends IBaseTest, IWhen, IGiven>(
|
|
@@ -29,76 +32,132 @@ export default <ITestShape extends IBaseTest, IWhen, IGiven>(
|
|
|
29
32
|
testSpecifications: ITestSpecification<ITestShape>,
|
|
30
33
|
testImplementations: ITestImplementation<ITestShape, any>
|
|
31
34
|
) => {
|
|
35
|
+
class TesterantoComponent extends testInput {
|
|
36
|
+
done: (t: TesterantoComponent) => void;
|
|
37
|
+
constructor(props) {
|
|
38
|
+
super(props);
|
|
39
|
+
this.done = props.done;
|
|
40
|
+
}
|
|
41
|
+
componentDidMount() {
|
|
42
|
+
super.componentDidMount && super.componentDidMount();
|
|
43
|
+
return this.done(this);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const t = Testeranto<ITestShape>(
|
|
48
|
+
testInput,
|
|
49
|
+
testSpecifications,
|
|
50
|
+
testImplementations,
|
|
51
|
+
{
|
|
52
|
+
beforeAll: async (initialProps, artificer): Promise<ISubject> => {
|
|
53
|
+
console.log("mark5", initialProps);
|
|
54
|
+
return await new Promise((resolve, rej) => {
|
|
55
|
+
const htmlElement = document.getElementById("root");
|
|
56
|
+
if (htmlElement) {
|
|
57
|
+
const domRoot = ReactDom.createRoot(htmlElement);
|
|
58
|
+
// Ignore these type errors
|
|
59
|
+
domRoot.render(
|
|
60
|
+
createElement(
|
|
61
|
+
TesterantoComponent,
|
|
62
|
+
{
|
|
63
|
+
...initialProps,
|
|
64
|
+
done: (reactElement) => {
|
|
65
|
+
resolve({
|
|
66
|
+
htmlElement,
|
|
67
|
+
reactElement,
|
|
68
|
+
domRoot,
|
|
69
|
+
});
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
[]
|
|
73
|
+
)
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
// resolve({ htmlElement });
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
},
|
|
80
|
+
// beforeEach: async (
|
|
81
|
+
// s,
|
|
82
|
+
// initializer,
|
|
83
|
+
// testResource,
|
|
84
|
+
// artificer,
|
|
85
|
+
// initialValues
|
|
86
|
+
// ): Promise<IStore> => {
|
|
87
|
+
// return new Promise((resolve, rej) => {
|
|
88
|
+
// console.log("beforeEach" + TesterantoComponent);
|
|
89
|
+
|
|
90
|
+
// // const domRoot = ReactDom.createRoot(htmlElement);
|
|
91
|
+
// // // Ignore these type errors
|
|
92
|
+
// // domRoot.render(
|
|
93
|
+
// // createElement(
|
|
94
|
+
// // TesterantoComponent,
|
|
95
|
+
// // {
|
|
96
|
+
// // ...initializer,
|
|
97
|
+
// // done: (reactElement) => {
|
|
98
|
+
// // resolve({
|
|
99
|
+
// // htmlElement,
|
|
100
|
+
// // reactElement,
|
|
101
|
+
// // domRoot,
|
|
102
|
+
// // });
|
|
103
|
+
// // },
|
|
104
|
+
// // },
|
|
105
|
+
// // []
|
|
106
|
+
// // )
|
|
107
|
+
// // );
|
|
108
|
+
// });
|
|
109
|
+
// },
|
|
110
|
+
andWhen: function (s: IStore, whenCB): Promise<ISelection> {
|
|
111
|
+
return whenCB(s);
|
|
112
|
+
},
|
|
113
|
+
butThen: async function (s: IStore, thenCB): Promise<ISelection> {
|
|
114
|
+
return thenCB(s);
|
|
115
|
+
},
|
|
116
|
+
afterEach: async function (store: IStore, ndx, artificer, utils) {
|
|
117
|
+
console.log("afterEach", store);
|
|
118
|
+
utils.writeFileSync("aftereachlog", store.toString());
|
|
119
|
+
|
|
120
|
+
const page = (await utils.browser.pages()).filter((x) => {
|
|
121
|
+
const parsedUrl = new URL(x.url());
|
|
122
|
+
parsedUrl.search = "";
|
|
123
|
+
const strippedUrl = parsedUrl.toString();
|
|
124
|
+
|
|
125
|
+
return (
|
|
126
|
+
strippedUrl ===
|
|
127
|
+
"file:///Users/adam/Code/kokomoBay/docs/web/src/ClassicalComponent/react-dom/client.web.test.html"
|
|
128
|
+
);
|
|
129
|
+
// return true;
|
|
130
|
+
})[0];
|
|
131
|
+
|
|
132
|
+
const x = await page.screenshot({
|
|
133
|
+
path: "afterEachLog.jpg",
|
|
134
|
+
});
|
|
135
|
+
console.log("x", x);
|
|
136
|
+
// debugger;
|
|
137
|
+
// const div_root = document.getElementById("root");
|
|
138
|
+
// store.domRoot && store.domRoot.unmount(); //React 18
|
|
139
|
+
// store.remove();
|
|
140
|
+
// store.htmlElement.remove();
|
|
141
|
+
// store.htmlElement = document.createElement("root");
|
|
142
|
+
return store;
|
|
143
|
+
},
|
|
144
|
+
afterAll: async (store: IStore, artificer, utils) => {
|
|
145
|
+
// setTimeout(() => {
|
|
146
|
+
// console.log("This will run after 1 second");
|
|
147
|
+
// }, 1000); // 1000 milliseconds = 1 second
|
|
148
|
+
// store.htmlElement.remove();
|
|
149
|
+
// store.htmlElement = document.createElement("root");
|
|
150
|
+
return store;
|
|
151
|
+
},
|
|
152
|
+
}
|
|
153
|
+
);
|
|
154
|
+
|
|
32
155
|
document.addEventListener("DOMContentLoaded", function () {
|
|
33
156
|
const elem = document.getElementById("root");
|
|
34
157
|
if (elem) {
|
|
35
|
-
|
|
36
|
-
done: (t: TesterantoComponent) => void;
|
|
37
|
-
constructor(props) {
|
|
38
|
-
super(props);
|
|
39
|
-
this.done = props.done;
|
|
40
|
-
}
|
|
41
|
-
componentDidMount() {
|
|
42
|
-
super.componentDidMount && super.componentDidMount();
|
|
43
|
-
return this.done(this);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return Testeranto<ITestShape>(
|
|
48
|
-
testInput,
|
|
49
|
-
testSpecifications,
|
|
50
|
-
testImplementations,
|
|
51
|
-
{
|
|
52
|
-
beforeAll: async (initialProps, artificer): Promise<ISubject> => {
|
|
53
|
-
console.log("mark5", initialProps);
|
|
54
|
-
return await new Promise((resolve, rej) => {
|
|
55
|
-
const elem = document.getElementById("root");
|
|
56
|
-
if (elem) {
|
|
57
|
-
resolve({ htmlElement: elem });
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
},
|
|
61
|
-
beforeEach: async (
|
|
62
|
-
{ htmlElement },
|
|
63
|
-
initializer,
|
|
64
|
-
testResource,
|
|
65
|
-
artificer,
|
|
66
|
-
initialValues
|
|
67
|
-
): Promise<IStore> => {
|
|
68
|
-
return new Promise((resolve, rej) => {
|
|
69
|
-
// console.log("beforeEach" + JSON.stringify(initializer) + JSON.stringify(initialValues));
|
|
70
|
-
// Ignore these type errors
|
|
71
|
-
ReactDom.createRoot(htmlElement).render(
|
|
72
|
-
createElement(
|
|
73
|
-
TesterantoComponent,
|
|
74
|
-
{
|
|
75
|
-
...initializer,
|
|
76
|
-
done: (reactElement) => {
|
|
77
|
-
resolve({
|
|
78
|
-
htmlElement,
|
|
79
|
-
reactElement,
|
|
80
|
-
});
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
[]
|
|
84
|
-
)
|
|
85
|
-
);
|
|
86
|
-
});
|
|
87
|
-
},
|
|
88
|
-
andWhen: function (s: IStore, whenCB): Promise<ISelection> {
|
|
89
|
-
return whenCB(s);
|
|
90
|
-
},
|
|
91
|
-
butThen: async function (s: IStore): Promise<ISelection> {
|
|
92
|
-
return s;
|
|
93
|
-
},
|
|
94
|
-
afterEach: async function (store: IStore, ndx, artificer) {
|
|
95
|
-
return {};
|
|
96
|
-
},
|
|
97
|
-
afterAll: (store: IStore, artificer) => {
|
|
98
|
-
return;
|
|
99
|
-
},
|
|
100
|
-
}
|
|
101
|
-
);
|
|
158
|
+
return t;
|
|
102
159
|
}
|
|
103
160
|
});
|
|
161
|
+
|
|
162
|
+
return t;
|
|
104
163
|
};
|
package/src/Web.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PM_Web } from "./PM/web";
|
|
1
2
|
import type {
|
|
2
3
|
IBaseTest,
|
|
3
4
|
ITestImplementation,
|
|
@@ -7,21 +8,9 @@ import Testeranto from "./lib/core.js";
|
|
|
7
8
|
import {
|
|
8
9
|
ITTestResourceConfiguration,
|
|
9
10
|
ITTestResourceRequest,
|
|
10
|
-
ITestJob,
|
|
11
11
|
defaultTestResourceRequirement,
|
|
12
12
|
} from "./lib/index.js";
|
|
13
|
-
import {
|
|
14
|
-
INodeUtils,
|
|
15
|
-
ITestInterface,
|
|
16
|
-
IWebTestInterface,
|
|
17
|
-
IWebUtils,
|
|
18
|
-
} from "./lib/types";
|
|
19
|
-
|
|
20
|
-
// const remote = require("@electron/remote");
|
|
21
|
-
// import remote from "@electron/remote";
|
|
22
|
-
// const electron = require("electron");
|
|
23
|
-
// const remote =
|
|
24
|
-
// process.type === "browser" ? electron : require("@electron/remote");
|
|
13
|
+
import { ITestInterface, IWebTestInterface } from "./lib/types";
|
|
25
14
|
|
|
26
15
|
class WebTesteranto<TestShape extends IBaseTest> extends Testeranto<TestShape> {
|
|
27
16
|
constructor(
|
|
@@ -36,66 +25,33 @@ class WebTesteranto<TestShape extends IBaseTest> extends Testeranto<TestShape> {
|
|
|
36
25
|
testSpecification,
|
|
37
26
|
testImplementation,
|
|
38
27
|
testResourceRequirement,
|
|
39
|
-
(window as any).NodeWriter,
|
|
40
28
|
testInterface
|
|
41
29
|
);
|
|
42
|
-
|
|
43
|
-
const testResourceArg = decodeURIComponent(
|
|
44
|
-
new URLSearchParams(location.search).get("requesting") || ""
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
try {
|
|
48
|
-
const partialTestResource = JSON.parse(
|
|
49
|
-
testResourceArg
|
|
50
|
-
) as ITTestResourceConfiguration;
|
|
51
|
-
|
|
52
|
-
this.receiveTestResourceConfig(this.testJobs[0], partialTestResource);
|
|
53
|
-
} catch (e) {
|
|
54
|
-
console.error(e);
|
|
55
|
-
// process.exit(-1);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const requesting = new URLSearchParams(location.search).get("requesting");
|
|
59
|
-
if (requesting) {
|
|
60
|
-
const testResourceArg = decodeURIComponent(requesting);
|
|
61
|
-
|
|
62
|
-
try {
|
|
63
|
-
const partialTestResource = JSON.parse(
|
|
64
|
-
testResourceArg
|
|
65
|
-
) as ITTestResourceConfiguration;
|
|
66
|
-
|
|
67
|
-
console.log("initial test resource", partialTestResource);
|
|
68
|
-
this.receiveTestResourceConfig(this.testJobs[0], partialTestResource);
|
|
69
|
-
} catch (e) {
|
|
70
|
-
console.error(e);
|
|
71
|
-
// process.exit(-1);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
30
|
}
|
|
75
31
|
|
|
76
|
-
async receiveTestResourceConfig(
|
|
77
|
-
t:
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
});
|
|
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
|
+
pm.customclose();
|
|
38
|
+
// Promise.all([...artifacts, logPromise]).then(async () => {
|
|
39
|
+
// console.log("hello world");
|
|
40
|
+
// pm.customclose();
|
|
41
|
+
// // we can't close the window becuase we might be taking a screenshot
|
|
42
|
+
// // window.close();
|
|
43
|
+
// // console.log(
|
|
44
|
+
// // "(window as any).browser",
|
|
45
|
+
// // JSON.stringify(await (window as any).browser)
|
|
46
|
+
// // );
|
|
47
|
+
// // var currentWindow = (await (window as any).browser).getCurrentWindow();
|
|
48
|
+
// // window.close();
|
|
49
|
+
// // var customWindow = window.open("", "_blank", "");
|
|
50
|
+
// // customWindow.close();
|
|
51
|
+
// // this.puppetMaster.browser.page
|
|
52
|
+
// // window["customclose"]();
|
|
53
|
+
// // console.log("goodbye", window["customclose"]());
|
|
54
|
+
// });
|
|
99
55
|
}
|
|
100
56
|
}
|
|
101
57
|
|
|
@@ -29,9 +29,7 @@ export default (
|
|
|
29
29
|
"testeranto.json",
|
|
30
30
|
"features.test.ts",
|
|
31
31
|
// "url",
|
|
32
|
-
|
|
33
32
|
"react",
|
|
34
|
-
"electron",
|
|
35
33
|
|
|
36
34
|
"path",
|
|
37
35
|
"fs",
|
|
@@ -47,6 +45,10 @@ export default (
|
|
|
47
45
|
"zlib",
|
|
48
46
|
"crypto",
|
|
49
47
|
"https",
|
|
48
|
+
|
|
49
|
+
"util",
|
|
50
|
+
"process",
|
|
51
|
+
"dns",
|
|
50
52
|
],
|
|
51
53
|
|
|
52
54
|
platform: "browser",
|