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
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.destinationOfRuntime = void 0;
|
|
7
|
+
// import { configs } from "eslint-plugin-react";
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const destinationOfRuntime = (f, r, configs) => {
|
|
10
|
+
return path_1.default
|
|
11
|
+
.normalize(`${configs.buildDir}/${r}/${f}`)
|
|
12
|
+
.split(".")
|
|
13
|
+
.slice(0, -1)
|
|
14
|
+
.join(".");
|
|
15
|
+
};
|
|
16
|
+
exports.destinationOfRuntime = destinationOfRuntime;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
|
+
import Col from 'react-bootstrap/Col';
|
|
3
|
+
import Nav from 'react-bootstrap/Nav';
|
|
4
|
+
import Row from 'react-bootstrap/Row';
|
|
5
|
+
import Tab from 'react-bootstrap/Tab';
|
|
6
|
+
import Tabs from 'react-bootstrap/Tabs';
|
|
7
|
+
import 'bootstrap/dist/css/bootstrap.min.css';
|
|
8
|
+
const queryString = window.location.search;
|
|
9
|
+
// Create a URLSearchParams object
|
|
10
|
+
const urlParams = new URLSearchParams(queryString);
|
|
11
|
+
console.log("urlParams", urlParams.has("local"));
|
|
12
|
+
// Get the value of a specific parameter
|
|
13
|
+
const isLocal = urlParams.get("local");
|
|
14
|
+
const urlFixer = (url) => {
|
|
15
|
+
if (isLocal) {
|
|
16
|
+
return `file:///Users/adam/Code/kokomoBay/${url}`;
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
return `https://chromapdx.github.io/kokomoBay/${url}`;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const TextTab = (props) => {
|
|
23
|
+
const [text, setText] = useState('');
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
fetch(props.url) // Replace with your API endpoint
|
|
26
|
+
.then(response => response.text())
|
|
27
|
+
.then(data => setText(data))
|
|
28
|
+
.catch(error => console.error('Error fetching text:', error));
|
|
29
|
+
}, []);
|
|
30
|
+
return React.createElement("code", null,
|
|
31
|
+
React.createElement("pre", null, text));
|
|
32
|
+
};
|
|
33
|
+
export default () => {
|
|
34
|
+
return (React.createElement(Tab.Container, { id: "left-tabs-example5", defaultActiveKey: "examples-0" },
|
|
35
|
+
React.createElement(Row, null,
|
|
36
|
+
React.createElement(Col, { sm: 3, lg: 2 },
|
|
37
|
+
React.createElement(Nav, { variant: "pills", className: "flex-column" },
|
|
38
|
+
React.createElement(Nav.Link, { eventKey: `manual-example-rectangle` }, "RECTANGLE"),
|
|
39
|
+
React.createElement(Nav.Link, { eventKey: `manual-example-ClassicalComponent` }, "ClassicalComponent"),
|
|
40
|
+
React.createElement(Nav.Link, { eventKey: `manual-example-react+sol` }, "React and solidity"))),
|
|
41
|
+
React.createElement(Col, { sm: 3, lg: 2 },
|
|
42
|
+
React.createElement(Tab.Content, null,
|
|
43
|
+
React.createElement(Tab.Pane, { eventKey: `manual-example-rectangle`, key: `manual-example-rectangle` },
|
|
44
|
+
React.createElement("pre", null, "In this contrived example, we are testing the Rectangle class. Node that because it uses no web-specific, nor node-specific language features, it can be run in either runtime, thought it more efficient and reasonable to test in node.")),
|
|
45
|
+
React.createElement(Tab.Pane, { eventKey: `manual-example-ClassicalComponent`, key: `manual-example-ClassicalComponent` },
|
|
46
|
+
React.createElement("pre", null, "Testing a react component with the react-test-renderer package.")),
|
|
47
|
+
React.createElement(Tab.Pane, { eventKey: `manual-example-react+sol`, key: `manual-example-react+sol` },
|
|
48
|
+
React.createElement("pre", null, "Testing a react component which is backed by a solidity contract. This test is performed _on_ the server but but _through_ the browser. The react element is renderer into an chromium window and accessed by puppeteer.")))),
|
|
49
|
+
React.createElement(Col, null,
|
|
50
|
+
React.createElement(Tab.Content, null,
|
|
51
|
+
React.createElement(Tab.Pane, { eventKey: `manual-example-rectangle`, key: `manual-example-rectangle` },
|
|
52
|
+
React.createElement(Tabs, { defaultActiveKey: "profile", id: "uncontrolled-tab-example", className: "mb-3" },
|
|
53
|
+
React.createElement(Tab, { eventKey: "Rectangle.ts", title: "Rectangle.ts" },
|
|
54
|
+
React.createElement(TextTab, { url: urlFixer("src/Rectangle.ts") })),
|
|
55
|
+
React.createElement(Tab, { eventKey: "Rectangle.test.specification.ts", title: "Rectangle.test.specification.ts" },
|
|
56
|
+
React.createElement(TextTab, { url: urlFixer("src/Rectangle.test.specification.ts") })),
|
|
57
|
+
React.createElement(Tab, { eventKey: "Rectangle.test.shape.ts", title: "Rectangle.test.shape.ts" },
|
|
58
|
+
React.createElement(TextTab, { url: urlFixer("src/Rectangle.test.shape.ts") })),
|
|
59
|
+
React.createElement(Tab, { eventKey: "Rectangle.test.implementation.ts", title: "Rectangle.test.implementation.ts" },
|
|
60
|
+
React.createElement(TextTab, { url: urlFixer("src/Rectangle.test.implementation.ts") })),
|
|
61
|
+
React.createElement(Tab, { eventKey: "Rectangle.test.interface.ts", title: "Rectangle.test.interface.ts" },
|
|
62
|
+
React.createElement(TextTab, { url: urlFixer("src/Rectangle.test.interface.ts") })),
|
|
63
|
+
React.createElement(Tab, { eventKey: "Rectangle.config", title: "Rectangle.config" },
|
|
64
|
+
React.createElement("code", null,
|
|
65
|
+
React.createElement("pre", null, `
|
|
66
|
+
...
|
|
67
|
+
|
|
68
|
+
// Run the test in node
|
|
69
|
+
"./src/Rectangle/Rectangle.test.node.ts",
|
|
70
|
+
"node",
|
|
71
|
+
{ ports: 0 },
|
|
72
|
+
[],
|
|
73
|
+
],
|
|
74
|
+
|
|
75
|
+
// Run the same test in chromium too!
|
|
76
|
+
"./src/Rectangle/Rectangle.test.web.ts",
|
|
77
|
+
"web",
|
|
78
|
+
{ ports: 0 },
|
|
79
|
+
[],
|
|
80
|
+
],
|
|
81
|
+
|
|
82
|
+
...
|
|
83
|
+
`))))),
|
|
84
|
+
React.createElement(Tab.Pane, { eventKey: `manual-example-ClassicalComponent`, key: `manual-example-ClassicalComponent` },
|
|
85
|
+
React.createElement(Tabs, { defaultActiveKey: "profile", id: "uncontrolled-tab-example", className: "mb-3" },
|
|
86
|
+
React.createElement(Tab, { eventKey: "ClassicalComponent/index.tsx", title: "ClassicalComponent/index.tsx" },
|
|
87
|
+
React.createElement(TextTab, { url: urlFixer("src/ClassicalComponent/index.tsx") })),
|
|
88
|
+
React.createElement(Tab, { eventKey: "ClassicalComponent/test.specification.ts", title: "ClassicalComponent/test.specification.ts" },
|
|
89
|
+
React.createElement(TextTab, { url: urlFixer("src/ClassicalComponent/test.specification.ts") })),
|
|
90
|
+
React.createElement(Tab, { eventKey: "ClassicalComponent/test.shape.ts", title: "ClassicalComponent/test.shape.ts" },
|
|
91
|
+
React.createElement(TextTab, { url: urlFixer("src/ClassicalComponent/test.shape.ts") })),
|
|
92
|
+
React.createElement(Tab, { eventKey: "ClassicalComponent/react-test-renderer/test.implementation.ts", title: "ClassicalComponent/react-test-renderer/test.implementation.ts" },
|
|
93
|
+
React.createElement(TextTab, { url: urlFixer("src/ClassicalComponent/react-test-renderer/test.implementation.ts") })),
|
|
94
|
+
React.createElement(Tab, { eventKey: "react-test-renderer/test.interface.ts", title: "react-test-renderer/test.interface.ts" },
|
|
95
|
+
React.createElement(TextTab, { url: "https://raw.githubusercontent.com/adamwong246/testeranto/master/src/subPackages/react-test-renderer/component/interface.ts" })))),
|
|
96
|
+
React.createElement(Tab.Pane, { eventKey: `manual-example-react+sol`, key: `manual-example-react+sol` },
|
|
97
|
+
React.createElement(Tabs, { defaultActiveKey: "profile", id: "uncontrolled-tab-example", className: "mb-3" },
|
|
98
|
+
React.createElement(Tab, { eventKey: "contracts/MyBaseContract.sol", title: "MyBaseContract.sol" },
|
|
99
|
+
React.createElement(TextTab, { url: urlFixer("contracts/MyBaseContract.sol") })),
|
|
100
|
+
React.createElement(Tab, { eventKey: "src/MyFirstContractUI.tsx", title: "MyFirstContractUI.tsx" },
|
|
101
|
+
React.createElement(TextTab, { url: urlFixer("src/MyFirstContractUI.tsx") })),
|
|
102
|
+
React.createElement(Tab, { eventKey: "src/MyFirstContract.specification.test.ts", title: "MyFirstContract.specification.test.ts" },
|
|
103
|
+
React.createElement(TextTab, { url: urlFixer("src/MyFirstContract.specification.test.ts") })),
|
|
104
|
+
React.createElement(Tab, { eventKey: "src/MyFirstContract.solidity-react.interface.test.ts", title: "MyFirstContract.solidity-react.interface.test.ts" },
|
|
105
|
+
React.createElement(TextTab, { url: urlFixer("src/MyFirstContract.solidity-react.interface.test.ts") })),
|
|
106
|
+
React.createElement(Tab, { eventKey: "src/MyFirstContract.solidity-react.implementation.test.ts", title: "MyFirstContract.solidity-react.implementation.test.ts" },
|
|
107
|
+
React.createElement(TextTab, { url: urlFixer("src/MyFirstContract.solidity-react.implementation.test.ts") })),
|
|
108
|
+
React.createElement(Tab, { eventKey: "src/MyFirstContract.solidity-react.shape.test.ts", title: "MyFirstContract.solidity-react.shape.test.ts" },
|
|
109
|
+
React.createElement(TextTab, { url: urlFixer("src/MyFirstContract.solidity-react.shape.test.ts") })),
|
|
110
|
+
React.createElement(Tab, { eventKey: "MyFirstContract.solidity-react-example-jpg", title: "screenshot" },
|
|
111
|
+
React.createElement("img", { src: urlFixer("docs/node/src/MyFirstContract.solidity-react.testeranto/suite-0/given-test1/when/0/afterEach/andWhen.jpg") })))))))));
|
|
112
|
+
};
|
package/dist/module/Node.js
CHANGED
|
@@ -7,6 +7,7 @@ class NodeTesteranto extends Testeranto {
|
|
|
7
7
|
}
|
|
8
8
|
async receiveTestResourceConfig(partialTestResource) {
|
|
9
9
|
const t = JSON.parse(partialTestResource);
|
|
10
|
+
console.log("receiveTestResourceConfig", t);
|
|
10
11
|
const pm = new PM_Node(t);
|
|
11
12
|
const { failed, artifacts, logPromise } = await this.testJobs[0].receiveTestResourceConfig(pm);
|
|
12
13
|
pm.customclose();
|
package/dist/module/PM/index.js
CHANGED
|
@@ -1,67 +1,3 @@
|
|
|
1
|
-
// import {
|
|
2
|
-
// Browser,
|
|
3
|
-
// BrowserContext,
|
|
4
|
-
// BrowserContextOptions,
|
|
5
|
-
// DebugInfo,
|
|
6
|
-
// Page,
|
|
7
|
-
// PuppeteerNode,
|
|
8
|
-
// Target,
|
|
9
|
-
// } from "puppeteer-core";
|
|
10
1
|
const fPaths = [];
|
|
11
2
|
export class PM {
|
|
12
3
|
}
|
|
13
|
-
// export class PuppetMasterBrowser extends Browser {
|
|
14
|
-
// process(): ChildProcess | null {
|
|
15
|
-
// return super.process();
|
|
16
|
-
// }
|
|
17
|
-
// createBrowserContext(
|
|
18
|
-
// options?: BrowserContextOptions
|
|
19
|
-
// ): Promise<BrowserContext> {
|
|
20
|
-
// throw new Error("Method not implemented.");
|
|
21
|
-
// }
|
|
22
|
-
// browserContexts(): BrowserContext[] {
|
|
23
|
-
// throw new Error("Method not implemented.");
|
|
24
|
-
// }
|
|
25
|
-
// defaultBrowserContext(): BrowserContext {
|
|
26
|
-
// throw new Error("Method not implemented.");
|
|
27
|
-
// }
|
|
28
|
-
// wsEndpoint(): string {
|
|
29
|
-
// throw new Error("Method not implemented.");
|
|
30
|
-
// }
|
|
31
|
-
// newPage(): Promise<Page> {
|
|
32
|
-
// throw new Error("Method not implemented.");
|
|
33
|
-
// }
|
|
34
|
-
// targets(): Target[] {
|
|
35
|
-
// throw new Error("Method not implemented.");
|
|
36
|
-
// }
|
|
37
|
-
// target(): Target {
|
|
38
|
-
// throw new Error("Method not implemented.");
|
|
39
|
-
// }
|
|
40
|
-
// version(): Promise<string> {
|
|
41
|
-
// throw new Error("Method not implemented.");
|
|
42
|
-
// }
|
|
43
|
-
// userAgent(): Promise<string> {
|
|
44
|
-
// throw new Error("Method not implemented.");
|
|
45
|
-
// }
|
|
46
|
-
// close(): Promise<void> {
|
|
47
|
-
// throw new Error("Method not implemented.");
|
|
48
|
-
// }
|
|
49
|
-
// disconnect(): Promise<void> {
|
|
50
|
-
// throw new Error("Method not implemented.");
|
|
51
|
-
// }
|
|
52
|
-
// get connected(): boolean {
|
|
53
|
-
// throw new Error("Method not implemented.");
|
|
54
|
-
// }
|
|
55
|
-
// get debugInfo(): DebugInfo {
|
|
56
|
-
// throw new Error("Method not implemented.");
|
|
57
|
-
// }
|
|
58
|
-
// constructor(...z: []) {
|
|
59
|
-
// super(...z);
|
|
60
|
-
// }
|
|
61
|
-
// // pages(): Promise<Page[]>;
|
|
62
|
-
// pages(): Promise<Page[]> {
|
|
63
|
-
// return new Promise<Page[]>((res, rej) => {
|
|
64
|
-
// res(super.pages());
|
|
65
|
-
// });
|
|
66
|
-
// }
|
|
67
|
-
// }
|
package/dist/module/PM/main.js
CHANGED
|
@@ -2,6 +2,7 @@ import fs from "fs";
|
|
|
2
2
|
import path from "path";
|
|
3
3
|
import puppeteer from "puppeteer-core";
|
|
4
4
|
import { PM } from "./index.js";
|
|
5
|
+
import { destinationOfRuntime } from "../utils.js";
|
|
5
6
|
const fPaths = [];
|
|
6
7
|
const fileStreams3 = [];
|
|
7
8
|
const files = {}; // = new Set<string>();
|
|
@@ -33,6 +34,7 @@ export class PM_Main extends PM {
|
|
|
33
34
|
}
|
|
34
35
|
else if (testConfigResource.ports > 0) {
|
|
35
36
|
const openPorts = Object.entries(this.ports).filter(([portnumber, portopen]) => portopen);
|
|
37
|
+
console.log("openPorts", openPorts);
|
|
36
38
|
if (openPorts.length >= testConfigResource.ports) {
|
|
37
39
|
for (let i = 0; i < testConfigResource.ports; i++) {
|
|
38
40
|
portsToUse.push(openPorts[i][0]);
|
|
@@ -43,7 +45,7 @@ export class PM_Main extends PM {
|
|
|
43
45
|
name: src,
|
|
44
46
|
// ports: [3333],
|
|
45
47
|
ports: portsToUse,
|
|
46
|
-
fs:
|
|
48
|
+
fs: destFolder,
|
|
47
49
|
browserWSEndpoint: this.browser.wsEndpoint(),
|
|
48
50
|
});
|
|
49
51
|
}
|
|
@@ -57,6 +59,14 @@ export class PM_Main extends PM {
|
|
|
57
59
|
process.exit(-1);
|
|
58
60
|
}
|
|
59
61
|
const builtfile = dest + ".mjs";
|
|
62
|
+
await Promise.all(testConfig[3].map((sidecar) => {
|
|
63
|
+
if (sidecar[1] === "web") {
|
|
64
|
+
return this.launchWebSideCar(sidecar[0], destinationOfRuntime(sidecar[0], "web", this.configs), sidecar);
|
|
65
|
+
}
|
|
66
|
+
if (sidecar[1] === "node") {
|
|
67
|
+
return this.launchNodeSideCar(sidecar[0], destinationOfRuntime(sidecar[0], "node", this.configs), sidecar);
|
|
68
|
+
}
|
|
69
|
+
}));
|
|
60
70
|
this.server[builtfile] = await import(`${builtfile}?cacheBust=${Date.now()}`).then((module) => {
|
|
61
71
|
return module.default.then((defaultModule) => {
|
|
62
72
|
defaultModule
|
|
@@ -70,12 +80,231 @@ export class PM_Main extends PM {
|
|
|
70
80
|
});
|
|
71
81
|
});
|
|
72
82
|
});
|
|
83
|
+
console.log("portsToUse", portsToUse);
|
|
84
|
+
for (let i = 0; i <= portsToUse.length; i++) {
|
|
85
|
+
if (portsToUse[i]) {
|
|
86
|
+
this.ports[portsToUse[i]] = "true"; //port is open again
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
this.launchWebSideCar = async (src, dest, testConfig) => {
|
|
91
|
+
const d = dest + ".mjs";
|
|
92
|
+
console.log("launchWebSideCar", src, dest, d);
|
|
93
|
+
const destFolder = dest.replace(".mjs", "");
|
|
94
|
+
const webArgz = JSON.stringify({
|
|
95
|
+
name: dest,
|
|
96
|
+
ports: [].toString(),
|
|
97
|
+
fs: destFolder,
|
|
98
|
+
browserWSEndpoint: this.browser.wsEndpoint(),
|
|
99
|
+
});
|
|
100
|
+
const evaluation = `
|
|
101
|
+
console.log("importing ${dest}.mjs");
|
|
102
|
+
import('${dest}.mjs').then(async (x) => {
|
|
103
|
+
console.log("imported", x.default);
|
|
104
|
+
})`;
|
|
105
|
+
const fileStreams2 = [];
|
|
106
|
+
const doneFileStream2 = [];
|
|
107
|
+
return new Promise((res, rej) => {
|
|
108
|
+
this.browser
|
|
109
|
+
.newPage()
|
|
110
|
+
.then((page) => {
|
|
111
|
+
page.on("console", (msg) => {
|
|
112
|
+
console.log("web > ", msg.args(), msg.text());
|
|
113
|
+
// for (let i = 0; i < msg._args.length; ++i)
|
|
114
|
+
// console.log(`${i}: ${msg._args[i]}`);
|
|
115
|
+
});
|
|
116
|
+
page.exposeFunction("custom-screenshot", async (ssOpts, testName) => {
|
|
117
|
+
console.log("main.ts browser custom-screenshot", testName);
|
|
118
|
+
const p = ssOpts.path;
|
|
119
|
+
const dir = path.dirname(p);
|
|
120
|
+
fs.mkdirSync(dir, {
|
|
121
|
+
recursive: true,
|
|
122
|
+
});
|
|
123
|
+
files[testName].add(ssOpts.path);
|
|
124
|
+
const sPromise = page.screenshot(Object.assign(Object.assign({}, ssOpts), { path: p }));
|
|
125
|
+
if (!screenshots[testName]) {
|
|
126
|
+
screenshots[testName] = [];
|
|
127
|
+
}
|
|
128
|
+
screenshots[testName].push(sPromise);
|
|
129
|
+
// sPromise.then(())
|
|
130
|
+
await sPromise;
|
|
131
|
+
return sPromise;
|
|
132
|
+
// page.evaluate(`window["screenshot done"]`);
|
|
133
|
+
});
|
|
134
|
+
page.exposeFunction("writeFileSync", (fp, contents, testName) => {
|
|
135
|
+
const dir = path.dirname(fp);
|
|
136
|
+
fs.mkdirSync(dir, {
|
|
137
|
+
recursive: true,
|
|
138
|
+
});
|
|
139
|
+
const p = new Promise(async (res, rej) => {
|
|
140
|
+
fs.writeFileSync(fp, contents);
|
|
141
|
+
res(fp);
|
|
142
|
+
});
|
|
143
|
+
doneFileStream2.push(p);
|
|
144
|
+
if (!files[testName]) {
|
|
145
|
+
files[testName] = new Set();
|
|
146
|
+
}
|
|
147
|
+
files[testName].add(fp);
|
|
148
|
+
return p;
|
|
149
|
+
});
|
|
150
|
+
page.exposeFunction("existsSync", (fp, contents) => {
|
|
151
|
+
return fs.existsSync(fp);
|
|
152
|
+
});
|
|
153
|
+
page.exposeFunction("mkdirSync", (fp) => {
|
|
154
|
+
if (!fs.existsSync(fp)) {
|
|
155
|
+
return fs.mkdirSync(fp, {
|
|
156
|
+
recursive: true,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
return false;
|
|
160
|
+
});
|
|
161
|
+
page.exposeFunction("createWriteStream", (fp, testName) => {
|
|
162
|
+
const f = fs.createWriteStream(fp);
|
|
163
|
+
if (!files[testName]) {
|
|
164
|
+
files[testName] = new Set();
|
|
165
|
+
}
|
|
166
|
+
files[testName].add(fp);
|
|
167
|
+
const p = new Promise((res, rej) => {
|
|
168
|
+
res(fp);
|
|
169
|
+
});
|
|
170
|
+
doneFileStream2.push(p);
|
|
171
|
+
f.on("close", async () => {
|
|
172
|
+
await p;
|
|
173
|
+
});
|
|
174
|
+
fileStreams2.push(f);
|
|
175
|
+
return Object.assign(Object.assign({}, JSON.parse(JSON.stringify(f))), { uid: fileStreams2.length - 1 });
|
|
176
|
+
});
|
|
177
|
+
page.exposeFunction("write", async (uid, contents) => {
|
|
178
|
+
return fileStreams2[uid].write(contents);
|
|
179
|
+
});
|
|
180
|
+
page.exposeFunction("end", async (uid) => {
|
|
181
|
+
return fileStreams2[uid].end();
|
|
182
|
+
});
|
|
183
|
+
page.exposeFunction("customclose", (p, testName) => {
|
|
184
|
+
fs.writeFileSync(p + "/manifest.json", JSON.stringify(Array.from(files[testName])));
|
|
185
|
+
delete files[testName];
|
|
186
|
+
Promise.all(screenshots[testName] || []).then(() => {
|
|
187
|
+
delete screenshots[testName];
|
|
188
|
+
page.close();
|
|
189
|
+
});
|
|
190
|
+
// globalThis["writeFileSync"](
|
|
191
|
+
// p + "/manifest.json",
|
|
192
|
+
// // files.entries()
|
|
193
|
+
// JSON.stringify(Array.from(files[testName]))
|
|
194
|
+
// );
|
|
195
|
+
// console.log("closing doneFileStream2", doneFileStream2);
|
|
196
|
+
// console.log("closing doneFileStream2", doneFileStream2);
|
|
197
|
+
// Promise.all([...doneFileStream2, ...screenshots2]).then(() => {
|
|
198
|
+
// page.close();
|
|
199
|
+
// });
|
|
200
|
+
// Promise.all(screenshots).then(() => {
|
|
201
|
+
// page.close();
|
|
202
|
+
// });
|
|
203
|
+
// setTimeout(() => {
|
|
204
|
+
// console.log("Delayed for 1 second.");
|
|
205
|
+
// page.close();
|
|
206
|
+
// }, 5000);
|
|
207
|
+
// return page.close();
|
|
208
|
+
});
|
|
209
|
+
return page;
|
|
210
|
+
})
|
|
211
|
+
.then(async (page) => {
|
|
212
|
+
page.on("console", (log) => console.debug(`Log from client: [${log.text()}] `));
|
|
213
|
+
await page.goto(`file://${`${dest}.html`}`, {});
|
|
214
|
+
res(page);
|
|
215
|
+
// page.evaluate(evaluation).finally(() => {
|
|
216
|
+
// console.log("evaluation failed.", dest);
|
|
217
|
+
// });
|
|
218
|
+
// return page;
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
};
|
|
222
|
+
// launchNodeSideCar = async (src: string, dest: string) => {};
|
|
223
|
+
this.launchNodeSideCar = async (src, dest, testConfig) => {
|
|
224
|
+
const d = dest + ".mjs";
|
|
225
|
+
console.log("launchNodeSideCar", src, dest, d);
|
|
226
|
+
const destFolder = dest.replace(".mjs", "");
|
|
227
|
+
let argz = "";
|
|
228
|
+
// const testConfig = this.configs.tests.find((t) => {
|
|
229
|
+
// return t[0] === src;
|
|
230
|
+
// });
|
|
231
|
+
// if (!testConfig) {
|
|
232
|
+
// console.error("missing test config");
|
|
233
|
+
// process.exit(-1);
|
|
234
|
+
// }
|
|
235
|
+
const testConfigResource = testConfig[2];
|
|
236
|
+
let portsToUse = [];
|
|
237
|
+
if (testConfigResource.ports === 0) {
|
|
238
|
+
argz = JSON.stringify({
|
|
239
|
+
scheduled: true,
|
|
240
|
+
name: src,
|
|
241
|
+
ports: portsToUse,
|
|
242
|
+
fs: destFolder,
|
|
243
|
+
browserWSEndpoint: this.browser.wsEndpoint(),
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
else if (testConfigResource.ports > 0) {
|
|
247
|
+
const openPorts = Object.entries(this.ports).filter(([portnumber, portopen]) => portopen);
|
|
248
|
+
console.log("openPorts", openPorts);
|
|
249
|
+
if (openPorts.length >= testConfigResource.ports) {
|
|
250
|
+
for (let i = 0; i < testConfigResource.ports; i++) {
|
|
251
|
+
portsToUse.push(openPorts[i][0]);
|
|
252
|
+
this.ports[openPorts[i][0]] = false; // port is now closed
|
|
253
|
+
}
|
|
254
|
+
argz = JSON.stringify({
|
|
255
|
+
scheduled: true,
|
|
256
|
+
name: src,
|
|
257
|
+
// ports: [3333],
|
|
258
|
+
ports: portsToUse,
|
|
259
|
+
fs: ".",
|
|
260
|
+
browserWSEndpoint: this.browser.wsEndpoint(),
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
this.queue.push(src);
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
console.error("negative port makes no sense", src);
|
|
270
|
+
process.exit(-1);
|
|
271
|
+
}
|
|
272
|
+
const builtfile = dest + ".mjs";
|
|
273
|
+
// console.log(
|
|
274
|
+
// "node builtfile",
|
|
275
|
+
// (await import(`${builtfile}?cacheBust=${Date.now()}`)).default
|
|
276
|
+
// );
|
|
277
|
+
this.server[builtfile] = await import(`${builtfile}?cacheBust=${Date.now()}`).then((module) => {
|
|
278
|
+
return module.default.then((defaultModule) => {
|
|
279
|
+
console.log("defaultModule", defaultModule);
|
|
280
|
+
const s = new defaultModule();
|
|
281
|
+
s.receiveTestResourceConfig(argz);
|
|
282
|
+
// Object.create(defaultModule);
|
|
283
|
+
// defaultModule
|
|
284
|
+
// .receiveTestResourceConfig(argz)
|
|
285
|
+
// .then((x) => {
|
|
286
|
+
// console.log("then", x);
|
|
287
|
+
// return x;
|
|
288
|
+
// })
|
|
289
|
+
// .catch((e) => {
|
|
290
|
+
// console.log("catch", e);
|
|
291
|
+
// });
|
|
292
|
+
});
|
|
293
|
+
});
|
|
294
|
+
console.log("portsToUse", portsToUse);
|
|
73
295
|
for (let i = 0; i <= portsToUse.length; i++) {
|
|
74
|
-
|
|
296
|
+
if (portsToUse[i]) {
|
|
297
|
+
this.ports[portsToUse[i]] = "true"; //port is open again
|
|
298
|
+
}
|
|
75
299
|
}
|
|
76
300
|
};
|
|
77
|
-
this.launchWeb = (t, dest) => {
|
|
301
|
+
this.launchWeb = (t, dest, sidecars) => {
|
|
78
302
|
console.log("launchWeb", t, dest);
|
|
303
|
+
sidecars.map((sidecar) => {
|
|
304
|
+
if (sidecar[1] === "node") {
|
|
305
|
+
return this.launchNodeSideCar(sidecar[0], destinationOfRuntime(sidecar[0], "node", this.configs), sidecar);
|
|
306
|
+
}
|
|
307
|
+
});
|
|
79
308
|
const destFolder = dest.replace(".mjs", "");
|
|
80
309
|
const webArgz = JSON.stringify({
|
|
81
310
|
name: dest,
|
|
@@ -83,8 +312,10 @@ export class PM_Main extends PM {
|
|
|
83
312
|
fs: destFolder,
|
|
84
313
|
browserWSEndpoint: this.browser.wsEndpoint(),
|
|
85
314
|
});
|
|
86
|
-
const evaluation = `
|
|
87
|
-
|
|
315
|
+
const evaluation = `
|
|
316
|
+
console.log("importing ${dest}.mjs");
|
|
317
|
+
import('${dest}.mjs').then(async (x) => {
|
|
318
|
+
console.log("imported", x.default);
|
|
88
319
|
try {
|
|
89
320
|
await (await x.default).receiveTestResourceConfig(${webArgz})
|
|
90
321
|
} catch (e) {
|
|
@@ -92,18 +323,25 @@ export class PM_Main extends PM {
|
|
|
92
323
|
}
|
|
93
324
|
})`;
|
|
94
325
|
const fileStreams2 = [];
|
|
95
|
-
// const screenshots2: Promise<any>[] = [];
|
|
96
326
|
const doneFileStream2 = [];
|
|
97
327
|
this.browser
|
|
98
328
|
.newPage()
|
|
99
329
|
.then((page) => {
|
|
100
|
-
page.
|
|
330
|
+
page.on("console", (msg) => {
|
|
331
|
+
console.log("web > ", msg.args(), msg.text());
|
|
332
|
+
// for (let i = 0; i < msg._args.length; ++i)
|
|
333
|
+
// console.log(`${i}: ${msg._args[i]}`);
|
|
334
|
+
});
|
|
335
|
+
page.exposeFunction("customScreenShot", async (ssOpts, testName) => {
|
|
101
336
|
console.log("main.ts browser custom-screenshot", testName);
|
|
102
337
|
const p = ssOpts.path;
|
|
103
338
|
const dir = path.dirname(p);
|
|
104
339
|
fs.mkdirSync(dir, {
|
|
105
340
|
recursive: true,
|
|
106
341
|
});
|
|
342
|
+
if (!files[testName]) {
|
|
343
|
+
files[testName] = new Set();
|
|
344
|
+
}
|
|
107
345
|
files[testName].add(ssOpts.path);
|
|
108
346
|
const sPromise = page.screenshot(Object.assign(Object.assign({}, ssOpts), { path: p }));
|
|
109
347
|
if (!screenshots[testName]) {
|
|
@@ -165,6 +403,7 @@ export class PM_Main extends PM {
|
|
|
165
403
|
return fileStreams2[uid].end();
|
|
166
404
|
});
|
|
167
405
|
page.exposeFunction("customclose", (p, testName) => {
|
|
406
|
+
console.log("\t closing", p);
|
|
168
407
|
fs.writeFileSync(p + "/manifest.json", JSON.stringify(Array.from(files[testName])));
|
|
169
408
|
delete files[testName];
|
|
170
409
|
Promise.all(screenshots[testName] || []).then(() => {
|
|
@@ -193,6 +432,7 @@ export class PM_Main extends PM {
|
|
|
193
432
|
return page;
|
|
194
433
|
})
|
|
195
434
|
.then(async (page) => {
|
|
435
|
+
page.on("console", (log) => console.debug(`Log from client: [${log.text()}] `));
|
|
196
436
|
await page.goto(`file://${`${dest}.html`}`, {});
|
|
197
437
|
page.evaluate(evaluation).finally(() => {
|
|
198
438
|
console.log("evaluation failed.", dest);
|
|
@@ -215,6 +455,7 @@ export class PM_Main extends PM {
|
|
|
215
455
|
return false;
|
|
216
456
|
};
|
|
217
457
|
globalThis["writeFileSync"] = (filepath, contents, testName) => {
|
|
458
|
+
console.log("globalThis-writeFileSync", filepath);
|
|
218
459
|
// Create directories if they don't exist
|
|
219
460
|
const dir = path.dirname(filepath.split("/").slice(0, -1).join("/"));
|
|
220
461
|
fs.mkdirSync(dir, {
|
|
@@ -242,6 +483,33 @@ export class PM_Main extends PM {
|
|
|
242
483
|
globalThis["end"] = (uid) => {
|
|
243
484
|
fileStreams3[uid].end();
|
|
244
485
|
};
|
|
486
|
+
globalThis["customScreenShot"] = async (opts, page) => {
|
|
487
|
+
// // fileStreams3[uid].write(contents);
|
|
488
|
+
// // console.log("asd", opts.path.split("/").slice(0, -1).join("/"));
|
|
489
|
+
// // const dir = path.dirname(opts.path.split("/").slice(0, -1).join("/"));
|
|
490
|
+
// // console.log("dir", dir);
|
|
491
|
+
// fs.mkdirSync(opts.path.split("/").slice(0, -1).join("/"), {
|
|
492
|
+
// recursive: true,
|
|
493
|
+
// });
|
|
494
|
+
// return page.screenshot(opts);
|
|
495
|
+
console.log("main.ts node custom-screenshot", page);
|
|
496
|
+
const p = opts.path;
|
|
497
|
+
const dir = path.dirname(p);
|
|
498
|
+
fs.mkdirSync(dir, {
|
|
499
|
+
recursive: true,
|
|
500
|
+
});
|
|
501
|
+
if (!files[opts.path]) {
|
|
502
|
+
files[opts.path] = new Set();
|
|
503
|
+
}
|
|
504
|
+
files[opts.path].add(opts.path);
|
|
505
|
+
const sPromise = page.screenshot(Object.assign(Object.assign({}, opts), { path: p }));
|
|
506
|
+
if (!screenshots[opts.path]) {
|
|
507
|
+
screenshots[opts.path] = [];
|
|
508
|
+
}
|
|
509
|
+
screenshots[opts.path].push(sPromise);
|
|
510
|
+
await sPromise;
|
|
511
|
+
return sPromise;
|
|
512
|
+
};
|
|
245
513
|
globalThis["customclose"] = (p, testName) => {
|
|
246
514
|
if (!files[testName]) {
|
|
247
515
|
files[testName] = new Set();
|
|
@@ -272,6 +540,9 @@ export class PM_Main extends PM {
|
|
|
272
540
|
// // return page.close();
|
|
273
541
|
// });
|
|
274
542
|
}
|
|
543
|
+
customScreenShot(opts) {
|
|
544
|
+
throw new Error("Method not implemented.");
|
|
545
|
+
}
|
|
275
546
|
async startPuppeteer(options, destfolder) {
|
|
276
547
|
this.browser = await puppeteer.launch(options);
|
|
277
548
|
return this.browser;
|
package/dist/module/PM/node.js
CHANGED
|
@@ -9,6 +9,9 @@ export class PM_Node extends PM {
|
|
|
9
9
|
this.server = {};
|
|
10
10
|
this.testResourceConfiguration = t;
|
|
11
11
|
}
|
|
12
|
+
customScreenShot(opts, page) {
|
|
13
|
+
return globalThis["customScreenShot"](opts, page);
|
|
14
|
+
}
|
|
12
15
|
existsSync(destFolder) {
|
|
13
16
|
return globalThis["existsSync"](this.testResourceConfiguration.fs + "/" + destFolder);
|
|
14
17
|
}
|
|
@@ -19,6 +22,7 @@ export class PM_Node extends PM {
|
|
|
19
22
|
return globalThis["write"](writeObject.uid, contents);
|
|
20
23
|
}
|
|
21
24
|
writeFileSync(filepath, contents) {
|
|
25
|
+
console.log("pm_node-writeFileSync", this.testResourceConfiguration);
|
|
22
26
|
return globalThis["writeFileSync"](this.testResourceConfiguration.fs + "/" + filepath, contents, this.testResourceConfiguration.name);
|
|
23
27
|
}
|
|
24
28
|
createWriteStream(filepath) {
|
package/dist/module/PM/web.js
CHANGED
package/dist/module/Project.js
CHANGED
|
@@ -70,6 +70,9 @@ export class ITProject {
|
|
|
70
70
|
.then((x) => fs.writeFileSync(htmlFilePath, webHtmlFrame(jsfilePath, htmlFilePath)));
|
|
71
71
|
})));
|
|
72
72
|
const [nodeEntryPoints, webEntryPoints] = getRunnables(this.config.tests);
|
|
73
|
+
console.log(`this.getSecondaryEndpointsPoints("web")`, this.getSecondaryEndpointsPoints("web"));
|
|
74
|
+
// console.log("nodeEntryPoints", nodeEntryPoints);
|
|
75
|
+
// console.log("webEntryPoints", webEntryPoints);
|
|
73
76
|
// nodeEntryPoints.forEach((nep) => {
|
|
74
77
|
// const f = `${process.cwd()}/${nep}`;
|
|
75
78
|
// console.log("nep", f);
|
|
@@ -147,11 +150,12 @@ export class ITProject {
|
|
|
147
150
|
getSecondaryEndpointsPoints(runtime) {
|
|
148
151
|
const meta = (ts, st) => {
|
|
149
152
|
ts.forEach((t) => {
|
|
153
|
+
console.log("getSecondaryEndpointsPoints", t);
|
|
150
154
|
if (t[1] === runtime) {
|
|
151
155
|
st.add(t[0]);
|
|
152
156
|
}
|
|
153
|
-
if (Array.isArray(t[
|
|
154
|
-
meta(t[
|
|
157
|
+
if (Array.isArray(t[3])) {
|
|
158
|
+
meta(t[3], st);
|
|
155
159
|
}
|
|
156
160
|
});
|
|
157
161
|
return st;
|