testeranto 0.62.0 → 0.73.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -26
- package/dist/cjs-shim.js +2 -2
- package/dist/common/Node.js +14 -51
- package/dist/common/PM/index.js +71 -0
- package/dist/common/PM/main.js +361 -0
- package/dist/common/PM/node.js +176 -0
- package/dist/common/PM/web.js +174 -0
- package/dist/common/Project.js +121 -266
- package/dist/common/Puppeteer.js +109 -0
- package/dist/common/Reporter.js +119 -0
- package/dist/common/Scheduler.js +1 -0
- package/dist/common/SubPackages/puppeteer.js +3 -1
- package/dist/common/SubPackages/react-dom/component/web.js +98 -45
- package/dist/common/SubPackages/react-dom/jsx/web.js +15 -7
- package/dist/common/SubPackages/react-test-renderer/MemoExoticComponent/node.js +1 -1
- package/dist/common/SubPackages/react-test-renderer/component/index.js +0 -1
- package/dist/common/SubPackages/react-test-renderer/fc/web.js +1 -1
- package/dist/common/SubPackages/react-test-renderer/jsx/index.js +1 -3
- package/dist/common/SubPackages/react-test-renderer/jsx/web.js +1 -1
- package/dist/common/SubPackages/react-test-renderer/jsx-promised/index.js +1 -1
- package/dist/common/Types.js +2 -32
- package/dist/common/Web.js +25 -37
- package/dist/common/esbuildConfigs/index.js +5 -5
- package/dist/common/esbuildConfigs/node.js +17 -15
- package/dist/common/esbuildConfigs/report.js +12 -47
- package/dist/common/esbuildConfigs/tests.js +0 -1
- package/dist/common/esbuildConfigs/web.js +17 -12
- package/dist/common/lib/abstractBase.js +190 -35
- package/dist/common/lib/basebuilder.js +56 -29
- package/dist/common/lib/classBuilder.js +8 -5
- package/dist/common/lib/core.js +42 -17
- package/dist/common/lib/index.js +11 -8
- package/dist/common/lib/types.js +2 -0
- package/dist/common/preload.js +14 -28
- package/dist/common/puppeteerConfiger.js +24 -0
- package/dist/common/tsconfig.common.tsbuildinfo +1 -1
- package/dist/module/Node.js +14 -51
- package/dist/module/PM/index.js +67 -0
- package/dist/module/PM/main.js +331 -0
- package/dist/module/PM/node.js +168 -0
- package/dist/module/PM/web.js +167 -0
- package/dist/module/Project.js +122 -267
- package/dist/module/Puppeteer.js +104 -0
- package/dist/module/Reporter.js +114 -0
- package/dist/module/Scheduler.js +1 -0
- package/dist/module/SubPackages/puppeteer.js +3 -1
- package/dist/module/SubPackages/react/jsx/node.js +1 -1
- package/dist/module/SubPackages/react/jsx/web.js +1 -1
- package/dist/module/SubPackages/react-dom/component/node.js +2 -2
- package/dist/module/SubPackages/react-dom/component/web.js +98 -45
- package/dist/module/SubPackages/react-dom/jsx/web.js +17 -9
- package/dist/module/SubPackages/react-test-renderer/MemoExoticComponent/node.js +1 -1
- package/dist/module/SubPackages/react-test-renderer/component/index.js +0 -1
- package/dist/module/SubPackages/react-test-renderer/fc/web.js +1 -1
- package/dist/module/SubPackages/react-test-renderer/jsx/index.js +1 -3
- package/dist/module/SubPackages/react-test-renderer/jsx/web.js +1 -1
- package/dist/module/SubPackages/react-test-renderer/jsx-promised/index.js +1 -1
- package/dist/module/Types.js +3 -30
- package/dist/module/Web.js +26 -38
- package/dist/module/esbuildConfigs/index.js +5 -5
- package/dist/module/esbuildConfigs/node.js +17 -15
- package/dist/module/esbuildConfigs/report.js +11 -48
- package/dist/module/esbuildConfigs/tests.js +0 -1
- package/dist/module/esbuildConfigs/web.js +17 -12
- package/dist/module/lib/abstractBase.js +190 -35
- package/dist/module/lib/basebuilder.js +56 -29
- package/dist/module/lib/classBuilder.js +8 -5
- package/dist/module/lib/core.js +44 -19
- package/dist/module/lib/index.js +11 -8
- package/dist/module/preload.js +15 -27
- package/dist/module/puppeteerConfiger.js +19 -0
- package/dist/module/tsconfig.module.tsbuildinfo +1 -1
- package/dist/prebuild/Report.css +1616 -584
- package/dist/prebuild/Report.js +2635 -2506
- package/dist/types/Node.d.ts +3 -2
- package/dist/types/PM/index.d.ts +19 -0
- package/dist/types/PM/main.d.ts +28 -0
- package/dist/types/PM/node.d.ts +26 -0
- package/dist/types/PM/web.d.ts +24 -0
- package/dist/types/Project.d.ts +1 -2
- package/dist/types/Puppeteer.d.ts +1 -0
- package/dist/types/Reporter.d.ts +1 -0
- package/dist/types/Scheduler.d.ts +0 -0
- package/dist/types/SubPackages/puppeteer.d.ts +3 -3
- package/dist/types/SubPackages/react/component/node.d.ts +1 -1
- package/dist/types/SubPackages/react/component/web.d.ts +1 -1
- package/dist/types/SubPackages/react/jsx/index.d.ts +1 -1
- package/dist/types/SubPackages/react/jsx/node.d.ts +1 -1
- package/dist/types/SubPackages/react/jsx/web.d.ts +2 -2
- package/dist/types/SubPackages/react-dom/component/node.d.ts +2 -2
- package/dist/types/SubPackages/react-dom/component/web.d.ts +1 -1
- package/dist/types/SubPackages/react-dom/jsx/node.d.ts +1 -1
- package/dist/types/SubPackages/react-dom/jsx/web.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/MemoExoticComponent/node.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/component/index.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/component/node.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/component/web.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/fc/node.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/fc/web.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/jsx/node.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/jsx/web.d.ts +3 -3
- package/dist/types/SubPackages/react-test-renderer/jsx-promised/index.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/jsx-promised/node.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/jsx-promised/web.d.ts +1 -1
- package/dist/types/Types.d.ts +19 -100
- package/dist/types/Web.d.ts +3 -2
- package/dist/types/esbuildConfigs/features.d.ts +1 -1
- package/dist/types/esbuildConfigs/index.d.ts +1 -1
- package/dist/types/esbuildConfigs/node.d.ts +1 -1
- package/dist/types/esbuildConfigs/report.d.ts +4 -0
- package/dist/types/esbuildConfigs/tests.d.ts +1 -1
- package/dist/types/esbuildConfigs/web.d.ts +1 -1
- package/dist/types/lib/abstractBase.d.ts +26 -24
- package/dist/types/lib/basebuilder.d.ts +10 -7
- package/dist/types/lib/classBuilder.d.ts +4 -3
- package/dist/types/lib/core.d.ts +5 -4
- package/dist/types/lib/index.d.ts +7 -5
- package/dist/types/lib/types.d.ts +62 -0
- package/dist/types/preload.d.ts +0 -1
- package/dist/types/puppeteerConfiger.d.ts +4 -0
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +6 -7
- package/src/Node.ts +30 -85
- package/src/PM/index.ts +102 -0
- package/src/PM/main.ts +420 -0
- package/src/PM/node.ts +515 -0
- package/src/PM/web.ts +497 -0
- package/src/Project.ts +183 -619
- package/src/Puppeteer.ts +131 -0
- package/src/Report.tsx +158 -44
- package/src/Reporter.ts +134 -0
- package/src/Scheduler.ts +0 -0
- package/src/SubPackages/puppeteer.ts +19 -14
- package/src/SubPackages/react/component/node.ts +20 -32
- package/src/SubPackages/react/component/web.ts +20 -30
- package/src/SubPackages/react/jsx/index.ts +13 -24
- package/src/SubPackages/react/jsx/node.ts +5 -8
- package/src/SubPackages/react/jsx/web.ts +10 -8
- package/src/SubPackages/react-dom/component/node.ts +17 -23
- package/src/SubPackages/react-dom/component/web.ts +134 -95
- package/src/SubPackages/react-dom/jsx/web.ts +41 -48
- package/src/SubPackages/react-test-renderer/MemoExoticComponent/node.ts +27 -37
- package/src/SubPackages/react-test-renderer/component/index.ts +16 -30
- package/src/SubPackages/react-test-renderer/component/node.ts +5 -11
- package/src/SubPackages/react-test-renderer/component/web.ts +5 -11
- package/src/SubPackages/react-test-renderer/fc/node.ts +36 -50
- package/src/SubPackages/react-test-renderer/fc/web.ts +37 -50
- package/src/SubPackages/react-test-renderer/jsx/index.ts +15 -21
- package/src/SubPackages/react-test-renderer/jsx/node.ts +6 -10
- package/src/SubPackages/react-test-renderer/jsx/web.ts +7 -7
- package/src/SubPackages/react-test-renderer/jsx-promised/index.ts +13 -16
- package/src/Types.ts +73 -307
- package/src/Web.ts +40 -81
- package/src/cjs-shim.js +2 -2
- package/src/esbuildConfigs/features.ts +3 -4
- package/src/esbuildConfigs/index.ts +8 -8
- package/src/esbuildConfigs/node.ts +21 -20
- package/src/esbuildConfigs/report.ts +15 -51
- package/src/esbuildConfigs/tests.ts +3 -9
- package/src/esbuildConfigs/web.ts +22 -20
- package/src/lib/abstractBase.ts +312 -164
- package/src/lib/basebuilder.ts +123 -127
- package/src/lib/classBuilder.ts +30 -48
- package/src/lib/core.ts +115 -84
- package/src/lib/index.ts +58 -56
- package/src/lib/types.ts +197 -0
- package/src/preload.ts +14 -30
- package/src/puppeteerConfiger.ts +26 -0
- package/src/web.html.ts +1 -1
- package/dist/common/NodeWriter.js +0 -56
- package/dist/common/electron.js +0 -196
- package/dist/common/lib/browser.js +0 -26
- package/dist/common/nodeWriterElectron.js +0 -55
- package/dist/module/NodeWriter.js +0 -50
- package/dist/module/electron.js +0 -191
- package/dist/module/lib/browser.js +0 -22
- package/dist/module/nodeWriterElectron.js +0 -52
- package/dist/types/NodeWriter.d.ts +0 -2
- package/dist/types/lib/browser.d.ts +0 -6
- package/dist/types/nodeWriterElectron.d.ts +0 -2
- package/src/NodeWriter.ts +0 -69
- package/src/electron.ts +0 -250
- package/src/lib/browser.ts +0 -34
- package/src/nodeWriterElectron.ts +0 -71
- package/yarn-error.log +0 -3144
- /package/dist/{types/electron.d.ts → module/lib/types.js} +0 -0
|
@@ -3,16 +3,16 @@ export default (config) => {
|
|
|
3
3
|
target: "esnext",
|
|
4
4
|
format: "esm",
|
|
5
5
|
splitting: true,
|
|
6
|
-
outExtension: {
|
|
6
|
+
outExtension: { ".js": ".mjs" },
|
|
7
7
|
outbase: config.outbase,
|
|
8
|
-
jsx:
|
|
8
|
+
jsx: "transform",
|
|
9
9
|
bundle: true,
|
|
10
10
|
minify: config.minify === true,
|
|
11
11
|
write: true,
|
|
12
12
|
loader: {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
".js": "jsx",
|
|
14
|
+
".png": "binary",
|
|
15
|
+
".jpg": "binary",
|
|
16
16
|
},
|
|
17
17
|
};
|
|
18
18
|
};
|
|
@@ -1,30 +1,32 @@
|
|
|
1
1
|
import baseEsBuildConfig from "./index.js";
|
|
2
|
-
// const jsonConfig = jsonc.parse((await fs.readFileSync("./testeranto.json")).toString()) as IJsonConfig;
|
|
3
2
|
export default (config, entryPoints) => {
|
|
4
|
-
return Object.assign(Object.assign({}, baseEsBuildConfig(config)), { outdir: config.outdir + "/node", inject: [`./node_modules/testeranto/dist/cjs-shim.js`], supported: {
|
|
5
|
-
"dynamic-import": true
|
|
3
|
+
return Object.assign(Object.assign({}, baseEsBuildConfig(config)), { splitting: true, outdir: config.outdir + "/node", inject: [`./node_modules/testeranto/dist/cjs-shim.js`], supported: {
|
|
4
|
+
"dynamic-import": true,
|
|
6
5
|
}, define: {
|
|
7
|
-
"process.env.FLUENTFFMPEG_COV": "0"
|
|
6
|
+
"process.env.FLUENTFFMPEG_COV": "0",
|
|
8
7
|
}, absWorkingDir: process.cwd(), banner: {
|
|
9
|
-
js: `import { createRequire } from 'module';const require = createRequire(import.meta.url)
|
|
8
|
+
js: `import { createRequire } from 'module';const require = createRequire(import.meta.url);`,
|
|
10
9
|
}, platform: "node", external: [
|
|
11
|
-
"testeranto.json",
|
|
12
|
-
"features.test.js",
|
|
13
|
-
"react",
|
|
14
|
-
"events",
|
|
10
|
+
// "testeranto.json",
|
|
11
|
+
// "features.test.js",
|
|
12
|
+
// "react",
|
|
13
|
+
// "events",
|
|
15
14
|
// "ganache"
|
|
16
|
-
...config.externals
|
|
15
|
+
...config.externals,
|
|
17
16
|
], entryPoints: [...entryPoints], plugins: [
|
|
18
17
|
...(config.nodePlugins || []),
|
|
19
18
|
{
|
|
20
|
-
name:
|
|
19
|
+
name: "rebuild-notify",
|
|
21
20
|
setup(build) {
|
|
22
|
-
build.onEnd(result => {
|
|
21
|
+
build.onEnd((result) => {
|
|
23
22
|
console.log(`node build ended with ${result.errors.length} errors`);
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
if (result.errors.length > 0) {
|
|
24
|
+
console.log(result);
|
|
25
|
+
}
|
|
26
|
+
// console.log(result);
|
|
27
|
+
// result.errors.length !== 0 && process.exit(-1);
|
|
26
28
|
});
|
|
27
|
-
}
|
|
29
|
+
},
|
|
28
30
|
},
|
|
29
31
|
] });
|
|
30
32
|
};
|
|
@@ -1,48 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
// entryPoints: ["./node_modules/testeranto/dist/module/report.js"],
|
|
13
|
-
// minify: config.minify === true,
|
|
14
|
-
// outbase: config.outbase,
|
|
15
|
-
// write: true,
|
|
16
|
-
// outfile: `${jsonConfig.outdir}/report.js`,
|
|
17
|
-
// external: [
|
|
18
|
-
// "tests.json",
|
|
19
|
-
// "features.test.js"
|
|
20
|
-
// ],
|
|
21
|
-
// // plugins: [
|
|
22
|
-
// // CssModulesPlugin({
|
|
23
|
-
// // // @see https://github.com/indooorsman/esbuild-css-modules-plugin/blob/main/index.d.ts for more details
|
|
24
|
-
// // force: true,
|
|
25
|
-
// // emitDeclarationFile: true,
|
|
26
|
-
// // localsConvention: 'camelCaseOnly',
|
|
27
|
-
// // namedExports: true,
|
|
28
|
-
// // inject: false
|
|
29
|
-
// // })
|
|
30
|
-
// // ]
|
|
31
|
-
// }
|
|
32
|
-
// // return {
|
|
33
|
-
// // bundle: true,
|
|
34
|
-
// // entryPoints: [
|
|
35
|
-
// // "./node_modules/testeranto/dist/module/Report.js",
|
|
36
|
-
// // jsonConfig.features
|
|
37
|
-
// // ],
|
|
38
|
-
// // minify: config.minify === true,
|
|
39
|
-
// // outbase: ".",
|
|
40
|
-
// // outdir: 'docs',
|
|
41
|
-
// // write: true,
|
|
42
|
-
// // // outfile: `${jsonConfig.outdir}/Report.js`,
|
|
43
|
-
// // external: [
|
|
44
|
-
// // "features.test.js",
|
|
45
|
-
// // "testeranto.json"
|
|
46
|
-
// // ]
|
|
47
|
-
// // }
|
|
48
|
-
// }
|
|
1
|
+
export default (config) => {
|
|
2
|
+
return {
|
|
3
|
+
bundle: true,
|
|
4
|
+
entryPoints: ["./node_modules/testeranto/dist/module/report.js"],
|
|
5
|
+
minify: config.minify === true,
|
|
6
|
+
outbase: config.outbase,
|
|
7
|
+
write: true,
|
|
8
|
+
outfile: `${config.outdir}/report.js`,
|
|
9
|
+
external: ["tests.json", "features.test.js"],
|
|
10
|
+
};
|
|
11
|
+
};
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import baseEsBuildConfig from "./index.js";
|
|
3
|
-
// const jsonConfig = jsonc.parse((await fs.readFileSync("./testeranto.json")).toString()) as IJsonConfig;
|
|
4
3
|
export default (config, entryPoints) => {
|
|
5
4
|
return Object.assign(Object.assign({}, baseEsBuildConfig(config)), {
|
|
6
|
-
// inject: [
|
|
5
|
+
// inject: ["./node_modules/testeranto/dist/cjs-shim.js"],
|
|
7
6
|
// banner: {
|
|
8
|
-
// js: `import { createRequire } from 'module';const require = createRequire(import.meta.url)
|
|
7
|
+
// js: `import { createRequire } from 'module';const require = createRequire(import.meta.url);`,
|
|
9
8
|
// },
|
|
9
|
+
// splitting: true,
|
|
10
10
|
outdir: config.outdir + "/web", alias: {
|
|
11
|
-
react: path.resolve("./node_modules/react")
|
|
11
|
+
react: path.resolve("./node_modules/react"),
|
|
12
12
|
}, external: [
|
|
13
13
|
"testeranto.json",
|
|
14
14
|
"features.test.ts",
|
|
15
|
-
// "url",
|
|
15
|
+
// "url",
|
|
16
16
|
"react",
|
|
17
|
-
"electron",
|
|
18
17
|
"path",
|
|
19
18
|
"fs",
|
|
20
19
|
"stream",
|
|
@@ -28,18 +27,24 @@ export default (config, entryPoints) => {
|
|
|
28
27
|
"readline",
|
|
29
28
|
"zlib",
|
|
30
29
|
"crypto",
|
|
31
|
-
"https"
|
|
30
|
+
"https",
|
|
31
|
+
"util",
|
|
32
|
+
"process",
|
|
33
|
+
"dns",
|
|
32
34
|
], platform: "browser", entryPoints: [...entryPoints], plugins: [
|
|
33
35
|
...(config.webPlugins || []),
|
|
34
36
|
{
|
|
35
|
-
name:
|
|
37
|
+
name: "rebuild-notify",
|
|
36
38
|
setup(build) {
|
|
37
|
-
build.onEnd(result => {
|
|
39
|
+
build.onEnd((result) => {
|
|
38
40
|
console.log(`web build ended with ${result.errors.length} errors`);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
if (result.errors.length > 0) {
|
|
42
|
+
console.log(result);
|
|
43
|
+
}
|
|
44
|
+
// console.log(result);
|
|
45
|
+
// result.errors.length !== 0 && process.exit(-1);
|
|
41
46
|
});
|
|
42
|
-
}
|
|
47
|
+
},
|
|
43
48
|
},
|
|
44
49
|
] });
|
|
45
50
|
};
|
|
@@ -13,38 +13,114 @@ export class BaseSuite {
|
|
|
13
13
|
fails: this.fails,
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
|
-
setup(s, artifactory, tr,
|
|
16
|
+
setup(s, artifactory, tr, pm) {
|
|
17
17
|
return new Promise((res) => res(s));
|
|
18
18
|
}
|
|
19
19
|
assertThat(t) {
|
|
20
|
-
// console.log("base assertThat")
|
|
21
20
|
return t;
|
|
22
21
|
}
|
|
23
|
-
|
|
22
|
+
afterAll(store, artifactory, pm) {
|
|
23
|
+
return store;
|
|
24
|
+
}
|
|
25
|
+
async run(input, testResourceConfiguration, artifactory, tLog, pm) {
|
|
24
26
|
this.testResourceConfiguration = testResourceConfiguration;
|
|
25
|
-
tLog("test resources: ", testResourceConfiguration);
|
|
27
|
+
tLog("test resources: ", JSON.stringify(testResourceConfiguration));
|
|
26
28
|
const suiteArtifactory = (fPath, value) => artifactory(`suite-${this.index}-${this.name}/${fPath}`, value);
|
|
27
|
-
|
|
29
|
+
console.log("\nSuite:", this.index, this.name);
|
|
28
30
|
tLog("\nSuite:", this.index, this.name);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
const sNdx = this.index;
|
|
32
|
+
const sName = this.name;
|
|
33
|
+
for (const [gNdx, g] of Object.entries(this.givens)) {
|
|
34
|
+
const subject = await this.setup(input, suiteArtifactory, testResourceConfiguration, pm);
|
|
35
|
+
const giver = this.givens[gNdx];
|
|
31
36
|
try {
|
|
32
|
-
this.store = await giver.give(subject,
|
|
37
|
+
this.store = await giver.give(subject, gNdx, testResourceConfiguration, this.assertThat, suiteArtifactory, tLog, pm, sNdx);
|
|
33
38
|
}
|
|
34
39
|
catch (e) {
|
|
35
40
|
console.error(e);
|
|
36
41
|
this.fails.push(giver);
|
|
37
|
-
return this;
|
|
42
|
+
// return this;
|
|
38
43
|
}
|
|
39
44
|
}
|
|
40
|
-
|
|
41
|
-
|
|
45
|
+
const afterAllProxy = new Proxy(pm, {
|
|
46
|
+
get(target, prop, receiver) {
|
|
47
|
+
if (prop === "writeFileSync") {
|
|
48
|
+
return (fp, contents) => target[prop](`suite-${sNdx}/afterAll/${fp}`, contents);
|
|
49
|
+
}
|
|
50
|
+
if (prop === "browser") {
|
|
51
|
+
return new Proxy(target[prop], {
|
|
52
|
+
get(bTarget, bProp, bReceiver) {
|
|
53
|
+
if (bProp === "pages") {
|
|
54
|
+
return async () => {
|
|
55
|
+
return bTarget.pages().then((pages) => {
|
|
56
|
+
return pages.map((page) => {
|
|
57
|
+
return new Proxy(page, {
|
|
58
|
+
get(pTarget, pProp, pReciever) {
|
|
59
|
+
if (pProp === "screenshot") {
|
|
60
|
+
return async (x) => {
|
|
61
|
+
// console.log(
|
|
62
|
+
// "custom-screenshot-MARK-afterAllProxy",
|
|
63
|
+
// // arguments,
|
|
64
|
+
// // x,
|
|
65
|
+
// window["custom-screenshot"].toString()
|
|
66
|
+
// );
|
|
67
|
+
return await window["custom-screenshot"](Object.assign(Object.assign({}, x), { path: `${testResourceConfiguration.fs}/suite-${sNdx}/afterAll` +
|
|
68
|
+
"/" +
|
|
69
|
+
x.path }));
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
// else if (pProp === "mainFrame") {
|
|
73
|
+
// return () => target[pProp](...arguments);
|
|
74
|
+
// }
|
|
75
|
+
else {
|
|
76
|
+
return Reflect.get(...arguments);
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
// return (await target.pages()).map((page) => {
|
|
83
|
+
// return new Proxy(page, handler2);
|
|
84
|
+
// });
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
return Reflect.get(...arguments);
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
// pm.browser
|
|
94
|
+
try {
|
|
95
|
+
this.afterAll(this.store, artifactory, afterAllProxy);
|
|
42
96
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
97
|
+
catch (e) {
|
|
98
|
+
console.error(e);
|
|
99
|
+
// this.fails.push(this);
|
|
100
|
+
// return this;
|
|
47
101
|
}
|
|
102
|
+
// for (const [ndx, thater] of this.checks.entries()) {
|
|
103
|
+
// await thater.check(
|
|
104
|
+
// subject,
|
|
105
|
+
// thater.name,
|
|
106
|
+
// testResourceConfiguration,
|
|
107
|
+
// this.assertThat,
|
|
108
|
+
// suiteArtifactory,
|
|
109
|
+
// tLog,
|
|
110
|
+
// pm
|
|
111
|
+
// );
|
|
112
|
+
// }
|
|
113
|
+
// @TODO fix me
|
|
114
|
+
// for (const k of Object.keys(this.givens)) {
|
|
115
|
+
// const giver = this.givens[k];
|
|
116
|
+
// try {
|
|
117
|
+
// giver.afterAll(this.store, artifactory, pm);
|
|
118
|
+
// } catch (e) {
|
|
119
|
+
// console.error(e);
|
|
120
|
+
// this.fails.push(giver);
|
|
121
|
+
// return this;
|
|
122
|
+
// }
|
|
123
|
+
// }
|
|
48
124
|
////////////////
|
|
49
125
|
return this;
|
|
50
126
|
}
|
|
@@ -61,32 +137,39 @@ export class BaseGiven {
|
|
|
61
137
|
beforeAll(store, artifactory) {
|
|
62
138
|
return store;
|
|
63
139
|
}
|
|
64
|
-
afterAll(store, artifactory, utils) {
|
|
65
|
-
return store;
|
|
66
|
-
}
|
|
67
140
|
toObj() {
|
|
68
141
|
return {
|
|
69
142
|
name: this.name,
|
|
70
143
|
whens: this.whens.map((w) => w.toObj()),
|
|
71
144
|
thens: this.thens.map((t) => t.toObj()),
|
|
72
145
|
error: this.error ? [this.error, this.error.stack] : null,
|
|
146
|
+
// fail: this.fail ? [this.fail] : false,
|
|
73
147
|
features: this.features,
|
|
74
148
|
};
|
|
75
149
|
}
|
|
76
|
-
async afterEach(store, key, artifactory) {
|
|
150
|
+
async afterEach(store, key, artifactory, pm) {
|
|
77
151
|
return store;
|
|
78
152
|
}
|
|
79
|
-
async give(subject, key, testResourceConfiguration, tester, artifactory, tLog,
|
|
153
|
+
async give(subject, key, testResourceConfiguration, tester, artifactory, tLog, pm, suiteNdx) {
|
|
80
154
|
tLog(`\n Given: ${this.name}`);
|
|
81
155
|
const givenArtifactory = (fPath, value) => artifactory(`given-${key}/${fPath}`, value);
|
|
82
156
|
try {
|
|
83
|
-
this.store = await this.givenThat(subject, testResourceConfiguration, givenArtifactory, this.givenCB);
|
|
84
157
|
// tLog(`\n Given this.store`, this.store);
|
|
85
|
-
|
|
86
|
-
|
|
158
|
+
const beforeEachProxy = new Proxy(pm, {
|
|
159
|
+
get(target, prop, receiver) {
|
|
160
|
+
if (prop === "writeFileSync") {
|
|
161
|
+
console.log("beforeEachProx", arguments, target[prop]);
|
|
162
|
+
return (fp, contents) => target[prop](`suite-${suiteNdx}/given-${key}/when/beforeEach/${fp}`, contents);
|
|
163
|
+
}
|
|
164
|
+
return Reflect.get(...arguments);
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
this.store = await this.givenThat(subject, testResourceConfiguration, givenArtifactory, this.givenCB, beforeEachProxy);
|
|
168
|
+
for (const [whenNdx, whenStep] of this.whens.entries()) {
|
|
169
|
+
await whenStep.test(this.store, testResourceConfiguration, tLog, pm, `suite-${suiteNdx}/given-${key}/when/${whenNdx}`);
|
|
87
170
|
}
|
|
88
171
|
for (const thenStep of this.thens) {
|
|
89
|
-
const t = await thenStep.test(this.store, testResourceConfiguration, tLog,
|
|
172
|
+
const t = await thenStep.test(this.store, testResourceConfiguration, tLog, pm);
|
|
90
173
|
tester(t);
|
|
91
174
|
}
|
|
92
175
|
}
|
|
@@ -98,7 +181,66 @@ export class BaseGiven {
|
|
|
98
181
|
}
|
|
99
182
|
finally {
|
|
100
183
|
try {
|
|
101
|
-
|
|
184
|
+
// const afterEachProxy = new Proxy(pm, {
|
|
185
|
+
// get(target, prop, receiver) {
|
|
186
|
+
// if (prop === "writeFileSync") {
|
|
187
|
+
// console.log("afterEachProxy", arguments, target[prop]);
|
|
188
|
+
// return (fp, contents) =>
|
|
189
|
+
// // target[prop](`${key}/andWhen/${fp}`, contents);
|
|
190
|
+
// target[prop](`${key}/afterEach/${fp}`, contents);
|
|
191
|
+
// }
|
|
192
|
+
// return Reflect.get(...arguments);
|
|
193
|
+
// },
|
|
194
|
+
// });
|
|
195
|
+
// await this.afterEach(this.store, key, givenArtifactory, afterEachProxy);
|
|
196
|
+
// await this.afterEach(this.store, key, givenArtifactory, pm);
|
|
197
|
+
const afterEachProxy = new Proxy(pm, {
|
|
198
|
+
get(target, prop, receiver) {
|
|
199
|
+
if (prop === "writeFileSync") {
|
|
200
|
+
return (fp, contents) => target[prop](`suite-${suiteNdx}/given-${key}/afterAll/${fp}`, contents);
|
|
201
|
+
}
|
|
202
|
+
if (prop === "browser") {
|
|
203
|
+
return new Proxy(target[prop], {
|
|
204
|
+
get(bTarget, bProp, bReceiver) {
|
|
205
|
+
if (bProp === "pages") {
|
|
206
|
+
return async () => {
|
|
207
|
+
return bTarget.pages().then((pages) => {
|
|
208
|
+
return pages.map((page) => {
|
|
209
|
+
return new Proxy(page, {
|
|
210
|
+
get(pTarget, pProp, pReciever) {
|
|
211
|
+
if (pProp === "screenshot") {
|
|
212
|
+
return async (x) => {
|
|
213
|
+
// console.log(
|
|
214
|
+
// "custom-screenshot-MARK-afterEachProxy",
|
|
215
|
+
// window["custom-screenshot"].toString()
|
|
216
|
+
// );
|
|
217
|
+
return await window["custom-screenshot"](Object.assign(Object.assign({}, x), { path: `${testResourceConfiguration.fs}/suite-${suiteNdx}/given-${key}/afterEach` +
|
|
218
|
+
"/" +
|
|
219
|
+
x.path }));
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
// else if (pProp === "mainFrame") {
|
|
223
|
+
// return () => target[pProp](...arguments);
|
|
224
|
+
// }
|
|
225
|
+
else {
|
|
226
|
+
return Reflect.get(...arguments);
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
// return (await target.pages()).map((page) => {
|
|
233
|
+
// return new Proxy(page, handler2);
|
|
234
|
+
// });
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
return Reflect.get(...arguments);
|
|
241
|
+
},
|
|
242
|
+
});
|
|
243
|
+
await this.afterEach(this.store, key, givenArtifactory, afterEachProxy);
|
|
102
244
|
}
|
|
103
245
|
catch (e) {
|
|
104
246
|
console.error("afterEach failed! no error will be recorded!", e);
|
|
@@ -118,10 +260,22 @@ export class BaseWhen {
|
|
|
118
260
|
error: this.error,
|
|
119
261
|
};
|
|
120
262
|
}
|
|
121
|
-
async test(store, testResourceConfiguration, tLog,
|
|
263
|
+
async test(store, testResourceConfiguration, tLog, pm, key) {
|
|
122
264
|
tLog(" When:", this.name);
|
|
265
|
+
const name = this.name;
|
|
266
|
+
const andWhenProxy = new Proxy(pm, {
|
|
267
|
+
get(target, prop, receiver) {
|
|
268
|
+
if (prop === "writeFileSync") {
|
|
269
|
+
console.log("andWhenProxy", arguments, target[prop]);
|
|
270
|
+
return (fp, contents) =>
|
|
271
|
+
// target[prop](`${key}/andWhen/${fp}`, contents);
|
|
272
|
+
target[prop](`${key}/andWhen/${fp}`, contents);
|
|
273
|
+
}
|
|
274
|
+
return Reflect.get(...arguments);
|
|
275
|
+
},
|
|
276
|
+
});
|
|
123
277
|
try {
|
|
124
|
-
return await this.andWhen(store, this.whenCB, testResourceConfiguration);
|
|
278
|
+
return await this.andWhen(store, this.whenCB, testResourceConfiguration, andWhenProxy);
|
|
125
279
|
}
|
|
126
280
|
catch (e) {
|
|
127
281
|
this.error = true;
|
|
@@ -133,6 +287,7 @@ export class BaseThen {
|
|
|
133
287
|
constructor(name, thenCB) {
|
|
134
288
|
this.name = name;
|
|
135
289
|
this.thenCB = thenCB;
|
|
290
|
+
this.error = false;
|
|
136
291
|
}
|
|
137
292
|
toObj() {
|
|
138
293
|
return {
|
|
@@ -140,15 +295,15 @@ export class BaseThen {
|
|
|
140
295
|
error: this.error,
|
|
141
296
|
};
|
|
142
297
|
}
|
|
143
|
-
async test(store, testResourceConfiguration, tLog,
|
|
298
|
+
async test(store, testResourceConfiguration, tLog, pm) {
|
|
144
299
|
tLog(" Then:", this.name);
|
|
145
300
|
try {
|
|
146
|
-
const x =
|
|
301
|
+
const x = await this.butThen(store, this.thenCB, testResourceConfiguration);
|
|
147
302
|
return x;
|
|
148
303
|
}
|
|
149
304
|
catch (e) {
|
|
150
305
|
console.log("test failed", e);
|
|
151
|
-
this.error =
|
|
306
|
+
this.error = e.message;
|
|
152
307
|
throw e;
|
|
153
308
|
}
|
|
154
309
|
}
|
|
@@ -161,25 +316,25 @@ export class BaseCheck {
|
|
|
161
316
|
this.whens = whens;
|
|
162
317
|
this.thens = thens;
|
|
163
318
|
}
|
|
164
|
-
async afterEach(store, key, cb) {
|
|
319
|
+
async afterEach(store, key, cb, pm) {
|
|
165
320
|
return;
|
|
166
321
|
}
|
|
167
|
-
async check(subject, key, testResourceConfiguration, tester, artifactory, tLog,
|
|
322
|
+
async check(subject, key, testResourceConfiguration, tester, artifactory, tLog, pm) {
|
|
168
323
|
tLog(`\n Check: ${this.name}`);
|
|
169
324
|
const store = await this.checkThat(subject, testResourceConfiguration, artifactory);
|
|
170
325
|
await this.checkCB(Object.entries(this.whens).reduce((a, [key, when]) => {
|
|
171
326
|
a[key] = async (payload) => {
|
|
172
|
-
return await when(payload, testResourceConfiguration).test(store, testResourceConfiguration, tLog,
|
|
327
|
+
return await when(payload, testResourceConfiguration).test(store, testResourceConfiguration, tLog, pm, "x");
|
|
173
328
|
};
|
|
174
329
|
return a;
|
|
175
330
|
}, {}), Object.entries(this.thens).reduce((a, [key, then]) => {
|
|
176
331
|
a[key] = async (payload) => {
|
|
177
|
-
const t = await then(payload, testResourceConfiguration).test(store, testResourceConfiguration, tLog,
|
|
332
|
+
const t = await then(payload, testResourceConfiguration).test(store, testResourceConfiguration, tLog, pm);
|
|
178
333
|
tester(t);
|
|
179
334
|
};
|
|
180
335
|
return a;
|
|
181
336
|
}, {}));
|
|
182
|
-
await this.afterEach(store, key);
|
|
337
|
+
await this.afterEach(store, key, () => { }, pm);
|
|
183
338
|
return;
|
|
184
339
|
}
|
|
185
340
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export class BaseBuilder {
|
|
2
|
-
constructor(input, suitesOverrides, givenOverides, whenOverides, thenOverides, checkOverides,
|
|
2
|
+
constructor(input, suitesOverrides, givenOverides, whenOverides, thenOverides, checkOverides, testResourceRequirement, testSpecification
|
|
3
|
+
// puppetMaster: PM
|
|
4
|
+
) {
|
|
3
5
|
this.input = input;
|
|
4
6
|
this.artifacts = [];
|
|
5
7
|
this.artifacts = [];
|
|
@@ -10,52 +12,77 @@ export class BaseBuilder {
|
|
|
10
12
|
this.thenOverides = thenOverides;
|
|
11
13
|
this.checkOverides = checkOverides;
|
|
12
14
|
this.testSpecification = testSpecification;
|
|
15
|
+
// this.puppetMaster = puppetMaster;
|
|
13
16
|
this.specs = testSpecification(this.Suites(), this.Given(), this.When(), this.Then(), this.Check());
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
this.testJobs = this.specs.map((suite) => {
|
|
18
|
+
const suiteRunner = (suite) => async (
|
|
19
|
+
// testResourceConfiguration: ITTestResourceConfiguration,
|
|
20
|
+
puppetMaster, tLog) => {
|
|
21
|
+
await puppetMaster.startPuppeteer({
|
|
22
|
+
browserWSEndpoint: puppetMaster.testResourceConfiguration.browserWSEndpoint,
|
|
23
|
+
}, puppetMaster.testResourceConfiguration.fs);
|
|
24
|
+
return await suite.run(input, puppetMaster.testResourceConfiguration, (fPath, value) => puppetMaster.testArtiFactoryfileWriter(tLog, (p) => {
|
|
25
|
+
this.artifacts.push(p);
|
|
26
|
+
})(puppetMaster.testResourceConfiguration.fs + "/" + fPath, value), tLog, puppetMaster);
|
|
27
|
+
};
|
|
28
|
+
const runner = suiteRunner(suite);
|
|
21
29
|
return {
|
|
22
30
|
test: suite,
|
|
23
|
-
testResourceRequirement,
|
|
31
|
+
// testResourceRequirement,
|
|
24
32
|
toObj: () => {
|
|
25
33
|
return suite.toObj();
|
|
26
34
|
},
|
|
27
35
|
runner,
|
|
28
|
-
receiveTestResourceConfig: async function (
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
receiveTestResourceConfig: async function (
|
|
37
|
+
// testResourceConfiguration = {
|
|
38
|
+
// name: "",
|
|
39
|
+
// fs: ".",
|
|
40
|
+
// ports: [],
|
|
41
|
+
// browserWSEndpoint: "",
|
|
42
|
+
// },
|
|
43
|
+
puppetMaster) {
|
|
44
|
+
// console.log(
|
|
45
|
+
// `testResourceConfiguration! ${JSON.stringify(
|
|
46
|
+
// testResourceConfiguration,
|
|
47
|
+
// null,
|
|
48
|
+
// 2
|
|
49
|
+
// )}`
|
|
50
|
+
// );
|
|
51
|
+
// console.log("puppetMaster", puppetMaster);
|
|
52
|
+
await puppetMaster
|
|
53
|
+
.mkdirSync();
|
|
54
|
+
// if (!puppetMaster.existsSync(destFolder)) {
|
|
55
|
+
// puppetMaster.mkdirSync(destFolder, { recursive: true });
|
|
56
|
+
// }
|
|
57
|
+
// puppetMaster.writeFileSync(
|
|
58
|
+
// // puppetMaster.testResourceConfiguration.fs + `/tests.json`,
|
|
59
|
+
// `tests.json`,
|
|
60
|
+
// JSON.stringify(this.toObj(), null, 2)
|
|
61
|
+
// );
|
|
62
|
+
const logFilePath = "log.txt";
|
|
63
|
+
// puppetMaster.testResourceConfiguration.fs + `/log.txt`;
|
|
64
|
+
const access = await puppetMaster.createWriteStream(logFilePath);
|
|
65
|
+
// console.log("access", access);
|
|
39
66
|
const tLog = (...l) => {
|
|
40
|
-
//
|
|
41
|
-
|
|
67
|
+
// access.write(`${l.toString()}\n`);
|
|
68
|
+
// console.log("tLog", l);
|
|
69
|
+
puppetMaster.write(access, `${l.toString()}\n`);
|
|
42
70
|
};
|
|
43
|
-
const suiteDone = await runner(
|
|
44
|
-
const resultsFilePath = (`${testResourceConfiguration.fs}/results.json`);
|
|
45
|
-
logWriter.writeFileSync(resultsFilePath, JSON.stringify(suiteDone.toObj(), null, 2));
|
|
71
|
+
const suiteDone = await runner(puppetMaster, tLog);
|
|
46
72
|
const logPromise = new Promise((res, rej) => {
|
|
47
|
-
|
|
73
|
+
puppetMaster.end(access);
|
|
74
|
+
res(true);
|
|
48
75
|
});
|
|
49
|
-
access.end();
|
|
50
76
|
const numberOfFailures = Object.keys(suiteDone.givens).filter((k) => {
|
|
51
|
-
// console.log(`suiteDone.givens[k].error`, suiteDone.givens[k].error);
|
|
52
77
|
return suiteDone.givens[k].error;
|
|
53
78
|
}).length;
|
|
79
|
+
puppetMaster.writeFileSync(`exitcode`, numberOfFailures.toString());
|
|
80
|
+
puppetMaster.writeFileSync(`tests.json`, JSON.stringify(this.toObj(), null, 2));
|
|
54
81
|
console.log(`exiting gracefully with ${numberOfFailures} failures.`);
|
|
55
82
|
return {
|
|
56
83
|
failed: numberOfFailures,
|
|
57
84
|
artifacts: this.artifacts || [],
|
|
58
|
-
logPromise
|
|
85
|
+
logPromise,
|
|
59
86
|
};
|
|
60
87
|
},
|
|
61
88
|
};
|