testeranto 0.74.0 → 0.79.3
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 +25 -24
- package/devBot.dockerfile +12 -0
- package/dist/common/Node.js +1 -0
- package/dist/common/PM/index.js +0 -64
- package/dist/common/PM/main.js +278 -7
- package/dist/common/PM/node.js +4 -0
- package/dist/common/PM/web.js +3 -0
- package/dist/common/Project.js +6 -2
- package/dist/common/Puppeteer.js +12 -17
- package/dist/common/Reporter.js +1 -8
- package/dist/common/SubPackages/react-dom/component/web.js +5 -25
- package/dist/common/SubPackages/react-dom/jsx/web.js +80 -55
- package/dist/common/SubPackages/react-test-renderer/component/index.js +0 -86
- package/dist/common/SubPackages/react-test-renderer/component/interface.js +68 -0
- package/dist/common/SubPackages/react-test-renderer/component/node.js +2 -2
- package/dist/common/SubPackages/react-test-renderer/component/web.js +2 -2
- package/dist/common/TaskManBackEnd.js +156 -0
- package/dist/common/Types.js +0 -2
- package/dist/common/esbuildConfigs/index.js +1 -0
- package/dist/common/esbuildConfigs/inputFilesPlugin.js +49 -0
- package/dist/common/esbuildConfigs/node.js +3 -1
- package/dist/common/esbuildConfigs/web.js +3 -1
- package/dist/common/lib/abstractBase.js +222 -17
- package/dist/common/lib/basebuilder.js +4 -38
- package/dist/common/lib/classBuilder.js +1 -3
- package/dist/common/lib/core.js +3 -5
- package/dist/common/mongooseSchemas.js +56 -0
- package/dist/common/tsconfig.common.tsbuildinfo +1 -1
- package/dist/common/utils.js +16 -0
- package/dist/module/ExampleTab.js +112 -0
- package/dist/module/Node.js +1 -0
- package/dist/module/PM/index.js +0 -64
- package/dist/module/PM/main.js +278 -7
- package/dist/module/PM/node.js +4 -0
- package/dist/module/PM/web.js +3 -0
- package/dist/module/Project.js +6 -2
- package/dist/module/Puppeteer.js +12 -17
- package/dist/module/Reporter.js +1 -8
- package/dist/module/SubPackages/react-dom/component/web.js +5 -25
- package/dist/module/SubPackages/react-dom/jsx/web.js +80 -55
- package/dist/module/SubPackages/react-test-renderer/component/index.js +1 -59
- package/dist/module/SubPackages/react-test-renderer/component/interface.js +39 -0
- package/dist/module/SubPackages/react-test-renderer/component/node.js +1 -1
- package/dist/module/SubPackages/react-test-renderer/component/web.js +1 -1
- package/dist/module/TaskManBackEnd.js +151 -0
- package/dist/module/TaskManFrontEnd.js +600 -0
- package/dist/module/Types.js +0 -2
- package/dist/module/esbuildConfigs/index.js +1 -0
- package/dist/module/esbuildConfigs/inputFilesPlugin.js +44 -0
- package/dist/module/esbuildConfigs/node.js +3 -1
- package/dist/module/esbuildConfigs/web.js +3 -1
- package/dist/module/lib/abstractBase.js +222 -17
- package/dist/module/lib/basebuilder.js +4 -38
- package/dist/module/lib/classBuilder.js +1 -3
- package/dist/module/lib/core.js +3 -5
- package/dist/module/mongooseSchemas.js +50 -0
- package/dist/module/tsconfig.module.tsbuildinfo +1 -1
- package/dist/module/utils.js +9 -0
- package/dist/prebuild/Report.js +117 -36
- package/dist/prebuild/TaskManBackEnd.mjs +185 -0
- package/dist/prebuild/TaskManFrontEnd.css +12301 -0
- package/dist/prebuild/TaskManFrontEnd.js +81737 -0
- package/dist/types/Node.d.ts +1 -1
- package/dist/types/PM/index.d.ts +2 -1
- package/dist/types/PM/main.d.ts +8 -3
- package/dist/types/PM/node.d.ts +2 -0
- package/dist/types/PM/web.d.ts +1 -0
- package/dist/types/SubPackages/puppeteer.d.ts +1 -1
- 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/node.d.ts +2 -2
- 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 +8 -2
- package/dist/types/SubPackages/react-dom/jsx/node.d.ts +2 -2
- package/dist/types/SubPackages/react-dom/jsx/web.d.ts +2 -2
- package/dist/types/SubPackages/react-test-renderer/MemoExoticComponent/node.d.ts +2 -2
- package/dist/types/SubPackages/react-test-renderer/component/index.d.ts +0 -7
- package/dist/types/SubPackages/react-test-renderer/component/interface.d.ts +9 -0
- package/dist/types/SubPackages/react-test-renderer/component/node.d.ts +1 -2
- package/dist/types/SubPackages/react-test-renderer/component/web.d.ts +1 -2
- 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 -2
- package/dist/types/SubPackages/react-test-renderer/jsx/web.d.ts +1 -2
- package/dist/types/SubPackages/react-test-renderer/jsx-promised/node.d.ts +1 -2
- package/dist/types/SubPackages/react-test-renderer/jsx-promised/web.d.ts +1 -2
- package/dist/types/TaskManBackEnd.d.ts +1 -0
- package/dist/types/Types.d.ts +19 -19
- package/dist/types/Web.d.ts +1 -1
- package/dist/types/esbuildConfigs/inputFilesPlugin.d.ts +5 -0
- package/dist/types/lib/abstractBase.d.ts +8 -8
- package/dist/types/lib/basebuilder.d.ts +1 -1
- package/dist/types/lib/classBuilder.d.ts +1 -1
- package/dist/types/lib/core.d.ts +1 -1
- package/dist/types/lib/index.d.ts +5 -5
- package/dist/types/lib/types.d.ts +15 -13
- package/dist/types/mongooseSchemas.d.ts +124 -0
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/dist/types/utils.d.ts +2 -0
- package/docker-compose-dev.yml +9 -0
- package/docker-compose-prod.yml +18 -0
- package/package.json +20 -7
- package/src/ExampleTab.tsx +219 -0
- package/src/Node.ts +31 -2
- package/src/PM/index.ts +6 -83
- package/src/PM/main.ts +389 -11
- package/src/PM/node.ts +6 -0
- package/src/PM/web.ts +4 -0
- package/src/Project.ts +10 -2
- package/src/Puppeteer.ts +16 -17
- package/src/Report.tsx +17 -40
- package/src/Reporter.ts +1 -9
- package/src/SubPackages/react-dom/component/web.ts +10 -30
- package/src/SubPackages/react-dom/jsx/web.ts +111 -74
- package/src/SubPackages/react-test-renderer/component/index.ts +0 -66
- package/src/SubPackages/react-test-renderer/component/interface.ts +48 -0
- package/src/SubPackages/react-test-renderer/component/node.ts +2 -1
- package/src/SubPackages/react-test-renderer/component/web.ts +2 -1
- package/src/TaskManBackEnd.ts +200 -0
- package/src/TaskManFrontEnd.tsx +1222 -0
- package/src/Types.ts +136 -28
- package/src/Web.ts +32 -2
- package/src/esbuildConfigs/index.ts +1 -0
- package/src/esbuildConfigs/inputFilesPlugin.ts +65 -0
- package/src/esbuildConfigs/node.ts +3 -1
- package/src/esbuildConfigs/web.ts +4 -0
- package/src/lib/abstractBase.ts +337 -34
- package/src/lib/basebuilder.ts +17 -52
- package/src/lib/classBuilder.ts +14 -2
- package/src/lib/core.ts +18 -7
- package/src/lib/index.ts +115 -7
- package/src/lib/types.ts +143 -35
- package/src/mongooseSchemas.ts +105 -0
- package/src/utils.ts +15 -0
- package/yarn-error.log +3144 -0
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ If so, then testeranto might be the testing tool you have been looking for!
|
|
|
22
22
|
|
|
23
23
|
## about
|
|
24
24
|
|
|
25
|
-
Testeranto.ts an Acceptance Test Driven Development ([ATDD](https://en.wikipedia.org/wiki/Acceptance_test-driven_development)) framework. It
|
|
25
|
+
Testeranto.ts an typescript Acceptance Test Driven Development ([ATDD](https://en.wikipedia.org/wiki/Acceptance_test-driven_development)) framework. It includes a library of common patterns to help write your tests, a test runner to schedule the tests and a reporter to display the results. The tests are specified in a strongly-typed gherkin-like syntax. Features are tracked _as code_, rather than living in a separate app. Tests can be run in the browser frontend or the node backend, or both! Testeranto can be used to test _anything_ that can be bundled with esbuild.
|
|
26
26
|
|
|
27
27
|
## Getting started
|
|
28
28
|
|
|
@@ -45,11 +45,11 @@ Testeranto.ts an Acceptance Test Driven Development ([ATDD](https://en.wikipedia
|
|
|
45
45
|
|
|
46
46
|
## 3 distinguishing features of testeranto
|
|
47
47
|
|
|
48
|
-
1. Rather than testing your code directly, Testeranto requires you wrap your code with a semantic interface which is based on TS type signatures. These interfaces can be shared and your code is
|
|
48
|
+
1. Rather than testing your code directly, Testeranto requires you wrap your code with a semantic interface which is based on TS type signatures. These interfaces can be shared and your code is tested through the gherkin-ish directives provided by that interface.
|
|
49
49
|
|
|
50
|
-
2. Testeranto tracks features and
|
|
50
|
+
2. Testeranto tracks features and tests results directly in the source code. You may be accustomed to using tools like Jira and Trello to define user stories and assign story points. Using Testeranto, this data lives within the code base _as_ typescript code. Features are defined as nodes within a directed graph, allowing the reporter to summarize these features and their test results.
|
|
51
51
|
|
|
52
|
-
3. Testeranto is designed for both the backend and the frontend. It leverages
|
|
52
|
+
3. Testeranto is designed for both the backend and the frontend. It leverages puppeteer to provide both of these runtimes. Each of your tests can be executed in the backend node runtime, within the frontend chromium browser runtime, or both.
|
|
53
53
|
|
|
54
54
|
## the good parts
|
|
55
55
|
|
|
@@ -65,11 +65,11 @@ Rather than the traditional method of specifying tests in plain text, Testeranto
|
|
|
65
65
|
|
|
66
66
|
## the bad parts
|
|
67
67
|
|
|
68
|
-
Testeranto is not designed to maximize performance.
|
|
68
|
+
Testeranto is very flexible and unopinionated, but not designed to maximize performance.
|
|
69
69
|
|
|
70
|
-
Testeranto does not (yet!)
|
|
70
|
+
Testeranto does not (yet!) allow a means of allowing non-coders to affect changes so, as they say, "git good 💪!"
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
Testeranto uses ONLY node v8 and chromium. It does not support bun or deno, nor firefox nor safari.
|
|
73
73
|
|
|
74
74
|
## How it works
|
|
75
75
|
|
|
@@ -81,14 +81,30 @@ Testeranto is comprised of 3 parts
|
|
|
81
81
|
- Build the node-style tests
|
|
82
82
|
- Build the web-style tests
|
|
83
83
|
|
|
84
|
-
2. The test runner watches the output of those build processes and launches the tests as those files change.
|
|
84
|
+
2. The test runner watches the output of those build processes and launches the tests as those files change. It uses puppeteer to run web tests in chromium. It uses dynamic loading to import the node tests directly into the node v8 process.
|
|
85
|
+
|
|
85
86
|
3. A Report which links your features, your tests and the results of those tests into a handy website.
|
|
86
87
|
|
|
88
|
+
## CLI
|
|
89
|
+
|
|
90
|
+
There are 3 commands you should add to your `package.json`
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
// build the tests once
|
|
94
|
+
"testeranto-esbuild": "ts-node-esm testeranto.mts",
|
|
95
|
+
|
|
96
|
+
// build the tests, watching for changes
|
|
97
|
+
"testeranto-esbuild-dev": "ts-node-esm testeranto.mts",
|
|
98
|
+
|
|
99
|
+
// run the tests
|
|
100
|
+
"testeranto-puppeteer":"ts-node-esm node_modules/testeranto/dist/module/Puppeteer.js",
|
|
101
|
+
```
|
|
102
|
+
|
|
87
103
|
## Hybrid tests
|
|
88
104
|
|
|
89
105
|
Consider the a scenario: You have an http server which serves a frontend react component. You have multiple ways you can test this.
|
|
90
106
|
|
|
91
|
-
- A node test of the logic of the http server
|
|
107
|
+
- A node test of the logic of the http server.
|
|
92
108
|
- A node test of the full http server, tested over http request.
|
|
93
109
|
- A node test of the react component with react-test-render
|
|
94
110
|
- A web test of the react component rendering it to the dom.
|
|
@@ -112,18 +128,3 @@ This is designed so that each piece can be worked upon separately. You can think
|
|
|
112
128
|
- "Product Manager" handles the "specification"
|
|
113
129
|
- "Middle Engineer" handles the "interface"
|
|
114
130
|
- "Junior Engineer" handles the "implementation"
|
|
115
|
-
|
|
116
|
-
## CLI
|
|
117
|
-
|
|
118
|
-
There are 3 commands you should add to your `package.json`
|
|
119
|
-
|
|
120
|
-
```
|
|
121
|
-
// build the tests once
|
|
122
|
-
"testeranto-esbuild": "ts-node-esm testeranto.mts",
|
|
123
|
-
|
|
124
|
-
// build the tests, watching for changes
|
|
125
|
-
"testeranto-esbuild-dev": "ts-node-esm testeranto.mts",
|
|
126
|
-
|
|
127
|
-
// run the tests
|
|
128
|
-
"testeranto-puppeteer":"ts-node-esm node_modules/testeranto/dist/module/Puppeteer.js",
|
|
129
|
-
```
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
FROM node:latest
|
|
2
|
+
RUN mkdir -p /usr/src/app
|
|
3
|
+
WORKDIR /usr/src/app
|
|
4
|
+
COPY package.json /usr/src/app
|
|
5
|
+
RUN yarn install
|
|
6
|
+
COPY . /usr/src/app
|
|
7
|
+
|
|
8
|
+
# RUN yarn testeranto-esbuild
|
|
9
|
+
|
|
10
|
+
# EXPOSE 3000
|
|
11
|
+
# CMD ['yarn', 'testeranto-testrun', '&', 'yarn', 'testeranto-taskman']
|
|
12
|
+
CMD ['yarn', 'testeranto-taskman']
|
package/dist/common/Node.js
CHANGED
|
@@ -12,6 +12,7 @@ class NodeTesteranto extends core_js_1.default {
|
|
|
12
12
|
}
|
|
13
13
|
async receiveTestResourceConfig(partialTestResource) {
|
|
14
14
|
const t = JSON.parse(partialTestResource);
|
|
15
|
+
console.log("receiveTestResourceConfig", t);
|
|
15
16
|
const pm = new node_js_1.PM_Node(t);
|
|
16
17
|
const { failed, artifacts, logPromise } = await this.testJobs[0].receiveTestResourceConfig(pm);
|
|
17
18
|
pm.customclose();
|
package/dist/common/PM/index.js
CHANGED
|
@@ -1,71 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// import {
|
|
3
|
-
// Browser,
|
|
4
|
-
// BrowserContext,
|
|
5
|
-
// BrowserContextOptions,
|
|
6
|
-
// DebugInfo,
|
|
7
|
-
// Page,
|
|
8
|
-
// PuppeteerNode,
|
|
9
|
-
// Target,
|
|
10
|
-
// } from "puppeteer-core";
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.PM = void 0;
|
|
13
4
|
const fPaths = [];
|
|
14
5
|
class PM {
|
|
15
6
|
}
|
|
16
7
|
exports.PM = PM;
|
|
17
|
-
// export class PuppetMasterBrowser extends Browser {
|
|
18
|
-
// process(): ChildProcess | null {
|
|
19
|
-
// return super.process();
|
|
20
|
-
// }
|
|
21
|
-
// createBrowserContext(
|
|
22
|
-
// options?: BrowserContextOptions
|
|
23
|
-
// ): Promise<BrowserContext> {
|
|
24
|
-
// throw new Error("Method not implemented.");
|
|
25
|
-
// }
|
|
26
|
-
// browserContexts(): BrowserContext[] {
|
|
27
|
-
// throw new Error("Method not implemented.");
|
|
28
|
-
// }
|
|
29
|
-
// defaultBrowserContext(): BrowserContext {
|
|
30
|
-
// throw new Error("Method not implemented.");
|
|
31
|
-
// }
|
|
32
|
-
// wsEndpoint(): string {
|
|
33
|
-
// throw new Error("Method not implemented.");
|
|
34
|
-
// }
|
|
35
|
-
// newPage(): Promise<Page> {
|
|
36
|
-
// throw new Error("Method not implemented.");
|
|
37
|
-
// }
|
|
38
|
-
// targets(): Target[] {
|
|
39
|
-
// throw new Error("Method not implemented.");
|
|
40
|
-
// }
|
|
41
|
-
// target(): Target {
|
|
42
|
-
// throw new Error("Method not implemented.");
|
|
43
|
-
// }
|
|
44
|
-
// version(): Promise<string> {
|
|
45
|
-
// throw new Error("Method not implemented.");
|
|
46
|
-
// }
|
|
47
|
-
// userAgent(): Promise<string> {
|
|
48
|
-
// throw new Error("Method not implemented.");
|
|
49
|
-
// }
|
|
50
|
-
// close(): Promise<void> {
|
|
51
|
-
// throw new Error("Method not implemented.");
|
|
52
|
-
// }
|
|
53
|
-
// disconnect(): Promise<void> {
|
|
54
|
-
// throw new Error("Method not implemented.");
|
|
55
|
-
// }
|
|
56
|
-
// get connected(): boolean {
|
|
57
|
-
// throw new Error("Method not implemented.");
|
|
58
|
-
// }
|
|
59
|
-
// get debugInfo(): DebugInfo {
|
|
60
|
-
// throw new Error("Method not implemented.");
|
|
61
|
-
// }
|
|
62
|
-
// constructor(...z: []) {
|
|
63
|
-
// super(...z);
|
|
64
|
-
// }
|
|
65
|
-
// // pages(): Promise<Page[]>;
|
|
66
|
-
// pages(): Promise<Page[]> {
|
|
67
|
-
// return new Promise<Page[]>((res, rej) => {
|
|
68
|
-
// res(super.pages());
|
|
69
|
-
// });
|
|
70
|
-
// }
|
|
71
|
-
// }
|
package/dist/common/PM/main.js
CHANGED
|
@@ -31,6 +31,7 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
31
31
|
const path_1 = __importDefault(require("path"));
|
|
32
32
|
const puppeteer_core_1 = __importDefault(require("puppeteer-core"));
|
|
33
33
|
const index_js_1 = require("./index.js");
|
|
34
|
+
const utils_js_1 = require("../utils.js");
|
|
34
35
|
const fPaths = [];
|
|
35
36
|
const fileStreams3 = [];
|
|
36
37
|
const files = {}; // = new Set<string>();
|
|
@@ -62,6 +63,7 @@ class PM_Main extends index_js_1.PM {
|
|
|
62
63
|
}
|
|
63
64
|
else if (testConfigResource.ports > 0) {
|
|
64
65
|
const openPorts = Object.entries(this.ports).filter(([portnumber, portopen]) => portopen);
|
|
66
|
+
console.log("openPorts", openPorts);
|
|
65
67
|
if (openPorts.length >= testConfigResource.ports) {
|
|
66
68
|
for (let i = 0; i < testConfigResource.ports; i++) {
|
|
67
69
|
portsToUse.push(openPorts[i][0]);
|
|
@@ -72,7 +74,7 @@ class PM_Main extends index_js_1.PM {
|
|
|
72
74
|
name: src,
|
|
73
75
|
// ports: [3333],
|
|
74
76
|
ports: portsToUse,
|
|
75
|
-
fs:
|
|
77
|
+
fs: destFolder,
|
|
76
78
|
browserWSEndpoint: this.browser.wsEndpoint(),
|
|
77
79
|
});
|
|
78
80
|
}
|
|
@@ -86,6 +88,14 @@ class PM_Main extends index_js_1.PM {
|
|
|
86
88
|
process.exit(-1);
|
|
87
89
|
}
|
|
88
90
|
const builtfile = dest + ".mjs";
|
|
91
|
+
await Promise.all(testConfig[3].map((sidecar) => {
|
|
92
|
+
if (sidecar[1] === "web") {
|
|
93
|
+
return this.launchWebSideCar(sidecar[0], (0, utils_js_1.destinationOfRuntime)(sidecar[0], "web", this.configs), sidecar);
|
|
94
|
+
}
|
|
95
|
+
if (sidecar[1] === "node") {
|
|
96
|
+
return this.launchNodeSideCar(sidecar[0], (0, utils_js_1.destinationOfRuntime)(sidecar[0], "node", this.configs), sidecar);
|
|
97
|
+
}
|
|
98
|
+
}));
|
|
89
99
|
this.server[builtfile] = await Promise.resolve().then(() => __importStar(require(`${builtfile}?cacheBust=${Date.now()}`))).then((module) => {
|
|
90
100
|
return module.default.then((defaultModule) => {
|
|
91
101
|
defaultModule
|
|
@@ -99,12 +109,231 @@ class PM_Main extends index_js_1.PM {
|
|
|
99
109
|
});
|
|
100
110
|
});
|
|
101
111
|
});
|
|
112
|
+
console.log("portsToUse", portsToUse);
|
|
113
|
+
for (let i = 0; i <= portsToUse.length; i++) {
|
|
114
|
+
if (portsToUse[i]) {
|
|
115
|
+
this.ports[portsToUse[i]] = "true"; //port is open again
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
this.launchWebSideCar = async (src, dest, testConfig) => {
|
|
120
|
+
const d = dest + ".mjs";
|
|
121
|
+
console.log("launchWebSideCar", src, dest, d);
|
|
122
|
+
const destFolder = dest.replace(".mjs", "");
|
|
123
|
+
const webArgz = JSON.stringify({
|
|
124
|
+
name: dest,
|
|
125
|
+
ports: [].toString(),
|
|
126
|
+
fs: destFolder,
|
|
127
|
+
browserWSEndpoint: this.browser.wsEndpoint(),
|
|
128
|
+
});
|
|
129
|
+
const evaluation = `
|
|
130
|
+
console.log("importing ${dest}.mjs");
|
|
131
|
+
import('${dest}.mjs').then(async (x) => {
|
|
132
|
+
console.log("imported", x.default);
|
|
133
|
+
})`;
|
|
134
|
+
const fileStreams2 = [];
|
|
135
|
+
const doneFileStream2 = [];
|
|
136
|
+
return new Promise((res, rej) => {
|
|
137
|
+
this.browser
|
|
138
|
+
.newPage()
|
|
139
|
+
.then((page) => {
|
|
140
|
+
page.on("console", (msg) => {
|
|
141
|
+
console.log("web > ", msg.args(), msg.text());
|
|
142
|
+
// for (let i = 0; i < msg._args.length; ++i)
|
|
143
|
+
// console.log(`${i}: ${msg._args[i]}`);
|
|
144
|
+
});
|
|
145
|
+
page.exposeFunction("custom-screenshot", async (ssOpts, testName) => {
|
|
146
|
+
console.log("main.ts browser custom-screenshot", testName);
|
|
147
|
+
const p = ssOpts.path;
|
|
148
|
+
const dir = path_1.default.dirname(p);
|
|
149
|
+
fs_1.default.mkdirSync(dir, {
|
|
150
|
+
recursive: true,
|
|
151
|
+
});
|
|
152
|
+
files[testName].add(ssOpts.path);
|
|
153
|
+
const sPromise = page.screenshot(Object.assign(Object.assign({}, ssOpts), { path: p }));
|
|
154
|
+
if (!screenshots[testName]) {
|
|
155
|
+
screenshots[testName] = [];
|
|
156
|
+
}
|
|
157
|
+
screenshots[testName].push(sPromise);
|
|
158
|
+
// sPromise.then(())
|
|
159
|
+
await sPromise;
|
|
160
|
+
return sPromise;
|
|
161
|
+
// page.evaluate(`window["screenshot done"]`);
|
|
162
|
+
});
|
|
163
|
+
page.exposeFunction("writeFileSync", (fp, contents, testName) => {
|
|
164
|
+
const dir = path_1.default.dirname(fp);
|
|
165
|
+
fs_1.default.mkdirSync(dir, {
|
|
166
|
+
recursive: true,
|
|
167
|
+
});
|
|
168
|
+
const p = new Promise(async (res, rej) => {
|
|
169
|
+
fs_1.default.writeFileSync(fp, contents);
|
|
170
|
+
res(fp);
|
|
171
|
+
});
|
|
172
|
+
doneFileStream2.push(p);
|
|
173
|
+
if (!files[testName]) {
|
|
174
|
+
files[testName] = new Set();
|
|
175
|
+
}
|
|
176
|
+
files[testName].add(fp);
|
|
177
|
+
return p;
|
|
178
|
+
});
|
|
179
|
+
page.exposeFunction("existsSync", (fp, contents) => {
|
|
180
|
+
return fs_1.default.existsSync(fp);
|
|
181
|
+
});
|
|
182
|
+
page.exposeFunction("mkdirSync", (fp) => {
|
|
183
|
+
if (!fs_1.default.existsSync(fp)) {
|
|
184
|
+
return fs_1.default.mkdirSync(fp, {
|
|
185
|
+
recursive: true,
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
return false;
|
|
189
|
+
});
|
|
190
|
+
page.exposeFunction("createWriteStream", (fp, testName) => {
|
|
191
|
+
const f = fs_1.default.createWriteStream(fp);
|
|
192
|
+
if (!files[testName]) {
|
|
193
|
+
files[testName] = new Set();
|
|
194
|
+
}
|
|
195
|
+
files[testName].add(fp);
|
|
196
|
+
const p = new Promise((res, rej) => {
|
|
197
|
+
res(fp);
|
|
198
|
+
});
|
|
199
|
+
doneFileStream2.push(p);
|
|
200
|
+
f.on("close", async () => {
|
|
201
|
+
await p;
|
|
202
|
+
});
|
|
203
|
+
fileStreams2.push(f);
|
|
204
|
+
return Object.assign(Object.assign({}, JSON.parse(JSON.stringify(f))), { uid: fileStreams2.length - 1 });
|
|
205
|
+
});
|
|
206
|
+
page.exposeFunction("write", async (uid, contents) => {
|
|
207
|
+
return fileStreams2[uid].write(contents);
|
|
208
|
+
});
|
|
209
|
+
page.exposeFunction("end", async (uid) => {
|
|
210
|
+
return fileStreams2[uid].end();
|
|
211
|
+
});
|
|
212
|
+
page.exposeFunction("customclose", (p, testName) => {
|
|
213
|
+
fs_1.default.writeFileSync(p + "/manifest.json", JSON.stringify(Array.from(files[testName])));
|
|
214
|
+
delete files[testName];
|
|
215
|
+
Promise.all(screenshots[testName] || []).then(() => {
|
|
216
|
+
delete screenshots[testName];
|
|
217
|
+
page.close();
|
|
218
|
+
});
|
|
219
|
+
// globalThis["writeFileSync"](
|
|
220
|
+
// p + "/manifest.json",
|
|
221
|
+
// // files.entries()
|
|
222
|
+
// JSON.stringify(Array.from(files[testName]))
|
|
223
|
+
// );
|
|
224
|
+
// console.log("closing doneFileStream2", doneFileStream2);
|
|
225
|
+
// console.log("closing doneFileStream2", doneFileStream2);
|
|
226
|
+
// Promise.all([...doneFileStream2, ...screenshots2]).then(() => {
|
|
227
|
+
// page.close();
|
|
228
|
+
// });
|
|
229
|
+
// Promise.all(screenshots).then(() => {
|
|
230
|
+
// page.close();
|
|
231
|
+
// });
|
|
232
|
+
// setTimeout(() => {
|
|
233
|
+
// console.log("Delayed for 1 second.");
|
|
234
|
+
// page.close();
|
|
235
|
+
// }, 5000);
|
|
236
|
+
// return page.close();
|
|
237
|
+
});
|
|
238
|
+
return page;
|
|
239
|
+
})
|
|
240
|
+
.then(async (page) => {
|
|
241
|
+
page.on("console", (log) => console.debug(`Log from client: [${log.text()}] `));
|
|
242
|
+
await page.goto(`file://${`${dest}.html`}`, {});
|
|
243
|
+
res(page);
|
|
244
|
+
// page.evaluate(evaluation).finally(() => {
|
|
245
|
+
// console.log("evaluation failed.", dest);
|
|
246
|
+
// });
|
|
247
|
+
// return page;
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
};
|
|
251
|
+
// launchNodeSideCar = async (src: string, dest: string) => {};
|
|
252
|
+
this.launchNodeSideCar = async (src, dest, testConfig) => {
|
|
253
|
+
const d = dest + ".mjs";
|
|
254
|
+
console.log("launchNodeSideCar", src, dest, d);
|
|
255
|
+
const destFolder = dest.replace(".mjs", "");
|
|
256
|
+
let argz = "";
|
|
257
|
+
// const testConfig = this.configs.tests.find((t) => {
|
|
258
|
+
// return t[0] === src;
|
|
259
|
+
// });
|
|
260
|
+
// if (!testConfig) {
|
|
261
|
+
// console.error("missing test config");
|
|
262
|
+
// process.exit(-1);
|
|
263
|
+
// }
|
|
264
|
+
const testConfigResource = testConfig[2];
|
|
265
|
+
let portsToUse = [];
|
|
266
|
+
if (testConfigResource.ports === 0) {
|
|
267
|
+
argz = JSON.stringify({
|
|
268
|
+
scheduled: true,
|
|
269
|
+
name: src,
|
|
270
|
+
ports: portsToUse,
|
|
271
|
+
fs: destFolder,
|
|
272
|
+
browserWSEndpoint: this.browser.wsEndpoint(),
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
else if (testConfigResource.ports > 0) {
|
|
276
|
+
const openPorts = Object.entries(this.ports).filter(([portnumber, portopen]) => portopen);
|
|
277
|
+
console.log("openPorts", openPorts);
|
|
278
|
+
if (openPorts.length >= testConfigResource.ports) {
|
|
279
|
+
for (let i = 0; i < testConfigResource.ports; i++) {
|
|
280
|
+
portsToUse.push(openPorts[i][0]);
|
|
281
|
+
this.ports[openPorts[i][0]] = false; // port is now closed
|
|
282
|
+
}
|
|
283
|
+
argz = JSON.stringify({
|
|
284
|
+
scheduled: true,
|
|
285
|
+
name: src,
|
|
286
|
+
// ports: [3333],
|
|
287
|
+
ports: portsToUse,
|
|
288
|
+
fs: ".",
|
|
289
|
+
browserWSEndpoint: this.browser.wsEndpoint(),
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
this.queue.push(src);
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
else {
|
|
298
|
+
console.error("negative port makes no sense", src);
|
|
299
|
+
process.exit(-1);
|
|
300
|
+
}
|
|
301
|
+
const builtfile = dest + ".mjs";
|
|
302
|
+
// console.log(
|
|
303
|
+
// "node builtfile",
|
|
304
|
+
// (await import(`${builtfile}?cacheBust=${Date.now()}`)).default
|
|
305
|
+
// );
|
|
306
|
+
this.server[builtfile] = await Promise.resolve().then(() => __importStar(require(`${builtfile}?cacheBust=${Date.now()}`))).then((module) => {
|
|
307
|
+
return module.default.then((defaultModule) => {
|
|
308
|
+
console.log("defaultModule", defaultModule);
|
|
309
|
+
const s = new defaultModule();
|
|
310
|
+
s.receiveTestResourceConfig(argz);
|
|
311
|
+
// Object.create(defaultModule);
|
|
312
|
+
// defaultModule
|
|
313
|
+
// .receiveTestResourceConfig(argz)
|
|
314
|
+
// .then((x) => {
|
|
315
|
+
// console.log("then", x);
|
|
316
|
+
// return x;
|
|
317
|
+
// })
|
|
318
|
+
// .catch((e) => {
|
|
319
|
+
// console.log("catch", e);
|
|
320
|
+
// });
|
|
321
|
+
});
|
|
322
|
+
});
|
|
323
|
+
console.log("portsToUse", portsToUse);
|
|
102
324
|
for (let i = 0; i <= portsToUse.length; i++) {
|
|
103
|
-
|
|
325
|
+
if (portsToUse[i]) {
|
|
326
|
+
this.ports[portsToUse[i]] = "true"; //port is open again
|
|
327
|
+
}
|
|
104
328
|
}
|
|
105
329
|
};
|
|
106
|
-
this.launchWeb = (t, dest) => {
|
|
330
|
+
this.launchWeb = (t, dest, sidecars) => {
|
|
107
331
|
console.log("launchWeb", t, dest);
|
|
332
|
+
sidecars.map((sidecar) => {
|
|
333
|
+
if (sidecar[1] === "node") {
|
|
334
|
+
return this.launchNodeSideCar(sidecar[0], (0, utils_js_1.destinationOfRuntime)(sidecar[0], "node", this.configs), sidecar);
|
|
335
|
+
}
|
|
336
|
+
});
|
|
108
337
|
const destFolder = dest.replace(".mjs", "");
|
|
109
338
|
const webArgz = JSON.stringify({
|
|
110
339
|
name: dest,
|
|
@@ -112,8 +341,10 @@ class PM_Main extends index_js_1.PM {
|
|
|
112
341
|
fs: destFolder,
|
|
113
342
|
browserWSEndpoint: this.browser.wsEndpoint(),
|
|
114
343
|
});
|
|
115
|
-
const evaluation = `
|
|
116
|
-
|
|
344
|
+
const evaluation = `
|
|
345
|
+
console.log("importing ${dest}.mjs");
|
|
346
|
+
import('${dest}.mjs').then(async (x) => {
|
|
347
|
+
console.log("imported", x.default);
|
|
117
348
|
try {
|
|
118
349
|
await (await x.default).receiveTestResourceConfig(${webArgz})
|
|
119
350
|
} catch (e) {
|
|
@@ -121,18 +352,25 @@ class PM_Main extends index_js_1.PM {
|
|
|
121
352
|
}
|
|
122
353
|
})`;
|
|
123
354
|
const fileStreams2 = [];
|
|
124
|
-
// const screenshots2: Promise<any>[] = [];
|
|
125
355
|
const doneFileStream2 = [];
|
|
126
356
|
this.browser
|
|
127
357
|
.newPage()
|
|
128
358
|
.then((page) => {
|
|
129
|
-
page.
|
|
359
|
+
page.on("console", (msg) => {
|
|
360
|
+
console.log("web > ", msg.args(), msg.text());
|
|
361
|
+
// for (let i = 0; i < msg._args.length; ++i)
|
|
362
|
+
// console.log(`${i}: ${msg._args[i]}`);
|
|
363
|
+
});
|
|
364
|
+
page.exposeFunction("customScreenShot", async (ssOpts, testName) => {
|
|
130
365
|
console.log("main.ts browser custom-screenshot", testName);
|
|
131
366
|
const p = ssOpts.path;
|
|
132
367
|
const dir = path_1.default.dirname(p);
|
|
133
368
|
fs_1.default.mkdirSync(dir, {
|
|
134
369
|
recursive: true,
|
|
135
370
|
});
|
|
371
|
+
if (!files[testName]) {
|
|
372
|
+
files[testName] = new Set();
|
|
373
|
+
}
|
|
136
374
|
files[testName].add(ssOpts.path);
|
|
137
375
|
const sPromise = page.screenshot(Object.assign(Object.assign({}, ssOpts), { path: p }));
|
|
138
376
|
if (!screenshots[testName]) {
|
|
@@ -194,6 +432,7 @@ class PM_Main extends index_js_1.PM {
|
|
|
194
432
|
return fileStreams2[uid].end();
|
|
195
433
|
});
|
|
196
434
|
page.exposeFunction("customclose", (p, testName) => {
|
|
435
|
+
console.log("\t closing", p);
|
|
197
436
|
fs_1.default.writeFileSync(p + "/manifest.json", JSON.stringify(Array.from(files[testName])));
|
|
198
437
|
delete files[testName];
|
|
199
438
|
Promise.all(screenshots[testName] || []).then(() => {
|
|
@@ -222,6 +461,7 @@ class PM_Main extends index_js_1.PM {
|
|
|
222
461
|
return page;
|
|
223
462
|
})
|
|
224
463
|
.then(async (page) => {
|
|
464
|
+
page.on("console", (log) => console.debug(`Log from client: [${log.text()}] `));
|
|
225
465
|
await page.goto(`file://${`${dest}.html`}`, {});
|
|
226
466
|
page.evaluate(evaluation).finally(() => {
|
|
227
467
|
console.log("evaluation failed.", dest);
|
|
@@ -244,6 +484,7 @@ class PM_Main extends index_js_1.PM {
|
|
|
244
484
|
return false;
|
|
245
485
|
};
|
|
246
486
|
globalThis["writeFileSync"] = (filepath, contents, testName) => {
|
|
487
|
+
console.log("globalThis-writeFileSync", filepath);
|
|
247
488
|
// Create directories if they don't exist
|
|
248
489
|
const dir = path_1.default.dirname(filepath.split("/").slice(0, -1).join("/"));
|
|
249
490
|
fs_1.default.mkdirSync(dir, {
|
|
@@ -271,6 +512,33 @@ class PM_Main extends index_js_1.PM {
|
|
|
271
512
|
globalThis["end"] = (uid) => {
|
|
272
513
|
fileStreams3[uid].end();
|
|
273
514
|
};
|
|
515
|
+
globalThis["customScreenShot"] = async (opts, page) => {
|
|
516
|
+
// // fileStreams3[uid].write(contents);
|
|
517
|
+
// // console.log("asd", opts.path.split("/").slice(0, -1).join("/"));
|
|
518
|
+
// // const dir = path.dirname(opts.path.split("/").slice(0, -1).join("/"));
|
|
519
|
+
// // console.log("dir", dir);
|
|
520
|
+
// fs.mkdirSync(opts.path.split("/").slice(0, -1).join("/"), {
|
|
521
|
+
// recursive: true,
|
|
522
|
+
// });
|
|
523
|
+
// return page.screenshot(opts);
|
|
524
|
+
console.log("main.ts node custom-screenshot", page);
|
|
525
|
+
const p = opts.path;
|
|
526
|
+
const dir = path_1.default.dirname(p);
|
|
527
|
+
fs_1.default.mkdirSync(dir, {
|
|
528
|
+
recursive: true,
|
|
529
|
+
});
|
|
530
|
+
if (!files[opts.path]) {
|
|
531
|
+
files[opts.path] = new Set();
|
|
532
|
+
}
|
|
533
|
+
files[opts.path].add(opts.path);
|
|
534
|
+
const sPromise = page.screenshot(Object.assign(Object.assign({}, opts), { path: p }));
|
|
535
|
+
if (!screenshots[opts.path]) {
|
|
536
|
+
screenshots[opts.path] = [];
|
|
537
|
+
}
|
|
538
|
+
screenshots[opts.path].push(sPromise);
|
|
539
|
+
await sPromise;
|
|
540
|
+
return sPromise;
|
|
541
|
+
};
|
|
274
542
|
globalThis["customclose"] = (p, testName) => {
|
|
275
543
|
if (!files[testName]) {
|
|
276
544
|
files[testName] = new Set();
|
|
@@ -301,6 +569,9 @@ class PM_Main extends index_js_1.PM {
|
|
|
301
569
|
// // return page.close();
|
|
302
570
|
// });
|
|
303
571
|
}
|
|
572
|
+
customScreenShot(opts) {
|
|
573
|
+
throw new Error("Method not implemented.");
|
|
574
|
+
}
|
|
304
575
|
async startPuppeteer(options, destfolder) {
|
|
305
576
|
this.browser = await puppeteer_core_1.default.launch(options);
|
|
306
577
|
return this.browser;
|
package/dist/common/PM/node.js
CHANGED
|
@@ -15,6 +15,9 @@ class PM_Node extends index_js_1.PM {
|
|
|
15
15
|
this.server = {};
|
|
16
16
|
this.testResourceConfiguration = t;
|
|
17
17
|
}
|
|
18
|
+
customScreenShot(opts, page) {
|
|
19
|
+
return globalThis["customScreenShot"](opts, page);
|
|
20
|
+
}
|
|
18
21
|
existsSync(destFolder) {
|
|
19
22
|
return globalThis["existsSync"](this.testResourceConfiguration.fs + "/" + destFolder);
|
|
20
23
|
}
|
|
@@ -25,6 +28,7 @@ class PM_Node extends index_js_1.PM {
|
|
|
25
28
|
return globalThis["write"](writeObject.uid, contents);
|
|
26
29
|
}
|
|
27
30
|
writeFileSync(filepath, contents) {
|
|
31
|
+
console.log("pm_node-writeFileSync", this.testResourceConfiguration);
|
|
28
32
|
return globalThis["writeFileSync"](this.testResourceConfiguration.fs + "/" + filepath, contents, this.testResourceConfiguration.name);
|
|
29
33
|
}
|
|
30
34
|
createWriteStream(filepath) {
|
package/dist/common/PM/web.js
CHANGED
package/dist/common/Project.js
CHANGED
|
@@ -76,6 +76,9 @@ class ITProject {
|
|
|
76
76
|
.then((x) => fs_1.default.writeFileSync(htmlFilePath, (0, web_html_js_1.default)(jsfilePath, htmlFilePath)));
|
|
77
77
|
})));
|
|
78
78
|
const [nodeEntryPoints, webEntryPoints] = getRunnables(this.config.tests);
|
|
79
|
+
console.log(`this.getSecondaryEndpointsPoints("web")`, this.getSecondaryEndpointsPoints("web"));
|
|
80
|
+
// console.log("nodeEntryPoints", nodeEntryPoints);
|
|
81
|
+
// console.log("webEntryPoints", webEntryPoints);
|
|
79
82
|
// nodeEntryPoints.forEach((nep) => {
|
|
80
83
|
// const f = `${process.cwd()}/${nep}`;
|
|
81
84
|
// console.log("nep", f);
|
|
@@ -153,11 +156,12 @@ class ITProject {
|
|
|
153
156
|
getSecondaryEndpointsPoints(runtime) {
|
|
154
157
|
const meta = (ts, st) => {
|
|
155
158
|
ts.forEach((t) => {
|
|
159
|
+
console.log("getSecondaryEndpointsPoints", t);
|
|
156
160
|
if (t[1] === runtime) {
|
|
157
161
|
st.add(t[0]);
|
|
158
162
|
}
|
|
159
|
-
if (Array.isArray(t[
|
|
160
|
-
meta(t[
|
|
163
|
+
if (Array.isArray(t[3])) {
|
|
164
|
+
meta(t[3], st);
|
|
161
165
|
}
|
|
162
166
|
});
|
|
163
167
|
return st;
|