testeranto 0.140.2 → 0.143.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/.aider.chat.history.md +9173 -0
- package/.aider.input.history +336 -0
- package/.aider.tags.cache.v3/{ad/3c/10f2ab1397f6d544e613d2a6acaf.val → 3d/81/8b6f0e9b98ec2952cdb8968ac386.val} +0 -0
- package/.aider.tags.cache.v3/63/f1/138061b0aadb868173d197c2a0e0.val +0 -0
- package/.aider.tags.cache.v3/be/72/19ee8e656d160afe9b31523245fe.val +0 -0
- package/.aider.tags.cache.v3/cache.db +0 -0
- package/.aider.tags.cache.v3/cache.db-shm +0 -0
- package/.aider.tags.cache.v3/cache.db-wal +0 -0
- package/.aider.tags.cache.v3/{a7/97/6d37fce350ad2d588f36729db0cd.val → d6/7d/1820c2d4b9330eab7017da4515e7.val} +0 -0
- package/docs/aiderTest.sh +1 -0
- package/docs/testing.ai.txt +98 -0
- package/docs/testing.prompt.txt +8 -0
- package/package.json +3 -3
- package/src/PM/PM_WithEslintAndTsc.ts +35 -21
- package/src/Pure.test.ts +299 -0
- package/src/lib/BaseSuite.test.ts +24 -5
- package/src/lib/abstractBase.test/MockGiven.ts +31 -0
- package/src/lib/abstractBase.test/MockThen.ts +20 -0
- package/src/lib/abstractBase.test/MockWhen.ts +17 -0
- package/src/lib/abstractBase.test/implementation.ts +51 -0
- package/src/lib/abstractBase.test/index.ts +19 -0
- package/src/lib/abstractBase.test/interface.ts +12 -0
- package/src/lib/abstractBase.test/specification.ts +49 -0
- package/src/lib/abstractBase.test/types.ts +19 -0
- package/src/lib/baseBuilder.test/TestBaseBuilder.ts +83 -0
- package/src/lib/baseBuilder.test/baseBuilder.test.implementation.ts +133 -0
- package/src/lib/baseBuilder.test/baseBuilder.test.interface.ts +18 -0
- package/src/lib/baseBuilder.test/baseBuilder.test.specification.ts +35 -0
- package/src/lib/baseBuilder.test/baseBuilder.test.ts +13 -0
- package/src/lib/baseBuilder.test/baseBuilder.test.types.ts +36 -0
- package/src/lib/classBuilder.test/TestClassBuilder.ts +88 -0
- package/src/lib/classBuilder.test/classBuilder.test.implementation.ts +200 -0
- package/src/lib/classBuilder.test/classBuilder.test.interface.ts +17 -0
- package/src/lib/classBuilder.test/classBuilder.test.specification.ts +112 -0
- package/src/lib/classBuilder.test/classBuilder.test.ts +14 -0
- package/src/lib/classBuilder.test/classBuilder.test.types.ts +72 -0
- package/src/lib/core.test/MockCore.ts +49 -0
- package/src/lib/core.test/core.test.implementation.ts +129 -0
- package/src/lib/core.test/core.test.interface.ts +18 -0
- package/src/lib/core.test/core.test.specification.ts +99 -0
- package/src/lib/core.test/core.test.ts +15 -0
- package/src/lib/core.test/core.test.types.ts +68 -0
- package/src/lib/core.ts +1 -1
- package/src/lib/pmProxy.test/implementation.ts +104 -0
- package/src/lib/pmProxy.test/index.ts +19 -0
- package/src/lib/pmProxy.test/interface.ts +47 -0
- package/src/lib/pmProxy.test/mockPM.ts +38 -0
- package/src/lib/pmProxy.test/mockPMBase.ts +136 -0
- package/src/lib/pmProxy.test/specification.ts +123 -0
- package/src/lib/pmProxy.test/types.ts +45 -0
- package/src/lib/pmProxy.ts +40 -193
- package/testeranto/bundles/node/allTests/chunk-2FXOXAKZ.mjs +800 -0
- package/testeranto/bundles/node/allTests/chunk-5MQGD4WC.mjs +251 -0
- package/testeranto/bundles/node/allTests/chunk-6CGAD2FD.mjs +800 -0
- package/testeranto/bundles/node/allTests/chunk-DWKHII32.mjs +800 -0
- package/testeranto/bundles/node/allTests/chunk-KYSOR62N.mjs +167 -0
- package/testeranto/bundles/node/allTests/chunk-PRPFVO6G.mjs +251 -0
- package/testeranto/bundles/node/allTests/chunk-RX4SUFXQ.mjs +251 -0
- package/testeranto/bundles/node/allTests/chunk-UED26IMH.mjs +802 -0
- package/testeranto/bundles/node/allTests/chunk-VAAIAWXC.mjs +117 -0
- package/testeranto/bundles/node/allTests/chunk-W44DUDBK.mjs +251 -0
- package/testeranto/bundles/node/allTests/chunk-YI3EGRMQ.mjs +167 -0
- package/testeranto/bundles/node/allTests/metafile.json +1072 -222
- package/testeranto/bundles/node/allTests/src/PM/__tests__/nodeSidecar.testeranto.mjs +2 -1
- package/testeranto/bundles/node/allTests/src/PM/__tests__/pureSidecar.testeranto.mjs +2 -1
- package/testeranto/bundles/node/allTests/src/PM/__tests__/webSidecar.testeranto.mjs +2 -1
- package/testeranto/bundles/node/allTests/src/Pure.test.mjs +261 -0
- package/testeranto/bundles/node/allTests/src/lib/BaseSuite.test.mjs +22 -4
- package/testeranto/bundles/node/allTests/src/lib/baseBuilder.test/baseBuilder.test.mjs +226 -0
- package/testeranto/bundles/node/allTests/src/lib/classBuilder.test/classBuilder.test.mjs +406 -0
- package/testeranto/bundles/node/allTests/src/lib/core.test/core.test.mjs +279 -0
- package/testeranto/bundles/node/allTests/src/lib/pmProxy.test/index.mjs +4479 -0
- package/testeranto/bundles/node/allTests/src/mothership/test.mjs +4 -2
- package/testeranto/reports/allTests/config.json +40 -1
- package/testeranto/reports/allTests/src/PM/__tests__/nodeSidecar.testeranto/node/console_log.txt +0 -0
- package/testeranto/reports/allTests/src/PM/__tests__/nodeSidecar.testeranto/node/log.txt +0 -0
- package/testeranto/reports/allTests/src/Pure.test/node/console_log.txt +17 -0
- package/testeranto/reports/allTests/src/Pure.test/node/dev.html +21 -0
- package/testeranto/reports/allTests/src/Pure.test/node/index.html +21 -0
- package/testeranto/reports/allTests/src/Pure.test/node/lint_errors.json +134 -0
- package/testeranto/reports/allTests/src/Pure.test/node/message +1 -0
- package/testeranto/reports/allTests/src/Pure.test/node/prompt.txt +7 -0
- package/testeranto/reports/allTests/src/Pure.test/node/type_errors.txt +26 -0
- package/testeranto/reports/allTests/src/lib/BaseGiven.test/node/dev.html +21 -0
- package/testeranto/reports/allTests/src/lib/BaseGiven.test/node/index.html +21 -0
- package/testeranto/reports/allTests/src/lib/BaseSuite.test/node/console_log.txt +27 -27
- package/testeranto/reports/allTests/src/lib/BaseSuite.test/node/lint_errors.json +104 -104
- package/testeranto/reports/allTests/src/lib/BaseSuite.test/node/type_errors.txt +47 -22
- package/testeranto/reports/allTests/src/lib/BaseThen.test/node/dev.html +21 -0
- package/testeranto/reports/allTests/src/lib/BaseThen.test/node/index.html +21 -0
- package/testeranto/reports/allTests/src/lib/BaseWhen.test/node/dev.html +21 -0
- package/testeranto/reports/allTests/src/lib/BaseWhen.test/node/index.html +21 -0
- package/testeranto/reports/allTests/src/lib/abstractBase/index/node/dev.html +21 -0
- package/testeranto/reports/allTests/src/lib/abstractBase/index/node/index.html +21 -0
- package/testeranto/reports/allTests/src/lib/baseBuilder/baseBuilder.test/node/dev.html +21 -0
- package/testeranto/reports/allTests/src/lib/baseBuilder/baseBuilder.test/node/index.html +21 -0
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test/node/console_log.txt +12 -0
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test/node/dev.html +21 -0
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test/node/index.html +21 -0
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test/node/lint_errors.json +966 -0
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test/node/message +1 -0
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test/node/prompt.txt +11 -0
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test/node/type_errors.txt +52 -0
- package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/console_log.txt +17 -0
- package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/dev.html +21 -0
- package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/index.html +21 -0
- package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/lint_errors.json +771 -0
- package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/message +1 -0
- package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/prompt.txt +11 -0
- package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/type_errors.txt +67 -0
- package/testeranto/reports/allTests/src/lib/core.test/core.test/node/console_log.txt +17 -0
- package/testeranto/reports/allTests/src/lib/core.test/core.test/node/dev.html +21 -0
- package/testeranto/reports/allTests/src/lib/core.test/core.test/node/index.html +21 -0
- package/testeranto/reports/allTests/src/lib/core.test/core.test/node/lint_errors.json +416 -0
- package/testeranto/reports/allTests/src/lib/core.test/core.test/node/message +1 -0
- package/testeranto/reports/allTests/src/lib/core.test/core.test/node/prompt.txt +11 -0
- package/testeranto/reports/allTests/src/lib/core.test/core.test/node/type_errors.txt +54 -0
- package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/console_log.txt +43 -0
- package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/dev.html +21 -0
- package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/index.html +21 -0
- package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/lint_errors.json +319 -0
- package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/log.txt +0 -0
- package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/message +1 -0
- package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/prompt.txt +10 -0
- package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/type_errors.txt +64 -0
- package/testeranto/reports/allTests/src/mothership/test/node/console_log.txt +44 -0
- package/testeranto/reports/allTests/src/mothership/test/node/log.txt +0 -0
- package/testeranto/reports/allTests/summary.json +76 -6
- package/testeranto/reportsnode_build_errors +12 -0
- package/testeranto.config.ts +19 -2
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { Browser } from "puppeteer-core";
|
|
2
|
+
|
|
3
|
+
import { IBuiltConfig, ITLog } from "../index";
|
|
4
|
+
import { PM_Base } from "../../PM/base";
|
|
5
|
+
|
|
6
|
+
export class MockPMBase implements PM_Base {
|
|
7
|
+
browser: Browser;
|
|
8
|
+
configs: IBuiltConfig;
|
|
9
|
+
calls: Record<string, any[]> = {};
|
|
10
|
+
testResourceConfiguration: any = {};
|
|
11
|
+
|
|
12
|
+
constructor(configs?: IBuiltConfig) {
|
|
13
|
+
this.configs = configs || ({} as IBuiltConfig);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Common tracking functionality
|
|
17
|
+
protected trackCall(method: string, args: any) {
|
|
18
|
+
if (!this.calls[method]) {
|
|
19
|
+
this.calls[method] = [];
|
|
20
|
+
}
|
|
21
|
+
this.calls[method].push(args);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
getCallCount(method: string): number {
|
|
25
|
+
return this.calls[method]?.length || 0;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
getLastCall(method: string): any {
|
|
29
|
+
const calls = this.calls[method];
|
|
30
|
+
return calls ? calls[calls.length - 1] : null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Minimal implementations of required methods
|
|
34
|
+
launchSideCar(n: number, testName: string, projectName: string) {
|
|
35
|
+
this.trackCall("launchSideCar", { n, testName, projectName });
|
|
36
|
+
return Promise.resolve();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
end(uid: number): Promise<boolean> {
|
|
40
|
+
this.trackCall("end", { uid });
|
|
41
|
+
return Promise.resolve(true);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
writeFileSync(
|
|
45
|
+
path: string,
|
|
46
|
+
content: string,
|
|
47
|
+
testName?: string
|
|
48
|
+
): Promise<boolean> {
|
|
49
|
+
this.trackCall("writeFileSync", { path, content, testName });
|
|
50
|
+
return Promise.resolve(true);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
createWriteStream(path: string, testName?: string): Promise<number> {
|
|
54
|
+
this.trackCall("createWriteStream", { path, testName });
|
|
55
|
+
return Promise.resolve(0);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
screencast(opts: any, testName: string, page?: any): Promise<any> {
|
|
59
|
+
this.trackCall("screencast", { opts, testName, page });
|
|
60
|
+
return Promise.resolve({});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
customScreenShot(opts: any, testName: string, pageUid?: any): Promise<any> {
|
|
64
|
+
this.trackCall("customScreenShot", { opts, testName, pageUid });
|
|
65
|
+
return Promise.resolve({});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
testArtiFactoryfileWriter(
|
|
69
|
+
tLog: ITLog,
|
|
70
|
+
callback: (Promise: any) => void
|
|
71
|
+
): any {
|
|
72
|
+
return (fPath: string, value: string | Buffer | any) => {
|
|
73
|
+
this.trackCall("testArtiFactoryfileWriter", { fPath, value });
|
|
74
|
+
callback(Promise.resolve());
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Other required PM_Base methods with minimal implementations
|
|
79
|
+
closePage(p: any): any {
|
|
80
|
+
return Promise.resolve();
|
|
81
|
+
}
|
|
82
|
+
$(selector: string, p: string): Promise<any> {
|
|
83
|
+
return Promise.resolve();
|
|
84
|
+
}
|
|
85
|
+
click(selector: string, page: any): any {
|
|
86
|
+
return Promise.resolve();
|
|
87
|
+
}
|
|
88
|
+
goto(p: string, url: string): any {
|
|
89
|
+
return Promise.resolve();
|
|
90
|
+
}
|
|
91
|
+
newPage(): Promise<string> {
|
|
92
|
+
return Promise.resolve("mock-page");
|
|
93
|
+
}
|
|
94
|
+
pages(): Promise<string[]> {
|
|
95
|
+
return Promise.resolve(["mock-page"]);
|
|
96
|
+
}
|
|
97
|
+
waitForSelector(p: string, s: string): any {
|
|
98
|
+
return Promise.resolve(true);
|
|
99
|
+
}
|
|
100
|
+
focusOn(selector: string, p: string): any {
|
|
101
|
+
return Promise.resolve();
|
|
102
|
+
}
|
|
103
|
+
typeInto(value: string, p: string): any {
|
|
104
|
+
return Promise.resolve();
|
|
105
|
+
}
|
|
106
|
+
getAttribute(selector: string, attribute: string, p: string): any {
|
|
107
|
+
return Promise.resolve();
|
|
108
|
+
}
|
|
109
|
+
getInnerHtml(selector: string, p: string): Promise<any> {
|
|
110
|
+
return Promise.resolve();
|
|
111
|
+
}
|
|
112
|
+
isDisabled(selector: string, p: string): any {
|
|
113
|
+
return Promise.resolve(false);
|
|
114
|
+
}
|
|
115
|
+
screencastStop(s: string): any {
|
|
116
|
+
return Promise.resolve();
|
|
117
|
+
}
|
|
118
|
+
existsSync(destFolder: string): boolean {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
mkdirSync(fp: string): any {
|
|
122
|
+
return Promise.resolve();
|
|
123
|
+
}
|
|
124
|
+
write(uid: number, contents: string): Promise<boolean> {
|
|
125
|
+
return Promise.resolve(true);
|
|
126
|
+
}
|
|
127
|
+
page(p: any): string | undefined {
|
|
128
|
+
return "mock-page";
|
|
129
|
+
}
|
|
130
|
+
doInPage(p: string, cb: (p: any) => unknown): any {
|
|
131
|
+
return Promise.resolve();
|
|
132
|
+
}
|
|
133
|
+
customclose(): any {
|
|
134
|
+
return Promise.resolve();
|
|
135
|
+
}
|
|
136
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { I, O } from "./types";
|
|
2
|
+
import { ITestSpecification } from "../../CoreTypes";
|
|
3
|
+
|
|
4
|
+
export const specification: ITestSpecification<I, O> = (
|
|
5
|
+
Suite,
|
|
6
|
+
Given,
|
|
7
|
+
When,
|
|
8
|
+
Then,
|
|
9
|
+
Check
|
|
10
|
+
) => [
|
|
11
|
+
Suite.Default("PM Proxy Functionality", {
|
|
12
|
+
// Basic path rewriting tests
|
|
13
|
+
writeFileProxyTest: Given.SomeBaseString(
|
|
14
|
+
["butThenProxy should rewrite writeFileSync paths"],
|
|
15
|
+
[],
|
|
16
|
+
[Then.theButTheProxyReturns("writeFileSync", "test/path/butThen/test.txt")],
|
|
17
|
+
"writeFileSync test"
|
|
18
|
+
),
|
|
19
|
+
createWriteStreamProxyTest: Given.SomeBaseString(
|
|
20
|
+
["butThenProxy should rewrite createWriteStream paths"],
|
|
21
|
+
[],
|
|
22
|
+
[Then.theButTheProxyReturns("createWriteStream", "test/path/butThen/stream.txt")],
|
|
23
|
+
"createWriteStream test"
|
|
24
|
+
),
|
|
25
|
+
screencastProxyTest: Given.SomeBaseString(
|
|
26
|
+
["butThenProxy should rewrite screencast paths"],
|
|
27
|
+
[],
|
|
28
|
+
[Then.theButTheProxyReturns("screencast", "test/path/butThen/screen.png")],
|
|
29
|
+
"screencast test"
|
|
30
|
+
),
|
|
31
|
+
customScreenShotProxyTest: Given.SomeBaseString(
|
|
32
|
+
["butThenProxy should rewrite customScreenShot paths"],
|
|
33
|
+
[],
|
|
34
|
+
[Then.theButTheProxyReturns("customScreenShot", "test/path/butThen/shot.png")],
|
|
35
|
+
"customScreenShot test"
|
|
36
|
+
),
|
|
37
|
+
|
|
38
|
+
// Edge cases
|
|
39
|
+
emptyPathTest: Given.SomeBaseString(
|
|
40
|
+
["butThenProxy should handle empty paths"],
|
|
41
|
+
[],
|
|
42
|
+
[Then.theButTheProxyReturns("writeFileSync", "test/path/butThen/")],
|
|
43
|
+
"empty path test"
|
|
44
|
+
),
|
|
45
|
+
nestedPathTest: Given.SomeBaseString(
|
|
46
|
+
["butThenProxy should handle nested paths"],
|
|
47
|
+
[],
|
|
48
|
+
[Then.theButTheProxyReturns("writeFileSync", "test/path/butThen/nested/folder/test.txt")],
|
|
49
|
+
"nested path test"
|
|
50
|
+
),
|
|
51
|
+
specialCharsTest: Given.SomeBaseString(
|
|
52
|
+
["butThenProxy should handle special characters in paths"],
|
|
53
|
+
[],
|
|
54
|
+
[Then.theButTheProxyReturns("writeFileSync", "test/path/butThen/file with spaces.txt")],
|
|
55
|
+
"special chars test"
|
|
56
|
+
),
|
|
57
|
+
}),
|
|
58
|
+
|
|
59
|
+
Suite.Default("Proxy Type Coverage", {
|
|
60
|
+
// Test all proxy types
|
|
61
|
+
butThenProxyTest: Given.SomeBaseString(
|
|
62
|
+
["butThenProxy should work correctly"],
|
|
63
|
+
[],
|
|
64
|
+
[Then.theButTheProxyReturns("writeFileSync", "test/path/butThen/test.txt")],
|
|
65
|
+
"butThenProxy test"
|
|
66
|
+
),
|
|
67
|
+
andWhenProxyTest: Given.SomeBaseString(
|
|
68
|
+
["andWhenProxy should work correctly"],
|
|
69
|
+
[],
|
|
70
|
+
[Then.theButTheProxyReturns("writeFileSync", "test/path/andWhen/test.txt")],
|
|
71
|
+
"andWhenProxy test"
|
|
72
|
+
),
|
|
73
|
+
beforeEachProxyTest: Given.SomeBaseString(
|
|
74
|
+
["beforeEachProxy should work correctly"],
|
|
75
|
+
[],
|
|
76
|
+
[Then.theButTheProxyReturns("writeFileSync", "suite-1/beforeEach/test.txt")],
|
|
77
|
+
"beforeEachProxy test"
|
|
78
|
+
),
|
|
79
|
+
afterEachProxyTest: Given.SomeBaseString(
|
|
80
|
+
["afterEachProxy should work correctly"],
|
|
81
|
+
[],
|
|
82
|
+
[Then.theButTheProxyReturns("writeFileSync", "suite-1/given-1/afterEach/test.txt")],
|
|
83
|
+
"afterEachProxy test"
|
|
84
|
+
),
|
|
85
|
+
}),
|
|
86
|
+
|
|
87
|
+
Suite.Default("Content Preservation", {
|
|
88
|
+
// Verify content is preserved
|
|
89
|
+
contentPreservationTest: Given.SomeBaseString(
|
|
90
|
+
["Proxies should preserve file content"],
|
|
91
|
+
[],
|
|
92
|
+
[
|
|
93
|
+
Then.theButTheProxyReturns("writeFileSync", "test/path/butThen/test.txt"),
|
|
94
|
+
Then.verifyContent("test content")
|
|
95
|
+
],
|
|
96
|
+
"content preservation test"
|
|
97
|
+
),
|
|
98
|
+
objectContentTest: Given.SomeBaseString(
|
|
99
|
+
["Proxies should preserve object content"],
|
|
100
|
+
[],
|
|
101
|
+
[
|
|
102
|
+
Then.theButTheProxyReturns("screencast", "test/path/butThen/screen.png"),
|
|
103
|
+
Then.verifyContent({quality: 80, fullPage: true})
|
|
104
|
+
],
|
|
105
|
+
"object content test"
|
|
106
|
+
),
|
|
107
|
+
}),
|
|
108
|
+
|
|
109
|
+
Suite.Default("Error Cases", {
|
|
110
|
+
invalidPathTest: Given.SomeBaseString(
|
|
111
|
+
["Proxies should handle invalid paths"],
|
|
112
|
+
[],
|
|
113
|
+
[Then.theButTheProxyReturns("writeFileSync", "test/path/butThen/../invalid.txt")],
|
|
114
|
+
"invalid path test"
|
|
115
|
+
),
|
|
116
|
+
undefinedInputTest: Given.SomeBaseString(
|
|
117
|
+
["Proxies should handle undefined inputs"],
|
|
118
|
+
[],
|
|
119
|
+
[Then.theButTheProxyReturns("writeFileSync", undefined)],
|
|
120
|
+
"undefined input test"
|
|
121
|
+
),
|
|
122
|
+
}),
|
|
123
|
+
];
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ITestProxies } from ".";
|
|
2
|
+
import { Ibdd_in, Ibdd_out } from "../../CoreTypes";
|
|
3
|
+
|
|
4
|
+
import { IProxiedFunctions, IProxy } from "../pmProxy";
|
|
5
|
+
import { IPM } from "../types";
|
|
6
|
+
|
|
7
|
+
export type I = Ibdd_in<
|
|
8
|
+
{ butThenProxy: IProxy },
|
|
9
|
+
{ proxies: ITestProxies; filepath: string; mockPm: IPM },
|
|
10
|
+
{ butThenProxy: IProxy },
|
|
11
|
+
// { butThenProxy: IProxy },
|
|
12
|
+
|
|
13
|
+
{ proxies: ITestProxies; filepath: string; mockPm: IPM },
|
|
14
|
+
[string, string],
|
|
15
|
+
(
|
|
16
|
+
...args: any[]
|
|
17
|
+
) => (proxies: { butThenProxy: IProxy }) => { butThenProxy: IProxy },
|
|
18
|
+
[IPM, "string"]
|
|
19
|
+
>;
|
|
20
|
+
|
|
21
|
+
export type O = Ibdd_out<
|
|
22
|
+
{ Default: [string] },
|
|
23
|
+
{ SomeBaseString: [string] },
|
|
24
|
+
{}, // No Whens for pure functions
|
|
25
|
+
{
|
|
26
|
+
theButTheProxyReturns: [IProxiedFunctions, string];
|
|
27
|
+
},
|
|
28
|
+
{ Default: [] }
|
|
29
|
+
>;
|
|
30
|
+
|
|
31
|
+
export type M = {
|
|
32
|
+
givens: {
|
|
33
|
+
[K in keyof O["givens"]]: (...Iw: O["givens"][K]) => string;
|
|
34
|
+
};
|
|
35
|
+
// whens: {
|
|
36
|
+
// [K in keyof O["whens"]]: (
|
|
37
|
+
// ...Iw: O["whens"][K]
|
|
38
|
+
// ) => (rectangle: Rectangle, utils: PM) => Rectangle;
|
|
39
|
+
// };
|
|
40
|
+
// thens: {
|
|
41
|
+
// [K in keyof O["thens"]]: (
|
|
42
|
+
// ...Iw: O["thens"][K]
|
|
43
|
+
// ) => (rectangle: Rectangle, utils: PM) => Rectangle;
|
|
44
|
+
// };
|
|
45
|
+
};
|
package/src/lib/pmProxy.ts
CHANGED
|
@@ -1,8 +1,27 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
|
+
|
|
3
4
|
import { IPM } from "./types";
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
export type IProxyBase = (
|
|
7
|
+
pm: IPM,
|
|
8
|
+
mappings: [string, (...x: any) => any][]
|
|
9
|
+
) => IPM;
|
|
10
|
+
|
|
11
|
+
export type IProxy = (pm: IPM, filepath: string) => IPM;
|
|
12
|
+
export type IProxyAfterEach = (pm: IPM, suite: string, given: string) => IPM;
|
|
13
|
+
export type IProxyBeforeEach = (pm: IPM, suite: string) => IPM;
|
|
14
|
+
|
|
15
|
+
export type IProxiedFunctions =
|
|
16
|
+
| "screencast"
|
|
17
|
+
| "createWriteStream"
|
|
18
|
+
| "writeFileSync"
|
|
19
|
+
| "customScreenShot";
|
|
20
|
+
|
|
21
|
+
const baseProxy: IProxyBase = function (
|
|
22
|
+
pm: IPM,
|
|
23
|
+
mappings: [IProxiedFunctions, (...x) => any][]
|
|
24
|
+
) {
|
|
6
25
|
return new Proxy(pm, {
|
|
7
26
|
get: (target, prop, receiver) => {
|
|
8
27
|
for (const mapping of mappings) {
|
|
@@ -10,7 +29,7 @@ const prxy = function (pm: IPM, mappings: [string, (...x) => any][]) {
|
|
|
10
29
|
const arger = mapping[1];
|
|
11
30
|
|
|
12
31
|
if (prop === method) {
|
|
13
|
-
return (...x) => target[prop](arger(...x));
|
|
32
|
+
return (...x) => (target[prop] as any)(arger(...x));
|
|
14
33
|
}
|
|
15
34
|
}
|
|
16
35
|
|
|
@@ -19,8 +38,8 @@ const prxy = function (pm: IPM, mappings: [string, (...x) => any][]) {
|
|
|
19
38
|
});
|
|
20
39
|
};
|
|
21
40
|
|
|
22
|
-
export const butThenProxy = (pm: IPM, filepath: string) =>
|
|
23
|
-
|
|
41
|
+
export const butThenProxy: IProxy = (pm: IPM, filepath: string) =>
|
|
42
|
+
baseProxy(pm, [
|
|
24
43
|
[
|
|
25
44
|
"screencast",
|
|
26
45
|
(opts, p) => [
|
|
@@ -51,8 +70,8 @@ export const butThenProxy = (pm: IPM, filepath: string) =>
|
|
|
51
70
|
],
|
|
52
71
|
]);
|
|
53
72
|
|
|
54
|
-
export const andWhenProxy = (pm: IPM, filepath: string) =>
|
|
55
|
-
|
|
73
|
+
export const andWhenProxy: IProxy = (pm: IPM, filepath: string) =>
|
|
74
|
+
baseProxy(pm, [
|
|
56
75
|
[
|
|
57
76
|
"screencast",
|
|
58
77
|
(opts, p) => [
|
|
@@ -80,8 +99,12 @@ export const andWhenProxy = (pm: IPM, filepath: string) =>
|
|
|
80
99
|
],
|
|
81
100
|
]);
|
|
82
101
|
|
|
83
|
-
export const afterEachProxy = (
|
|
84
|
-
|
|
102
|
+
export const afterEachProxy: IProxyAfterEach = (
|
|
103
|
+
pm: IPM,
|
|
104
|
+
suite: string,
|
|
105
|
+
given: string
|
|
106
|
+
): IPM =>
|
|
107
|
+
baseProxy(pm, [
|
|
85
108
|
[
|
|
86
109
|
"screencast",
|
|
87
110
|
(opts, p) => [
|
|
@@ -114,8 +137,11 @@ export const afterEachProxy = (pm: IPM, suite: string, given: string): IPM =>
|
|
|
114
137
|
],
|
|
115
138
|
]);
|
|
116
139
|
|
|
117
|
-
export const beforeEachProxy = (
|
|
118
|
-
|
|
140
|
+
export const beforeEachProxy: IProxyBeforeEach = (
|
|
141
|
+
pm: IPM,
|
|
142
|
+
suite: string
|
|
143
|
+
): IPM =>
|
|
144
|
+
baseProxy(pm, [
|
|
119
145
|
[
|
|
120
146
|
"screencast",
|
|
121
147
|
(opts, p) => [
|
|
@@ -146,8 +172,8 @@ export const beforeEachProxy = (pm: IPM, suite: string): IPM =>
|
|
|
146
172
|
["createWriteStream", (fp) => [`suite-${suite}/beforeEach/${fp}`]],
|
|
147
173
|
]);
|
|
148
174
|
|
|
149
|
-
export const beforeAllProxy = (pm: IPM, suite: string): IPM =>
|
|
150
|
-
|
|
175
|
+
export const beforeAllProxy: IProxy = (pm: IPM, suite: string): IPM =>
|
|
176
|
+
baseProxy(pm, [
|
|
151
177
|
[
|
|
152
178
|
"writeFileSync",
|
|
153
179
|
(fp, contents) => [`suite-${suite}/beforeAll/${fp}`, contents],
|
|
@@ -167,8 +193,8 @@ export const beforeAllProxy = (pm: IPM, suite: string): IPM =>
|
|
|
167
193
|
["createWriteStream", (fp) => [`suite-${suite}/beforeAll/${fp}`]],
|
|
168
194
|
]);
|
|
169
195
|
|
|
170
|
-
export const afterAllProxy = (pm: IPM, suite: string): IPM =>
|
|
171
|
-
|
|
196
|
+
export const afterAllProxy: IProxy = (pm: IPM, suite: string): IPM =>
|
|
197
|
+
baseProxy(pm, [
|
|
172
198
|
["createWriteStream", (fp) => [`suite-${suite}/afterAll/${fp}`]],
|
|
173
199
|
|
|
174
200
|
[
|
|
@@ -187,182 +213,3 @@ export const afterAllProxy = (pm: IPM, suite: string): IPM =>
|
|
|
187
213
|
],
|
|
188
214
|
],
|
|
189
215
|
]);
|
|
190
|
-
|
|
191
|
-
/////////////////////////////////////////////////
|
|
192
|
-
|
|
193
|
-
// export const butThenProxy = (pm: IPM, filepath: string) => {
|
|
194
|
-
// return new Proxy(pm, {
|
|
195
|
-
// get: (target, prop, receiver) => {
|
|
196
|
-
// if (prop === "customScreenShot") {
|
|
197
|
-
// return (opts, p) =>
|
|
198
|
-
// target.customScreenShot(
|
|
199
|
-
// {
|
|
200
|
-
// ...opts,
|
|
201
|
-
// path: `${filepath}/${opts.path}`,
|
|
202
|
-
// },
|
|
203
|
-
// p
|
|
204
|
-
// );
|
|
205
|
-
// }
|
|
206
|
-
|
|
207
|
-
// if (prop === "writeFileSync") {
|
|
208
|
-
// return (fp, contents) => target[prop](`${filepath}/${fp}`, contents);
|
|
209
|
-
// }
|
|
210
|
-
// },
|
|
211
|
-
// });
|
|
212
|
-
// };
|
|
213
|
-
|
|
214
|
-
// export const andWhenProxy = (pm: IPM, filepath: string) => {
|
|
215
|
-
// return new Proxy(pm, {
|
|
216
|
-
// get(target, prop, receiver) {
|
|
217
|
-
// if (prop === "customScreenShot") {
|
|
218
|
-
// return (opts, p) =>
|
|
219
|
-
// target.customScreenShot(
|
|
220
|
-
// {
|
|
221
|
-
// ...opts,
|
|
222
|
-
// path: `${filepath}/${opts.path}`,
|
|
223
|
-
// },
|
|
224
|
-
// p
|
|
225
|
-
// );
|
|
226
|
-
// }
|
|
227
|
-
// if (prop === "writeFileSync") {
|
|
228
|
-
// return (fp, contents) =>
|
|
229
|
-
// target[prop](`${filepath}/andWhen/${fp}`, contents);
|
|
230
|
-
// }
|
|
231
|
-
|
|
232
|
-
// /* @ts-ignore:next-line */
|
|
233
|
-
// return Reflect.get(...arguments);
|
|
234
|
-
// },
|
|
235
|
-
// });
|
|
236
|
-
// };
|
|
237
|
-
|
|
238
|
-
// export const afterEachProxy = (pm: IPM, suite: string, given: string): IPM => {
|
|
239
|
-
// return new Proxy(pm, {
|
|
240
|
-
// get(target, prop, receiver) {
|
|
241
|
-
// if (prop === "customScreenShot") {
|
|
242
|
-
// return (opts, p) =>
|
|
243
|
-
// target.customScreenShot(
|
|
244
|
-
// {
|
|
245
|
-
// ...opts,
|
|
246
|
-
// path: `suite-${suite}/given-${given}/afterEach/${opts.path}`,
|
|
247
|
-
// },
|
|
248
|
-
// p
|
|
249
|
-
// );
|
|
250
|
-
// }
|
|
251
|
-
|
|
252
|
-
// if (prop === "writeFileSync") {
|
|
253
|
-
// return (fp, contents) =>
|
|
254
|
-
// target[prop](
|
|
255
|
-
// `suite-${suite}/given-${given}/afterEach/${fp}`,
|
|
256
|
-
// contents
|
|
257
|
-
// );
|
|
258
|
-
// }
|
|
259
|
-
|
|
260
|
-
// /* @ts-ignore:next-line */
|
|
261
|
-
// return Reflect.get(...arguments);
|
|
262
|
-
// },
|
|
263
|
-
// });
|
|
264
|
-
// };
|
|
265
|
-
|
|
266
|
-
// export const beforeAllProxy = (pm: IPM, suite: string): IPM => {
|
|
267
|
-
// return new Proxy(pm, {
|
|
268
|
-
// get(target, prop, receiver) {
|
|
269
|
-
// if (prop === "customScreenShot") {
|
|
270
|
-
// return (opts, p) =>
|
|
271
|
-
// target.customScreenShot(
|
|
272
|
-
// {
|
|
273
|
-
// ...opts,
|
|
274
|
-
// // path: `${filepath}/${opts.path}`,
|
|
275
|
-
// path: `suite-${suite}/beforeAll/${opts.path}`,
|
|
276
|
-
// },
|
|
277
|
-
// p
|
|
278
|
-
// );
|
|
279
|
-
// }
|
|
280
|
-
|
|
281
|
-
// if (prop === "writeFileSync") {
|
|
282
|
-
// return (fp, contents) =>
|
|
283
|
-
// target[prop](`suite-${suite}/beforeAll/${fp}`, contents);
|
|
284
|
-
// }
|
|
285
|
-
|
|
286
|
-
// /* @ts-ignore:next-line */
|
|
287
|
-
// return Reflect.get(...arguments);
|
|
288
|
-
// },
|
|
289
|
-
// });
|
|
290
|
-
// };
|
|
291
|
-
|
|
292
|
-
// export const beforeEachProxy = (pm: IPM, suite: string, given: string): IPM => {
|
|
293
|
-
// return new Proxy(pm, {
|
|
294
|
-
// get(target, prop, receiver) {
|
|
295
|
-
// // if (prop === "write") {
|
|
296
|
-
// // return (handle, contents) =>
|
|
297
|
-
// // target[prop](
|
|
298
|
-
// // `suite-${suiteNdx}/given-${key}/when/beforeEach/${fp}`,
|
|
299
|
-
// // contents
|
|
300
|
-
// // );
|
|
301
|
-
// // }
|
|
302
|
-
|
|
303
|
-
// if (prop === "createWriteStream") {
|
|
304
|
-
// return (fp) =>
|
|
305
|
-
// target[prop](`suite-${suite}/given-${given}/when/beforeEach/${fp}`);
|
|
306
|
-
// }
|
|
307
|
-
|
|
308
|
-
// if (prop === "writeFileSync") {
|
|
309
|
-
// return (fp, contents) =>
|
|
310
|
-
// target[prop](
|
|
311
|
-
// `suite-${suite}/given-${given}/when/beforeEach/${fp}`,
|
|
312
|
-
// contents
|
|
313
|
-
// );
|
|
314
|
-
// }
|
|
315
|
-
|
|
316
|
-
// if (prop === "customScreenShot") {
|
|
317
|
-
// return (opts, p) =>
|
|
318
|
-
// target.customScreenShot(
|
|
319
|
-
// {
|
|
320
|
-
// ...opts,
|
|
321
|
-
// path: `suite-${suite}/given-${given}/when/beforeEach/${opts.path}`,
|
|
322
|
-
// },
|
|
323
|
-
// p
|
|
324
|
-
// );
|
|
325
|
-
// }
|
|
326
|
-
|
|
327
|
-
// if (prop === "screencast") {
|
|
328
|
-
// return (opts, p) =>
|
|
329
|
-
// target.screencast(
|
|
330
|
-
// {
|
|
331
|
-
// ...opts,
|
|
332
|
-
// path: `suite-${suite}/given-${given}/when/beforeEach/${opts.path}`,
|
|
333
|
-
// },
|
|
334
|
-
// p
|
|
335
|
-
// );
|
|
336
|
-
// }
|
|
337
|
-
|
|
338
|
-
// /* @ts-ignore:next-line */
|
|
339
|
-
// return Reflect.get(...arguments);
|
|
340
|
-
// },
|
|
341
|
-
// });
|
|
342
|
-
// };
|
|
343
|
-
|
|
344
|
-
// export const afterAllProxy = (pm: IPM, suite: string): IPM => {
|
|
345
|
-
// return new Proxy(pm, {
|
|
346
|
-
// get(target, prop, receiver) {
|
|
347
|
-
// if (prop === "customScreenShot") {
|
|
348
|
-
// return (opts, p) =>
|
|
349
|
-
// target.customScreenShot(
|
|
350
|
-
// {
|
|
351
|
-
// ...opts,
|
|
352
|
-
// // path: `${filepath}/${opts.path}`,
|
|
353
|
-
// path: `suite-${suite}/afterAll/${opts.path}`,
|
|
354
|
-
// },
|
|
355
|
-
// p
|
|
356
|
-
// );
|
|
357
|
-
// }
|
|
358
|
-
|
|
359
|
-
// if (prop === "writeFileSync") {
|
|
360
|
-
// return (fp, contents) =>
|
|
361
|
-
// target[prop](`suite-${suite}/afterAll/${fp}`, contents);
|
|
362
|
-
// }
|
|
363
|
-
|
|
364
|
-
// /* @ts-ignore:next-line */
|
|
365
|
-
// return Reflect.get(...arguments);
|
|
366
|
-
// },
|
|
367
|
-
// });
|
|
368
|
-
// };
|