testeranto 0.90.0 → 0.100.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/bundle.js +4 -7
- package/dist/common/src/Node.js +5 -3
- package/dist/common/src/PM/main.js +254 -126
- package/dist/common/src/PM/node.js +20 -5
- package/dist/common/src/PM/web.js +19 -4
- package/dist/common/src/SubPackages/puppeteer.js +1 -1
- package/dist/common/src/SubPackages/react/jsx/index.js +14 -6
- package/dist/common/src/SubPackages/react/jsx/node.js +2 -2
- package/dist/common/src/SubPackages/react-dom/component/web.js +13 -39
- package/dist/common/src/SubPackages/react-test-renderer/component/interface.js +2 -10
- package/dist/common/src/Web.js +25 -21
- package/dist/common/src/cli.js +439 -0
- package/dist/common/src/cli2.js +144 -0
- package/dist/common/src/esbuildConfigs/inputFilesPlugin.js +18 -8
- package/dist/common/src/esbuildConfigs/node.js +1 -4
- package/dist/common/src/esbuildConfigs/web.js +1 -1
- package/dist/common/src/lib/abstractBase.js +31 -263
- package/dist/common/src/lib/basebuilder.js +1 -11
- package/dist/common/src/lib/classBuilder.js +1 -1
- package/dist/common/src/lib/core.js +8 -28
- package/dist/common/src/lib/types.js +1 -0
- package/dist/common/tsconfig.common.tsbuildinfo +1 -1
- package/dist/module/src/Node.js +5 -3
- package/dist/module/src/PM/main.js +254 -126
- package/dist/module/src/PM/node.js +20 -5
- package/dist/module/src/PM/web.js +19 -4
- package/dist/module/src/SubPackages/puppeteer.js +1 -1
- package/dist/module/src/SubPackages/react/jsx/index.js +14 -6
- package/dist/module/src/SubPackages/react/jsx/node.js +2 -2
- package/dist/module/src/SubPackages/react-dom/component/web.js +13 -39
- package/dist/module/src/SubPackages/react-test-renderer/component/interface.js +2 -10
- package/dist/module/src/Web.js +25 -21
- package/dist/module/src/cli.js +411 -0
- package/dist/module/src/cli2.js +116 -0
- package/dist/module/src/esbuildConfigs/inputFilesPlugin.js +18 -8
- package/dist/module/src/esbuildConfigs/node.js +1 -4
- package/dist/module/src/esbuildConfigs/web.js +1 -1
- package/dist/module/src/lib/abstractBase.js +31 -263
- package/dist/module/src/lib/basebuilder.js +1 -11
- package/dist/module/src/lib/classBuilder.js +1 -1
- package/dist/module/src/lib/core.js +8 -28
- package/dist/module/src/lib/types.js +1 -0
- package/dist/module/tsconfig.module.tsbuildinfo +1 -1
- package/dist/prebuild/cli.mjs +1491 -0
- package/dist/prebuild/{run-tests.mjs → cli2.mjs} +223 -212
- package/dist/types/src/Node.d.ts +6 -3
- package/dist/types/src/PM/index.d.ts +10 -2
- package/dist/types/src/PM/main.d.ts +14 -7
- package/dist/types/src/PM/node.d.ts +9 -2
- package/dist/types/src/PM/web.d.ts +9 -3
- package/dist/types/src/SubPackages/puppeteer.d.ts +1 -1
- package/dist/types/src/SubPackages/react/component/node.d.ts +1 -1
- package/dist/types/src/SubPackages/react/component/web.d.ts +1 -1
- package/dist/types/src/SubPackages/react/jsx/node.d.ts +3 -3
- package/dist/types/src/SubPackages/react/jsx/web.d.ts +2 -2
- package/dist/types/src/SubPackages/react-dom/component/node.d.ts +2 -2
- package/dist/types/src/SubPackages/react-dom/component/web.d.ts +1 -1
- package/dist/types/src/SubPackages/react-dom/jsx/node.d.ts +1 -1
- package/dist/types/src/SubPackages/react-dom/jsx/web.d.ts +2 -2
- package/dist/types/src/SubPackages/react-test-renderer/MemoExoticComponent/node.d.ts +2 -2
- package/dist/types/src/SubPackages/react-test-renderer/component/interface.d.ts +1 -1
- package/dist/types/src/SubPackages/react-test-renderer/component/node.d.ts +2 -2
- package/dist/types/src/SubPackages/react-test-renderer/component/web.d.ts +2 -2
- package/dist/types/src/SubPackages/react-test-renderer/fc/node.d.ts +2 -2
- package/dist/types/src/SubPackages/react-test-renderer/fc/web.d.ts +2 -2
- package/dist/types/src/SubPackages/react-test-renderer/jsx/node.d.ts +3 -2
- package/dist/types/src/SubPackages/react-test-renderer/jsx/web.d.ts +2 -2
- package/dist/types/src/SubPackages/react-test-renderer/jsx-promised/node.d.ts +2 -2
- package/dist/types/src/SubPackages/react-test-renderer/jsx-promised/web.d.ts +2 -2
- package/dist/types/src/Types.d.ts +60 -21
- package/dist/types/src/Web.d.ts +3 -3
- package/dist/types/src/lib/abstractBase.d.ts +6 -2
- package/dist/types/src/lib/core.d.ts +3 -3
- package/dist/types/src/lib/index.d.ts +1 -1
- package/dist/types/src/lib/types.d.ts +6 -30
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +23 -20
- package/src/Node.ts +6 -3
- package/src/PM/index.ts +12 -8
- package/src/PM/main.ts +331 -165
- package/src/PM/node.ts +42 -7
- package/src/PM/web.ts +33 -5
- package/src/SubPackages/puppeteer.ts +1 -1
- package/src/SubPackages/react/jsx/index.ts +15 -7
- package/src/SubPackages/react/jsx/node.ts +18 -6
- package/src/SubPackages/react-dom/component/web.ts +28 -51
- package/src/SubPackages/react-test-renderer/component/interface.ts +4 -11
- package/src/SubPackages/react-test-renderer/jsx/node.ts +16 -1
- package/src/Types.ts +362 -114
- package/src/Web.ts +45 -23
- package/src/cli.ts +535 -0
- package/src/cli2.ts +157 -0
- package/src/esbuildConfigs/inputFilesPlugin.ts +27 -9
- package/src/esbuildConfigs/node.ts +4 -7
- package/src/esbuildConfigs/web.ts +4 -3
- package/src/lib/abstractBase.ts +84 -291
- package/src/lib/basebuilder.ts +1 -12
- package/src/lib/classBuilder.ts +2 -1
- package/src/lib/core.ts +17 -29
- package/src/lib/types.ts +5 -177
- package/dist/common/src/Aider.js +0 -143
- package/dist/common/src/Project.js +0 -225
- package/dist/common/src/Puppeteer.js +0 -113
- package/dist/common/src/build-tests.js +0 -39
- package/dist/common/src/esbuildConfigs/features.js +0 -14
- package/dist/common/src/esbuildConfigs/report.js +0 -14
- package/dist/common/src/esbuildConfigs/tests.js +0 -13
- package/dist/common/src/run-tests.js +0 -39
- package/dist/module/src/Aider.js +0 -136
- package/dist/module/src/Project.js +0 -218
- package/dist/module/src/Puppeteer.js +0 -108
- package/dist/module/src/build-tests.js +0 -11
- package/dist/module/src/esbuildConfigs/features.js +0 -12
- package/dist/module/src/esbuildConfigs/report.js +0 -14
- package/dist/module/src/esbuildConfigs/tests.js +0 -11
- package/dist/module/src/run-tests.js +0 -11
- package/dist/prebuild/build-tests.mjs +0 -552
- package/dist/types/src/Aider.d.ts +0 -1
- package/dist/types/src/Project.d.ts +0 -12
- package/dist/types/src/Puppeteer.d.ts +0 -2
- package/dist/types/src/esbuildConfigs/features.d.ts +0 -4
- package/dist/types/src/esbuildConfigs/report.d.ts +0 -0
- package/dist/types/src/esbuildConfigs/tests.d.ts +0 -4
- package/src/Aider.ts +0 -168
- package/src/Project.ts +0 -291
- package/src/Puppeteer.ts +0 -145
- package/src/build-tests.ts +0 -12
- package/src/esbuildConfigs/features.ts +0 -17
- package/src/esbuildConfigs/report.ts +0 -15
- package/src/esbuildConfigs/tests.ts +0 -14
- package/src/run-tests.ts +0 -12
- /package/dist/types/src/{build-tests.d.ts → cli.d.ts} +0 -0
- /package/dist/types/src/{run-tests.d.ts → cli2.d.ts} +0 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { watch } from "fs";
|
|
2
|
+
import { PM_Main } from "./PM/main";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import crypto from "node:crypto";
|
|
5
|
+
import fs from "fs";
|
|
6
|
+
const fileHashes = {};
|
|
7
|
+
async function fileHash(filePath, algorithm = "md5") {
|
|
8
|
+
return new Promise((resolve, reject) => {
|
|
9
|
+
const hash = crypto.createHash(algorithm);
|
|
10
|
+
const fileStream = fs.createReadStream(filePath);
|
|
11
|
+
fileStream.on("data", (data) => {
|
|
12
|
+
hash.update(data);
|
|
13
|
+
});
|
|
14
|
+
fileStream.on("end", () => {
|
|
15
|
+
const fileHash = hash.digest("hex");
|
|
16
|
+
resolve(fileHash);
|
|
17
|
+
});
|
|
18
|
+
fileStream.on("error", (error) => {
|
|
19
|
+
reject(`Error reading file: ${error.message}`);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
const getRunnables = (tests, payload = {
|
|
24
|
+
nodeEntryPoints: {},
|
|
25
|
+
webEntryPoints: {},
|
|
26
|
+
}) => {
|
|
27
|
+
return tests.reduce((pt, cv, cndx, cry) => {
|
|
28
|
+
if (cv[1] === "node") {
|
|
29
|
+
pt.nodeEntryPoints[cv[0]] = path.resolve(`./docs/node/${cv[0].split(".").slice(0, -1).concat("mjs").join(".")}`);
|
|
30
|
+
}
|
|
31
|
+
else if (cv[1] === "web") {
|
|
32
|
+
pt.webEntryPoints[cv[0]] = path.resolve(`./docs/web/${cv[0].split(".").slice(0, -1).concat("mjs").join(".")}`);
|
|
33
|
+
}
|
|
34
|
+
if (cv[3].length) {
|
|
35
|
+
getRunnables(cv[3], payload);
|
|
36
|
+
}
|
|
37
|
+
return pt;
|
|
38
|
+
}, payload);
|
|
39
|
+
};
|
|
40
|
+
import(process.cwd() + "/" + process.argv[2]).then(async (module) => {
|
|
41
|
+
const rawConfig = module.default;
|
|
42
|
+
const config = Object.assign(Object.assign({}, rawConfig), { buildDir: process.cwd() + "/" + rawConfig.outdir });
|
|
43
|
+
let pm = new PM_Main(config);
|
|
44
|
+
await pm.startPuppeteer({
|
|
45
|
+
slowMo: 1,
|
|
46
|
+
// timeout: 1,
|
|
47
|
+
waitForInitialPage: false,
|
|
48
|
+
executablePath:
|
|
49
|
+
// process.env.CHROMIUM_PATH || "/opt/homebrew/bin/chromium",
|
|
50
|
+
"/opt/homebrew/bin/chromium",
|
|
51
|
+
headless: true,
|
|
52
|
+
dumpio: true,
|
|
53
|
+
// timeout: 0,
|
|
54
|
+
devtools: true,
|
|
55
|
+
args: [
|
|
56
|
+
"--auto-open-devtools-for-tabs",
|
|
57
|
+
`--remote-debugging-port=3234`,
|
|
58
|
+
// "--disable-features=IsolateOrigins,site-per-process",
|
|
59
|
+
"--disable-site-isolation-trials",
|
|
60
|
+
"--allow-insecure-localhost",
|
|
61
|
+
"--allow-file-access-from-files",
|
|
62
|
+
"--allow-running-insecure-content",
|
|
63
|
+
"--disable-dev-shm-usage",
|
|
64
|
+
"--disable-extensions",
|
|
65
|
+
"--disable-gpu",
|
|
66
|
+
"--disable-setuid-sandbox",
|
|
67
|
+
"--disable-site-isolation-trials",
|
|
68
|
+
"--disable-web-security",
|
|
69
|
+
"--no-first-run",
|
|
70
|
+
"--no-sandbox",
|
|
71
|
+
"--no-startup-window",
|
|
72
|
+
// "--no-zygote",
|
|
73
|
+
"--reduce-security-for-testing",
|
|
74
|
+
"--remote-allow-origins=*",
|
|
75
|
+
"--unsafely-treat-insecure-origin-as-secure=*",
|
|
76
|
+
// "--disable-features=IsolateOrigins",
|
|
77
|
+
// "--remote-allow-origins=ws://localhost:3234",
|
|
78
|
+
// "--single-process",
|
|
79
|
+
// "--unsafely-treat-insecure-origin-as-secure",
|
|
80
|
+
// "--unsafely-treat-insecure-origin-as-secure=ws://192.168.0.101:3234",
|
|
81
|
+
// "--disk-cache-dir=/dev/null",
|
|
82
|
+
// "--disk-cache-size=1",
|
|
83
|
+
// "--start-maximized",
|
|
84
|
+
],
|
|
85
|
+
}, ".");
|
|
86
|
+
const { nodeEntryPoints, webEntryPoints } = getRunnables(config.tests);
|
|
87
|
+
Object.entries(nodeEntryPoints).forEach(([k, outputFile]) => {
|
|
88
|
+
console.log("watching and running", outputFile);
|
|
89
|
+
pm.launchNode(k, outputFile);
|
|
90
|
+
try {
|
|
91
|
+
watch(outputFile, async (e, filename) => {
|
|
92
|
+
const hash = await fileHash(outputFile);
|
|
93
|
+
if (fileHashes[k] !== hash) {
|
|
94
|
+
fileHashes[k] = hash;
|
|
95
|
+
console.log(`< ${e} ${filename} ${hash}`);
|
|
96
|
+
pm.launchNode(k, outputFile);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
catch (e) {
|
|
101
|
+
console.error(e);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
Object.entries(webEntryPoints).forEach(([k, outputFile]) => {
|
|
105
|
+
console.log("watching and running", outputFile);
|
|
106
|
+
pm.launchWeb(k, outputFile);
|
|
107
|
+
watch(outputFile, async (e, filename) => {
|
|
108
|
+
const hash = await fileHash(outputFile);
|
|
109
|
+
console.log(`< ${e} ${filename} ${hash}`);
|
|
110
|
+
if (fileHashes[k] !== hash) {
|
|
111
|
+
fileHashes[k] = hash;
|
|
112
|
+
pm.launchWeb(k, outputFile);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
});
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
|
+
import { spawn } from "child_process";
|
|
3
4
|
const otherInputs = {};
|
|
4
5
|
const register = (entrypoint, sources) => {
|
|
5
|
-
console.log("register", entrypoint, sources);
|
|
6
6
|
if (!otherInputs[entrypoint]) {
|
|
7
7
|
otherInputs[entrypoint] = new Set();
|
|
8
8
|
}
|
|
9
9
|
sources.forEach((s) => otherInputs[entrypoint].add(s));
|
|
10
10
|
};
|
|
11
11
|
function tree(meta, key) {
|
|
12
|
-
console.log("searching metafile for", key);
|
|
13
12
|
const outputKey = Object.keys(meta.outputs).find((k) => {
|
|
14
13
|
return meta.outputs[k].entryPoint === key;
|
|
15
14
|
});
|
|
@@ -49,6 +48,7 @@ export default (platform, entryPoints) => {
|
|
|
49
48
|
})
|
|
50
49
|
.flat();
|
|
51
50
|
const typeErrorFiles = addableFiles.map((t) => `docs/types/${t}.type_errors.txt`);
|
|
51
|
+
const lintPath = path.join("./docs/", platform, entryPoint.split(".").slice(0, -1).join("."), `lint_errors.txt`);
|
|
52
52
|
fs.writeFileSync(promptPath, `
|
|
53
53
|
${addableFiles
|
|
54
54
|
.map((x) => {
|
|
@@ -58,22 +58,32 @@ ${addableFiles
|
|
|
58
58
|
|
|
59
59
|
${typeErrorFiles
|
|
60
60
|
.map((x) => {
|
|
61
|
-
// const f = `docs/types/${x}.type_errors.txt`;
|
|
62
61
|
return `/read ${x}`;
|
|
63
|
-
// if (fs.existsSync(f)) {
|
|
64
|
-
// return `/read ${f}`;
|
|
65
|
-
// }
|
|
66
62
|
})
|
|
67
63
|
.join("\n")}
|
|
68
|
-
|
|
64
|
+
|
|
65
|
+
/read ${lintPath}
|
|
69
66
|
/read ${testPaths}
|
|
70
67
|
/read ${stdoutPath}
|
|
71
68
|
/read ${stderrPath}
|
|
72
69
|
|
|
73
70
|
/load ${featuresPath}
|
|
74
71
|
|
|
75
|
-
/code Fix the failing tests described in ${testPaths}. Correct any type signature errors described in the files [${typeErrorFiles.join(", ")}]. Implement any method which throws "Function not implemented."
|
|
72
|
+
/code Fix the failing tests described in ${testPaths}. Correct any type signature errors described in the files [${typeErrorFiles.join(", ")}]. Implement any method which throws "Function not implemented. Resolve the lint errors described in ${lintPath}"
|
|
76
73
|
`);
|
|
74
|
+
const logContent = [];
|
|
75
|
+
const tsc = spawn("eslint", addableFiles);
|
|
76
|
+
tsc.stdout.on("data", (data) => {
|
|
77
|
+
const lines = data.toString().split("\n");
|
|
78
|
+
logContent.push(...lines);
|
|
79
|
+
});
|
|
80
|
+
tsc.stderr.on("data", (data) => {
|
|
81
|
+
console.error(`stderr: ${data}`);
|
|
82
|
+
process.exit(-1);
|
|
83
|
+
});
|
|
84
|
+
tsc.on("close", (code) => {
|
|
85
|
+
fs.writeFileSync(lintPath, logContent.join("\n"));
|
|
86
|
+
});
|
|
77
87
|
}
|
|
78
88
|
});
|
|
79
89
|
}
|
|
@@ -3,8 +3,6 @@ import inputFilesPlugin from "./inputFilesPlugin.js";
|
|
|
3
3
|
import featuresPlugin from "./featuresPlugin";
|
|
4
4
|
export default (config, entryPoints) => {
|
|
5
5
|
const { inputFilesPluginFactory, register } = inputFilesPlugin("node", entryPoints);
|
|
6
|
-
// const inputFilesPluginFactory = inputFilesPlugin("node", entryPoints);
|
|
7
|
-
// const register = (x) => x;
|
|
8
6
|
return Object.assign(Object.assign({}, baseEsBuildConfig(config)), { splitting: true, outdir: config.outdir + "/node",
|
|
9
7
|
// inject: [`./node_modules/testeranto/dist/cjs-shim.js`],
|
|
10
8
|
metafile: true, supported: {
|
|
@@ -22,7 +20,6 @@ export default (config, entryPoints) => {
|
|
|
22
20
|
...config.externals,
|
|
23
21
|
], entryPoints: [...entryPoints], plugins: [
|
|
24
22
|
featuresPlugin,
|
|
25
|
-
// markdownPlugin({}),
|
|
26
23
|
...(config.nodePlugins.map((p) => p(register, entryPoints)) || []),
|
|
27
24
|
inputFilesPluginFactory,
|
|
28
25
|
// inputFilesPlugin("node", entryPoints),
|
|
@@ -30,7 +27,7 @@ export default (config, entryPoints) => {
|
|
|
30
27
|
name: "rebuild-notify",
|
|
31
28
|
setup(build) {
|
|
32
29
|
build.onEnd((result) => {
|
|
33
|
-
console.log(
|
|
30
|
+
console.log(`> node build ended with ${result.errors.length} errors`);
|
|
34
31
|
if (result.errors.length > 0) {
|
|
35
32
|
console.log(result);
|
|
36
33
|
}
|
|
@@ -43,7 +43,7 @@ export default (config, entryPoints) => {
|
|
|
43
43
|
name: "rebuild-notify",
|
|
44
44
|
setup(build) {
|
|
45
45
|
build.onEnd((result) => {
|
|
46
|
-
console.log(
|
|
46
|
+
console.log(`> web build ended with ${result.errors.length} errors`);
|
|
47
47
|
if (result.errors.length > 0) {
|
|
48
48
|
console.log(result);
|
|
49
49
|
}
|
|
@@ -41,80 +41,29 @@ export class BaseSuite {
|
|
|
41
41
|
this.testResourceConfiguration = testResourceConfiguration;
|
|
42
42
|
tLog("test resources: ", JSON.stringify(testResourceConfiguration));
|
|
43
43
|
const suiteArtifactory = (fPath, value) => artifactory(`suite-${this.index}-${this.name}/${fPath}`, value);
|
|
44
|
-
console.log("\nSuite:", this.index, this.name);
|
|
44
|
+
// console.log("\nSuite:", this.index, this.name);
|
|
45
45
|
tLog("\nSuite:", this.index, this.name);
|
|
46
46
|
const sNdx = this.index;
|
|
47
47
|
const sName = this.name;
|
|
48
|
-
for (const [
|
|
48
|
+
for (const [gKey, g] of Object.entries(this.givens)) {
|
|
49
|
+
// console.log("gKey", gKey);
|
|
49
50
|
const beforeAllProxy = new Proxy(pm, {
|
|
50
51
|
get(target, prop, receiver) {
|
|
51
52
|
if (prop === "customScreenShot") {
|
|
52
|
-
return (opts) => target.customScreenShot(Object.assign(Object.assign({}, opts), {
|
|
53
|
+
return (opts, p) => target.customScreenShot(Object.assign(Object.assign({}, opts), {
|
|
53
54
|
// path: `${filepath}/${opts.path}`,
|
|
54
|
-
path: `suite-${sNdx}/beforeAll/${opts.path}` }));
|
|
55
|
+
path: `suite-${sNdx}/beforeAll/${opts.path}` }), p);
|
|
55
56
|
}
|
|
56
57
|
if (prop === "writeFileSync") {
|
|
57
58
|
return (fp, contents) => target[prop](`suite-${sNdx}/beforeAll/${fp}`, contents);
|
|
58
59
|
}
|
|
59
|
-
// if (prop === "browser") {
|
|
60
|
-
// return new Proxy(target[prop], {
|
|
61
|
-
// get(bTarget, bProp, bReceiver) {
|
|
62
|
-
// if (bProp === "pages") {
|
|
63
|
-
// return async () => {
|
|
64
|
-
// return bTarget.pages().then((pages) => {
|
|
65
|
-
// return pages.map((page) => {
|
|
66
|
-
// return new Proxy(page, {
|
|
67
|
-
// get(pTarget, pProp, pReciever) {
|
|
68
|
-
// if (pProp === "screenshot") {
|
|
69
|
-
// return async (x) => {
|
|
70
|
-
// return pm.customScreenShot(
|
|
71
|
-
// {
|
|
72
|
-
// ...x,
|
|
73
|
-
// path:
|
|
74
|
-
// `${testResourceConfiguration.fs}/suite-${sNdx}/beforeAll` +
|
|
75
|
-
// "/" +
|
|
76
|
-
// x.path,
|
|
77
|
-
// },
|
|
78
|
-
// page
|
|
79
|
-
// );
|
|
80
|
-
// // return await window["custom-screenshot"]({
|
|
81
|
-
// // ...x,
|
|
82
|
-
// // path:
|
|
83
|
-
// // `${testResourceConfiguration.fs}/suite-${sNdx}/afterAll` +
|
|
84
|
-
// // "/" +
|
|
85
|
-
// // x.path,
|
|
86
|
-
// // });
|
|
87
|
-
// };
|
|
88
|
-
// } else if (pProp === "mainFrame") {
|
|
89
|
-
// return () => pTarget[pProp]();
|
|
90
|
-
// } else if (pProp === "close") {
|
|
91
|
-
// return () => pTarget[pProp]();
|
|
92
|
-
// }
|
|
93
|
-
// // else if (pProp === "mainFrame") {
|
|
94
|
-
// // return () => target[pProp](...arguments);
|
|
95
|
-
// // }
|
|
96
|
-
// else {
|
|
97
|
-
// return Reflect.get(...arguments);
|
|
98
|
-
// }
|
|
99
|
-
// },
|
|
100
|
-
// });
|
|
101
|
-
// });
|
|
102
|
-
// });
|
|
103
|
-
// // return (await target.pages()).map((page) => {
|
|
104
|
-
// // return new Proxy(page, handler2);
|
|
105
|
-
// // });
|
|
106
|
-
// };
|
|
107
|
-
// }
|
|
108
|
-
// },
|
|
109
|
-
// });
|
|
110
|
-
// }
|
|
111
60
|
return Reflect.get(...arguments);
|
|
112
61
|
},
|
|
113
62
|
});
|
|
114
63
|
const subject = await this.setup(input, suiteArtifactory, testResourceConfiguration, beforeAllProxy);
|
|
115
|
-
const giver = this.givens[
|
|
64
|
+
const giver = this.givens[gKey];
|
|
116
65
|
try {
|
|
117
|
-
this.store = await giver.give(subject,
|
|
66
|
+
this.store = await giver.give(subject, gKey, testResourceConfiguration, this.assertThat, suiteArtifactory, tLog, pm, sNdx);
|
|
118
67
|
}
|
|
119
68
|
catch (e) {
|
|
120
69
|
console.error(e);
|
|
@@ -122,64 +71,6 @@ export class BaseSuite {
|
|
|
122
71
|
// return this;
|
|
123
72
|
}
|
|
124
73
|
}
|
|
125
|
-
// const afterAllProxy = new Proxy(pm, {
|
|
126
|
-
// get(target, prop, receiver) {
|
|
127
|
-
// if (prop === "writeFileSync") {
|
|
128
|
-
// return (fp, contents) =>
|
|
129
|
-
// target[prop](`suite-${sNdx}/afterAll/${fp}`, contents);
|
|
130
|
-
// }
|
|
131
|
-
// if (prop === "browser") {
|
|
132
|
-
// return new Proxy(target[prop], {
|
|
133
|
-
// get(bTarget, bProp, bReceiver) {
|
|
134
|
-
// if (bProp === "pages") {
|
|
135
|
-
// return async () => {
|
|
136
|
-
// return bTarget.pages().then((pages) => {
|
|
137
|
-
// return pages.map((page) => {
|
|
138
|
-
// return new Proxy(page, {
|
|
139
|
-
// get(pTarget, pProp, pReciever) {
|
|
140
|
-
// if (pProp === "screenshot") {
|
|
141
|
-
// return async (x) => {
|
|
142
|
-
// return pm.customScreenShot({
|
|
143
|
-
// ...x,
|
|
144
|
-
// path:
|
|
145
|
-
// `${testResourceConfiguration.fs}/suite-${sNdx}/afterAll` +
|
|
146
|
-
// "/" +
|
|
147
|
-
// x.path,
|
|
148
|
-
// });
|
|
149
|
-
// // return await window["custom-screenshot"]({
|
|
150
|
-
// // ...x,
|
|
151
|
-
// // path:
|
|
152
|
-
// // `${testResourceConfiguration.fs}/suite-${sNdx}/afterAll` +
|
|
153
|
-
// // "/" +
|
|
154
|
-
// // x.path,
|
|
155
|
-
// // });
|
|
156
|
-
// };
|
|
157
|
-
// } else if (pProp === "mainFrame") {
|
|
158
|
-
// return () => pTarget[pProp]();
|
|
159
|
-
// } else if (pProp === "close") {
|
|
160
|
-
// return () => pTarget[pProp]();
|
|
161
|
-
// }
|
|
162
|
-
// // else if (pProp === "mainFrame") {
|
|
163
|
-
// // return () => target[pProp](...arguments);
|
|
164
|
-
// // }
|
|
165
|
-
// else {
|
|
166
|
-
// return Reflect.get(...arguments);
|
|
167
|
-
// }
|
|
168
|
-
// },
|
|
169
|
-
// });
|
|
170
|
-
// });
|
|
171
|
-
// });
|
|
172
|
-
// // return (await target.pages()).map((page) => {
|
|
173
|
-
// // return new Proxy(page, handler2);
|
|
174
|
-
// // });
|
|
175
|
-
// };
|
|
176
|
-
// }
|
|
177
|
-
// },
|
|
178
|
-
// });
|
|
179
|
-
// }
|
|
180
|
-
// return Reflect.get(...arguments);
|
|
181
|
-
// },
|
|
182
|
-
// });
|
|
183
74
|
try {
|
|
184
75
|
this.afterAll(this.store, artifactory,
|
|
185
76
|
// afterAllProxy
|
|
@@ -217,7 +108,9 @@ export class BaseSuite {
|
|
|
217
108
|
}
|
|
218
109
|
}
|
|
219
110
|
export class BaseGiven {
|
|
220
|
-
constructor(name, features, whens, thens, givenCB, initialValues
|
|
111
|
+
constructor(name, features, whens, thens, givenCB, initialValues
|
|
112
|
+
// key: string
|
|
113
|
+
) {
|
|
221
114
|
this.name = name;
|
|
222
115
|
this.features = features;
|
|
223
116
|
this.whens = whens;
|
|
@@ -225,11 +118,15 @@ export class BaseGiven {
|
|
|
225
118
|
this.givenCB = givenCB;
|
|
226
119
|
this.initialValues = initialValues;
|
|
227
120
|
}
|
|
228
|
-
beforeAll(store,
|
|
121
|
+
beforeAll(store,
|
|
122
|
+
// artifactory: ITestArtifactory
|
|
123
|
+
// subject,
|
|
124
|
+
initializer, artifactory, testResource, initialValues, pm) {
|
|
229
125
|
return store;
|
|
230
126
|
}
|
|
231
127
|
toObj() {
|
|
232
128
|
return {
|
|
129
|
+
key: this.key,
|
|
233
130
|
name: this.name,
|
|
234
131
|
whens: this.whens.map((w) => w.toObj()),
|
|
235
132
|
thens: this.thens.map((t) => t.toObj()),
|
|
@@ -242,6 +139,8 @@ export class BaseGiven {
|
|
|
242
139
|
return store;
|
|
243
140
|
}
|
|
244
141
|
async give(subject, key, testResourceConfiguration, tester, artifactory, tLog, pm, suiteNdx) {
|
|
142
|
+
this.key = key;
|
|
143
|
+
tLog(`\n ${this.key}`);
|
|
245
144
|
tLog(`\n Given: ${this.name}`);
|
|
246
145
|
const givenArtifactory = (fPath, value) => artifactory(`given-${key}/${fPath}`, value);
|
|
247
146
|
try {
|
|
@@ -252,15 +151,20 @@ export class BaseGiven {
|
|
|
252
151
|
return (fp, contents) => target[prop](`suite-${suiteNdx}/given-${key}/when/beforeEach/${fp}`, contents);
|
|
253
152
|
}
|
|
254
153
|
if (prop === "customScreenShot") {
|
|
255
|
-
return (opts) => target.customScreenShot(Object.assign(Object.assign({}, opts), {
|
|
256
|
-
|
|
257
|
-
|
|
154
|
+
return (opts, p) => target.customScreenShot(Object.assign(Object.assign({}, opts), { path: `suite-${suiteNdx}/given-${key}/when/beforeEach/${opts.path}` }), p);
|
|
155
|
+
}
|
|
156
|
+
if (prop === "screencast") {
|
|
157
|
+
return (opts, p) => target.screencast(Object.assign(Object.assign({}, opts), { path: `suite-${suiteNdx}/given-${key}/when/beforeEach/${opts.path}` }), p);
|
|
258
158
|
}
|
|
259
159
|
return Reflect.get(...arguments);
|
|
260
160
|
},
|
|
261
161
|
});
|
|
262
|
-
this.
|
|
263
|
-
|
|
162
|
+
this.uberCatcher((e) => {
|
|
163
|
+
console.error(e);
|
|
164
|
+
this.error = e.error;
|
|
165
|
+
tLog(e.stack);
|
|
166
|
+
});
|
|
167
|
+
this.store = await this.givenThat(subject, testResourceConfiguration, givenArtifactory, this.givenCB, this.initialValues, beforeEachProxy);
|
|
264
168
|
for (const [whenNdx, whenStep] of this.whens.entries()) {
|
|
265
169
|
await whenStep.test(this.store, testResourceConfiguration, tLog, pm, `suite-${suiteNdx}/given-${key}/when/${whenNdx}`);
|
|
266
170
|
}
|
|
@@ -281,7 +185,7 @@ export class BaseGiven {
|
|
|
281
185
|
const afterEachProxy = new Proxy(pm, {
|
|
282
186
|
get(target, prop, receiver) {
|
|
283
187
|
if (prop === "customScreenShot") {
|
|
284
|
-
return (opts) => target.customScreenShot(Object.assign(Object.assign({}, opts), { path: `suite-${suiteNdx}/given-${key}/afterEach/${opts.path}` }));
|
|
188
|
+
return (opts, p) => target.customScreenShot(Object.assign(Object.assign({}, opts), { path: `suite-${suiteNdx}/given-${key}/afterEach/${opts.path}` }), p);
|
|
285
189
|
}
|
|
286
190
|
if (prop === "writeFileSync") {
|
|
287
191
|
return (fp, contents) => target[prop](`suite-${suiteNdx}/given-${key}/afterEach/${fp}`, contents);
|
|
@@ -289,7 +193,7 @@ export class BaseGiven {
|
|
|
289
193
|
return Reflect.get(...arguments);
|
|
290
194
|
},
|
|
291
195
|
});
|
|
292
|
-
await this.afterEach(this.store, key, givenArtifactory,
|
|
196
|
+
await this.afterEach(this.store, this.key, givenArtifactory,
|
|
293
197
|
// pm
|
|
294
198
|
afterEachProxy);
|
|
295
199
|
}
|
|
@@ -317,91 +221,11 @@ export class BaseWhen {
|
|
|
317
221
|
const andWhenProxy = new Proxy(pm, {
|
|
318
222
|
get(target, prop, receiver) {
|
|
319
223
|
if (prop === "customScreenShot") {
|
|
320
|
-
return (opts) => target.customScreenShot(Object.assign(Object.assign({}, opts), { path: `${filepath}/${opts.path}` }));
|
|
224
|
+
return (opts, p) => target.customScreenShot(Object.assign(Object.assign({}, opts), { path: `${filepath}/${opts.path}` }), p);
|
|
321
225
|
}
|
|
322
226
|
if (prop === "writeFileSync") {
|
|
323
227
|
return (fp, contents) => target[prop](`${filepath}/andWhen/${fp}`, contents);
|
|
324
228
|
}
|
|
325
|
-
/////////////////////
|
|
326
|
-
// if (prop === "browser") {
|
|
327
|
-
// return new Proxy(target[prop], {
|
|
328
|
-
// get(bTarget, bProp, bReceiver) {
|
|
329
|
-
// if (bProp === "pages") {
|
|
330
|
-
// return async () => {
|
|
331
|
-
// return bTarget.pages().then((pages) => {
|
|
332
|
-
// return pages.map((page) => {
|
|
333
|
-
// return new Proxy(page, {
|
|
334
|
-
// get(pTarget, pProp, pReciever) {
|
|
335
|
-
// // console.log("mark get", pTarget, pProp, pReciever);
|
|
336
|
-
// if (pProp === "screenshot") {
|
|
337
|
-
// return async (x) => {
|
|
338
|
-
// return pm.customScreenShot(
|
|
339
|
-
// {
|
|
340
|
-
// ...x,
|
|
341
|
-
// path:
|
|
342
|
-
// `${testResourceConfiguration.fs}/${key}/afterEach` +
|
|
343
|
-
// "/" +
|
|
344
|
-
// x.path,
|
|
345
|
-
// },
|
|
346
|
-
// page
|
|
347
|
-
// );
|
|
348
|
-
// };
|
|
349
|
-
// } else if (pProp === "mainFrame") {
|
|
350
|
-
// return () => pTarget[pProp]();
|
|
351
|
-
// // return target[pProp];
|
|
352
|
-
// // return Reflect.get(...arguments);
|
|
353
|
-
// } else if (pProp === "exposeFunction") {
|
|
354
|
-
// // return Reflect.get(target, prop, receiver);
|
|
355
|
-
// return pTarget[pProp].bind(pTarget);
|
|
356
|
-
// // return target[pProp];
|
|
357
|
-
// } else if (pProp === "removeExposedFunction") {
|
|
358
|
-
// // return Reflect.get(target, prop, receiver);
|
|
359
|
-
// return pTarget[pProp].bind(pTarget);
|
|
360
|
-
// // return target[pProp];
|
|
361
|
-
// } else if (pProp === "click") {
|
|
362
|
-
// // console.log("mark12", arguments);
|
|
363
|
-
// // return Reflect.get(target, prop, receiver);
|
|
364
|
-
// // return pTarget[pProp].bind(pTarget);
|
|
365
|
-
// // return target[pProp];
|
|
366
|
-
// return (selector, options) => {
|
|
367
|
-
// pTarget[pProp](selector, options);
|
|
368
|
-
// };
|
|
369
|
-
// } else if (pProp === "$eval") {
|
|
370
|
-
// // return pTarget[pProp].bind(pTarget);
|
|
371
|
-
// return (selector, options) => {
|
|
372
|
-
// pTarget[pProp](selector, options);
|
|
373
|
-
// };
|
|
374
|
-
// } else if (pProp === "$") {
|
|
375
|
-
// return Reflect.get(...arguments);
|
|
376
|
-
// // return Reflect.get(target, prop, receiver);
|
|
377
|
-
// // return pTarget[pProp].bind(pTarget);
|
|
378
|
-
// // return target[pProp];
|
|
379
|
-
// // return pTarget[pProp].bind(pTarget);
|
|
380
|
-
// // return async (s) => {
|
|
381
|
-
// // console.log("mark17", s);
|
|
382
|
-
// // console.log("pTarget", pTarget);
|
|
383
|
-
// // console.log("pProp", pProp);
|
|
384
|
-
// // console.log("pReciever", pReciever);
|
|
385
|
-
// // // return "XXX";
|
|
386
|
-
// // // debugger;
|
|
387
|
-
// // return await pTarget[pProp](s);
|
|
388
|
-
// // };
|
|
389
|
-
// } else {
|
|
390
|
-
// return Reflect.get(...arguments);
|
|
391
|
-
// }
|
|
392
|
-
// },
|
|
393
|
-
// });
|
|
394
|
-
// });
|
|
395
|
-
// });
|
|
396
|
-
// // return (await target.pages()).map((page) => {
|
|
397
|
-
// // return new Proxy(page, handler2);
|
|
398
|
-
// // });
|
|
399
|
-
// };
|
|
400
|
-
// }
|
|
401
|
-
// },
|
|
402
|
-
// });
|
|
403
|
-
// }
|
|
404
|
-
///////////////////////
|
|
405
229
|
return Reflect.get(...arguments);
|
|
406
230
|
},
|
|
407
231
|
});
|
|
@@ -440,67 +264,11 @@ export class BaseThen {
|
|
|
440
264
|
const butThenProxy = new Proxy(pm, {
|
|
441
265
|
get(target, prop, receiver) {
|
|
442
266
|
if (prop === "customScreenShot") {
|
|
443
|
-
return (opts) => target.customScreenShot(Object.assign(Object.assign({}, opts), { path: `${filepath}/${opts.path}` }));
|
|
267
|
+
return (opts, p) => target.customScreenShot(Object.assign(Object.assign({}, opts), { path: `${filepath}/${opts.path}` }), p);
|
|
444
268
|
}
|
|
445
269
|
if (prop === "writeFileSync") {
|
|
446
270
|
return (fp, contents) => target[prop](`${filepath}/${fp}`, contents);
|
|
447
271
|
}
|
|
448
|
-
// if (prop === "browser") {
|
|
449
|
-
// return new Proxy(target[prop], {
|
|
450
|
-
// get(bTarget, bProp, bReceiver) {
|
|
451
|
-
// if (bProp === "pages") {
|
|
452
|
-
// return async () => {
|
|
453
|
-
// return bTarget.pages().then((pages) => {
|
|
454
|
-
// return pages.map((page) => {
|
|
455
|
-
// return new Proxy(page, {
|
|
456
|
-
// get(pTarget, pProp, pReciever) {
|
|
457
|
-
// if (pProp === "screenshot") {
|
|
458
|
-
// return async (x) => {
|
|
459
|
-
// return pm.customScreenShot(
|
|
460
|
-
// {
|
|
461
|
-
// ...x,
|
|
462
|
-
// path:
|
|
463
|
-
// `${testResourceConfiguration.fs}/${filepath}/butThen` +
|
|
464
|
-
// "/" +
|
|
465
|
-
// x.path,
|
|
466
|
-
// },
|
|
467
|
-
// page
|
|
468
|
-
// );
|
|
469
|
-
// // return await window["custom-screenshot"]({
|
|
470
|
-
// // ...x,
|
|
471
|
-
// // path:
|
|
472
|
-
// // `${testResourceConfiguration.fs}/suite-${sNdx}/afterAll` +
|
|
473
|
-
// // "/" +
|
|
474
|
-
// // x.path,
|
|
475
|
-
// // });
|
|
476
|
-
// };
|
|
477
|
-
// } else if (pProp === "close") {
|
|
478
|
-
// return () => pTarget[pProp]();
|
|
479
|
-
// } else if (pProp === "mainFrame") {
|
|
480
|
-
// return () => pTarget[pProp]();
|
|
481
|
-
// } else if (pProp === "exposeFunction") {
|
|
482
|
-
// // return Reflect.get(target, prop, receiver);
|
|
483
|
-
// return (...a) => pTarget[pProp](...a);
|
|
484
|
-
// // return target[pProp];
|
|
485
|
-
// } else if (pProp === "removeExposedFunction") {
|
|
486
|
-
// // return Reflect.get(target, prop, receiver);
|
|
487
|
-
// return pTarget[pProp].bind(pTarget);
|
|
488
|
-
// // return target[pProp];
|
|
489
|
-
// } else {
|
|
490
|
-
// return Reflect.get(...arguments);
|
|
491
|
-
// }
|
|
492
|
-
// },
|
|
493
|
-
// });
|
|
494
|
-
// });
|
|
495
|
-
// });
|
|
496
|
-
// // return (await target.pages()).map((page) => {
|
|
497
|
-
// // return new Proxy(page, handler2);
|
|
498
|
-
// // });
|
|
499
|
-
// };
|
|
500
|
-
// }
|
|
501
|
-
// },
|
|
502
|
-
// });
|
|
503
|
-
// }
|
|
504
272
|
return Reflect.get(...arguments);
|
|
505
273
|
},
|
|
506
274
|
});
|
|
@@ -11,21 +11,11 @@ export class BaseBuilder {
|
|
|
11
11
|
this.checkOverides = checkOverides;
|
|
12
12
|
this.testSpecification = testSpecification;
|
|
13
13
|
this.specs = testSpecification(this.Suites(), this.Given(), this.When(), this.Then(), this.Check());
|
|
14
|
-
// const f = this.specs[0].features;
|
|
15
14
|
this.testJobs = this.specs.map((suite) => {
|
|
16
15
|
const suiteRunner = (suite) => async (puppetMaster, tLog) => {
|
|
17
|
-
// const puppeteerBrowser = await puppetMaster.startPuppeteer(
|
|
18
|
-
// {
|
|
19
|
-
// browserWSEndpoint:
|
|
20
|
-
// puppetMaster.testResourceConfiguration.browserWSEndpoint,
|
|
21
|
-
// },
|
|
22
|
-
// puppetMaster.testResourceConfiguration.fs
|
|
23
|
-
// );
|
|
24
16
|
const x = await suite.run(input, puppetMaster.testResourceConfiguration, (fPath, value) => puppetMaster.testArtiFactoryfileWriter(tLog, (p) => {
|
|
25
17
|
this.artifacts.push(p);
|
|
26
18
|
})(puppetMaster.testResourceConfiguration.fs + "/" + fPath, value), tLog, puppetMaster);
|
|
27
|
-
// await puppetMaster.browser.disconnect();
|
|
28
|
-
// puppeteerBrowser.close();
|
|
29
19
|
return x;
|
|
30
20
|
};
|
|
31
21
|
const runner = suiteRunner(suite);
|
|
@@ -59,7 +49,7 @@ export class BaseBuilder {
|
|
|
59
49
|
// );
|
|
60
50
|
// }
|
|
61
51
|
puppetMaster.writeFileSync(`tests.json`, JSON.stringify(this.toObj(), null, 2));
|
|
62
|
-
console.log(`exiting gracefully with ${numberOfFailures} failures.`);
|
|
52
|
+
// console.log(`exiting gracefully with ${numberOfFailures} failures.`);
|
|
63
53
|
return {
|
|
64
54
|
failed: numberOfFailures,
|
|
65
55
|
artifacts: this.artifacts || [],
|
|
@@ -7,7 +7,7 @@ export class ClassBuilder extends BaseBuilder {
|
|
|
7
7
|
};
|
|
8
8
|
return a;
|
|
9
9
|
}, {});
|
|
10
|
-
const classyGivens = Object.entries(testImplementation.givens).reduce((a, [key,
|
|
10
|
+
const classyGivens = Object.entries(testImplementation.givens).reduce((a, [key, g]) => {
|
|
11
11
|
a[key] = (features, whens, thens, givEn) => {
|
|
12
12
|
return new givenKlasser.prototype.constructor(key, features, whens, thens, testImplementation.givens[key], givEn);
|
|
13
13
|
};
|