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.
Files changed (133) hide show
  1. package/bundle.js +4 -7
  2. package/dist/common/src/Node.js +5 -3
  3. package/dist/common/src/PM/main.js +254 -126
  4. package/dist/common/src/PM/node.js +20 -5
  5. package/dist/common/src/PM/web.js +19 -4
  6. package/dist/common/src/SubPackages/puppeteer.js +1 -1
  7. package/dist/common/src/SubPackages/react/jsx/index.js +14 -6
  8. package/dist/common/src/SubPackages/react/jsx/node.js +2 -2
  9. package/dist/common/src/SubPackages/react-dom/component/web.js +13 -39
  10. package/dist/common/src/SubPackages/react-test-renderer/component/interface.js +2 -10
  11. package/dist/common/src/Web.js +25 -21
  12. package/dist/common/src/cli.js +439 -0
  13. package/dist/common/src/cli2.js +144 -0
  14. package/dist/common/src/esbuildConfigs/inputFilesPlugin.js +18 -8
  15. package/dist/common/src/esbuildConfigs/node.js +1 -4
  16. package/dist/common/src/esbuildConfigs/web.js +1 -1
  17. package/dist/common/src/lib/abstractBase.js +31 -263
  18. package/dist/common/src/lib/basebuilder.js +1 -11
  19. package/dist/common/src/lib/classBuilder.js +1 -1
  20. package/dist/common/src/lib/core.js +8 -28
  21. package/dist/common/src/lib/types.js +1 -0
  22. package/dist/common/tsconfig.common.tsbuildinfo +1 -1
  23. package/dist/module/src/Node.js +5 -3
  24. package/dist/module/src/PM/main.js +254 -126
  25. package/dist/module/src/PM/node.js +20 -5
  26. package/dist/module/src/PM/web.js +19 -4
  27. package/dist/module/src/SubPackages/puppeteer.js +1 -1
  28. package/dist/module/src/SubPackages/react/jsx/index.js +14 -6
  29. package/dist/module/src/SubPackages/react/jsx/node.js +2 -2
  30. package/dist/module/src/SubPackages/react-dom/component/web.js +13 -39
  31. package/dist/module/src/SubPackages/react-test-renderer/component/interface.js +2 -10
  32. package/dist/module/src/Web.js +25 -21
  33. package/dist/module/src/cli.js +411 -0
  34. package/dist/module/src/cli2.js +116 -0
  35. package/dist/module/src/esbuildConfigs/inputFilesPlugin.js +18 -8
  36. package/dist/module/src/esbuildConfigs/node.js +1 -4
  37. package/dist/module/src/esbuildConfigs/web.js +1 -1
  38. package/dist/module/src/lib/abstractBase.js +31 -263
  39. package/dist/module/src/lib/basebuilder.js +1 -11
  40. package/dist/module/src/lib/classBuilder.js +1 -1
  41. package/dist/module/src/lib/core.js +8 -28
  42. package/dist/module/src/lib/types.js +1 -0
  43. package/dist/module/tsconfig.module.tsbuildinfo +1 -1
  44. package/dist/prebuild/cli.mjs +1491 -0
  45. package/dist/prebuild/{run-tests.mjs → cli2.mjs} +223 -212
  46. package/dist/types/src/Node.d.ts +6 -3
  47. package/dist/types/src/PM/index.d.ts +10 -2
  48. package/dist/types/src/PM/main.d.ts +14 -7
  49. package/dist/types/src/PM/node.d.ts +9 -2
  50. package/dist/types/src/PM/web.d.ts +9 -3
  51. package/dist/types/src/SubPackages/puppeteer.d.ts +1 -1
  52. package/dist/types/src/SubPackages/react/component/node.d.ts +1 -1
  53. package/dist/types/src/SubPackages/react/component/web.d.ts +1 -1
  54. package/dist/types/src/SubPackages/react/jsx/node.d.ts +3 -3
  55. package/dist/types/src/SubPackages/react/jsx/web.d.ts +2 -2
  56. package/dist/types/src/SubPackages/react-dom/component/node.d.ts +2 -2
  57. package/dist/types/src/SubPackages/react-dom/component/web.d.ts +1 -1
  58. package/dist/types/src/SubPackages/react-dom/jsx/node.d.ts +1 -1
  59. package/dist/types/src/SubPackages/react-dom/jsx/web.d.ts +2 -2
  60. package/dist/types/src/SubPackages/react-test-renderer/MemoExoticComponent/node.d.ts +2 -2
  61. package/dist/types/src/SubPackages/react-test-renderer/component/interface.d.ts +1 -1
  62. package/dist/types/src/SubPackages/react-test-renderer/component/node.d.ts +2 -2
  63. package/dist/types/src/SubPackages/react-test-renderer/component/web.d.ts +2 -2
  64. package/dist/types/src/SubPackages/react-test-renderer/fc/node.d.ts +2 -2
  65. package/dist/types/src/SubPackages/react-test-renderer/fc/web.d.ts +2 -2
  66. package/dist/types/src/SubPackages/react-test-renderer/jsx/node.d.ts +3 -2
  67. package/dist/types/src/SubPackages/react-test-renderer/jsx/web.d.ts +2 -2
  68. package/dist/types/src/SubPackages/react-test-renderer/jsx-promised/node.d.ts +2 -2
  69. package/dist/types/src/SubPackages/react-test-renderer/jsx-promised/web.d.ts +2 -2
  70. package/dist/types/src/Types.d.ts +60 -21
  71. package/dist/types/src/Web.d.ts +3 -3
  72. package/dist/types/src/lib/abstractBase.d.ts +6 -2
  73. package/dist/types/src/lib/core.d.ts +3 -3
  74. package/dist/types/src/lib/index.d.ts +1 -1
  75. package/dist/types/src/lib/types.d.ts +6 -30
  76. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  77. package/package.json +23 -20
  78. package/src/Node.ts +6 -3
  79. package/src/PM/index.ts +12 -8
  80. package/src/PM/main.ts +331 -165
  81. package/src/PM/node.ts +42 -7
  82. package/src/PM/web.ts +33 -5
  83. package/src/SubPackages/puppeteer.ts +1 -1
  84. package/src/SubPackages/react/jsx/index.ts +15 -7
  85. package/src/SubPackages/react/jsx/node.ts +18 -6
  86. package/src/SubPackages/react-dom/component/web.ts +28 -51
  87. package/src/SubPackages/react-test-renderer/component/interface.ts +4 -11
  88. package/src/SubPackages/react-test-renderer/jsx/node.ts +16 -1
  89. package/src/Types.ts +362 -114
  90. package/src/Web.ts +45 -23
  91. package/src/cli.ts +535 -0
  92. package/src/cli2.ts +157 -0
  93. package/src/esbuildConfigs/inputFilesPlugin.ts +27 -9
  94. package/src/esbuildConfigs/node.ts +4 -7
  95. package/src/esbuildConfigs/web.ts +4 -3
  96. package/src/lib/abstractBase.ts +84 -291
  97. package/src/lib/basebuilder.ts +1 -12
  98. package/src/lib/classBuilder.ts +2 -1
  99. package/src/lib/core.ts +17 -29
  100. package/src/lib/types.ts +5 -177
  101. package/dist/common/src/Aider.js +0 -143
  102. package/dist/common/src/Project.js +0 -225
  103. package/dist/common/src/Puppeteer.js +0 -113
  104. package/dist/common/src/build-tests.js +0 -39
  105. package/dist/common/src/esbuildConfigs/features.js +0 -14
  106. package/dist/common/src/esbuildConfigs/report.js +0 -14
  107. package/dist/common/src/esbuildConfigs/tests.js +0 -13
  108. package/dist/common/src/run-tests.js +0 -39
  109. package/dist/module/src/Aider.js +0 -136
  110. package/dist/module/src/Project.js +0 -218
  111. package/dist/module/src/Puppeteer.js +0 -108
  112. package/dist/module/src/build-tests.js +0 -11
  113. package/dist/module/src/esbuildConfigs/features.js +0 -12
  114. package/dist/module/src/esbuildConfigs/report.js +0 -14
  115. package/dist/module/src/esbuildConfigs/tests.js +0 -11
  116. package/dist/module/src/run-tests.js +0 -11
  117. package/dist/prebuild/build-tests.mjs +0 -552
  118. package/dist/types/src/Aider.d.ts +0 -1
  119. package/dist/types/src/Project.d.ts +0 -12
  120. package/dist/types/src/Puppeteer.d.ts +0 -2
  121. package/dist/types/src/esbuildConfigs/features.d.ts +0 -4
  122. package/dist/types/src/esbuildConfigs/report.d.ts +0 -0
  123. package/dist/types/src/esbuildConfigs/tests.d.ts +0 -4
  124. package/src/Aider.ts +0 -168
  125. package/src/Project.ts +0 -291
  126. package/src/Puppeteer.ts +0 -145
  127. package/src/build-tests.ts +0 -12
  128. package/src/esbuildConfigs/features.ts +0 -17
  129. package/src/esbuildConfigs/report.ts +0 -15
  130. package/src/esbuildConfigs/tests.ts +0 -14
  131. package/src/run-tests.ts +0 -12
  132. /package/dist/types/src/{build-tests.d.ts → cli.d.ts} +0 -0
  133. /package/dist/types/src/{run-tests.d.ts → cli2.d.ts} +0 -0
package/src/PM/node.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import fs from "fs";
2
2
  import path from "path";
3
- import puppeteer from "puppeteer-core";
3
+ import puppeteer, { ScreencastOptions, ScreenRecorder } from "puppeteer-core";
4
4
  import { PassThrough } from "stream";
5
5
 
6
6
  import { ITLog, ITTestResourceConfiguration } from "../lib";
7
7
 
8
8
  import { PM } from "./index.js";
9
- import { Page } from "puppeteer-core/lib/esm/puppeteer";
9
+ import { CdpPage, Page } from "puppeteer-core/lib/esm/puppeteer";
10
10
 
11
11
  type IFPaths = string[];
12
12
  const fPaths: IFPaths = [];
@@ -23,10 +23,23 @@ export class PM_Node extends PM {
23
23
  this.testResourceConfiguration = t;
24
24
  }
25
25
 
26
- $(selector: string): boolean {
27
- throw new Error("Method not implemented.");
26
+ waitForSelector(p: string, s: string): any {
27
+ return globalThis["waitForSelector"](p, s);
28
28
  }
29
- screencast(opts: object) {
29
+
30
+ closePage(p): string {
31
+ return globalThis["closePage"](p);
32
+ }
33
+
34
+ goto(cdpPage: CdpPage, url: string): any {
35
+ return globalThis["goto"](cdpPage.mainFrame()._id, url);
36
+ }
37
+
38
+ newPage(): CdpPage {
39
+ return globalThis["newPage"]();
40
+ }
41
+
42
+ $(selector: string): boolean {
30
43
  throw new Error("Method not implemented.");
31
44
  }
32
45
 
@@ -57,8 +70,30 @@ export class PM_Node extends PM {
57
70
  return globalThis["click"](selector);
58
71
  }
59
72
 
60
- customScreenShot(opts: object) {
61
- return globalThis["customScreenShot"](opts);
73
+ screencast(opts: ScreencastOptions, page: CdpPage) {
74
+ return globalThis["screencast"](
75
+ {
76
+ ...opts,
77
+ path: this.testResourceConfiguration.fs + "/" + opts.path,
78
+ },
79
+ page.mainFrame()._id,
80
+ this.testResourceConfiguration.name
81
+ );
82
+ }
83
+
84
+ screencastStop(p: string) {
85
+ return globalThis["screencastStop"](p);
86
+ }
87
+
88
+ customScreenShot(opts: ScreencastOptions, cdpPage: CdpPage) {
89
+ return globalThis["customScreenShot"](
90
+ {
91
+ ...opts,
92
+ path: this.testResourceConfiguration.fs + "/" + opts.path,
93
+ },
94
+ cdpPage.mainFrame()._id,
95
+ this.testResourceConfiguration.name
96
+ );
62
97
  }
63
98
 
64
99
  existsSync(destFolder: string): boolean {
package/src/PM/web.ts CHANGED
@@ -3,7 +3,8 @@ import { PassThrough } from "stream";
3
3
  import { ITLog, ITTestResourceConfiguration } from "../lib";
4
4
 
5
5
  import { PM } from "./index.js";
6
- import { ScreenshotOptions } from "puppeteer-core";
6
+ import { ScreencastOptions, ScreenshotOptions } from "puppeteer-core";
7
+ import { CdpPage } from "puppeteer-core/lib/esm/puppeteer";
7
8
 
8
9
  type PuppetMasterServer = Record<string, Promise<any>>;
9
10
 
@@ -16,12 +17,39 @@ export class PM_Web extends PM {
16
17
  this.testResourceConfiguration = t;
17
18
  }
18
19
 
20
+ waitForSelector(p: string, s: string): any {
21
+ return window["waitForSelector"](p, s);
22
+ }
23
+
24
+ screencast(opts: ScreencastOptions) {
25
+ return window["screencast"](
26
+ {
27
+ ...opts,
28
+ path: this.testResourceConfiguration.fs + "/" + opts.path,
29
+ },
30
+ this.testResourceConfiguration.name
31
+ );
32
+ }
33
+
34
+ screencastStop(recorder: string) {
35
+ return window["screencastStop"](recorder);
36
+ }
37
+
38
+ closePage(p): string {
39
+ return window["closePage"](p);
40
+ }
41
+
42
+ goto(p, url: string): any {
43
+ return window["goto"](p, url);
44
+ }
45
+
46
+ newPage(): CdpPage {
47
+ return window["newPage"]();
48
+ }
49
+
19
50
  $(selector: string): boolean {
20
51
  return window["$"](selector);
21
52
  }
22
- screencast(opts: object) {
23
- throw new Error("Method not implemented.");
24
- }
25
53
 
26
54
  isDisabled(selector: string): boolean {
27
55
  return window["isDisabled"](selector);
@@ -64,7 +92,7 @@ export class PM_Web extends PM {
64
92
  return window["existsSync"](destFolder);
65
93
  }
66
94
 
67
- mkdirSync() {
95
+ mkdirSync(x) {
68
96
  return window["mkdirSync"](this.testResourceConfiguration.fs + "/");
69
97
  }
70
98
 
@@ -29,7 +29,7 @@ export default <ITestShape extends IBaseTest>(
29
29
  testSpecifications,
30
30
  testImplementations,
31
31
  {
32
- beforeAll(x) {
32
+ beforeAll: (x) => {
33
33
  // process.parentPort.postMessage(
34
34
  // `/docs/web/src/ClassicalComponent/test.html`
35
35
  // );
@@ -1,4 +1,5 @@
1
1
  import { CElement } from "react";
2
+ import React from "react";
2
3
 
3
4
  import {
4
5
  IBaseTest,
@@ -6,7 +7,6 @@ import {
6
7
  ITestImplementation,
7
8
  ITestSpecification,
8
9
  } from "../../../Types";
9
- import React from "react";
10
10
 
11
11
  export type IWhenShape = any;
12
12
  export type IThenShape = any;
@@ -29,14 +29,22 @@ export const testInterface: IPartialInterface<any> = {
29
29
  // // resolve(x());
30
30
  // // });
31
31
  // },
32
- beforeEach: async (subject, initializer, artificer): Promise<IStore> => {
32
+ // beforeEach: async (subject, initializer, artificer): Promise<IStore> => {
33
+ // return new Promise((resolve, rej) => {
34
+ // resolve(React.createElement(subject));
35
+ // });
36
+ // },
37
+ andWhen: async (s: IStore, whenCB): Promise<IStore> => {
38
+ await whenCB(s());
33
39
  return new Promise((resolve, rej) => {
34
- const x = React.createElement(subject);
35
- console.log("react-element", x);
36
- resolve(x);
40
+ resolve(React.createElement(s));
37
41
  });
42
+ // return whenCB(s);
38
43
  },
39
- andWhen: function (s: IStore, whenCB): Promise<ISelection> {
40
- return whenCB(s);
44
+ butThen: async (subject, thenCB) => {
45
+ await thenCB(subject());
46
+ return new Promise((resolve, rej) => {
47
+ resolve(React.createElement(subject));
48
+ });
41
49
  },
42
50
  };
@@ -8,19 +8,31 @@ import {
8
8
  testInterface as baseInterface,
9
9
  } from "./index.js";
10
10
 
11
- export default <ITestShape extends IBaseTest>(
11
+ export default <
12
+ ITestShape extends IBaseTest<
13
+ IInput,
14
+ number,
15
+ number,
16
+ number,
17
+ unknown,
18
+ unknown,
19
+ unknown,
20
+ Record<string, any>,
21
+ Record<string, any>,
22
+ Record<string, any>,
23
+ Record<string, any>,
24
+ Record<string, any>
25
+ >
26
+ >(
12
27
  testImplementations: ITestImpl<ITestShape>,
13
28
  testSpecifications: ITestSpec<ITestShape>,
14
29
  testInput: IInput,
15
- testInterface: IPartialInterface<ITestShape>
30
+ testInterface: IPartialInterface<ITestShape> = baseInterface
16
31
  ) => {
17
32
  return Testeranto<ITestShape>(
18
33
  testInput,
19
34
  testSpecifications,
20
35
  testImplementations,
21
- {
22
- ...baseInterface,
23
- ...testInterface,
24
- }
36
+ testInterface
25
37
  );
26
38
  };
@@ -25,7 +25,7 @@ export type IStore = {
25
25
 
26
26
  type ISubject = {
27
27
  htmlElement: HTMLElement;
28
- reactElement: any; //CElement<any, any>,
28
+ // reactElement: any; //CElement<any, any>,
29
29
  domRoot: ReactDom.Root;
30
30
  };
31
31
 
@@ -52,63 +52,40 @@ export default <ITestShape extends IBaseTest, IWhen, IGiven>(
52
52
  testSpecifications,
53
53
  testImplementations,
54
54
  {
55
- beforeAll: async (initialProps, artificer): Promise<ISubject> => {
55
+ beforeAll: async (subject, artificer): Promise<ISubject> => {
56
56
  return await new Promise((resolve, rej) => {
57
57
  const htmlElement = document.getElementById("root");
58
58
  if (htmlElement) {
59
59
  const domRoot = ReactDom.createRoot(htmlElement);
60
- // Ignore these type errors
61
- domRoot.render(
62
- createElement(
63
- TesterantoComponent,
64
- {
65
- ...initialProps,
66
- done: (reactElement) => {
67
- resolve({
68
- htmlElement,
69
- reactElement,
70
- domRoot,
71
- });
72
- },
73
- },
74
- []
75
- )
76
- );
77
-
78
- // resolve({ htmlElement });
60
+ resolve({ domRoot, htmlElement });
79
61
  }
80
62
  });
81
63
  },
82
- // beforeEach: async (
83
- // s,
84
- // initializer,
85
- // testResource,
86
- // artificer,
87
- // initialValues
88
- // ): Promise<IStore> => {
89
- // return new Promise((resolve, rej) => {
90
- // console.log("beforeEach" + TesterantoComponent);
91
-
92
- // // const domRoot = ReactDom.createRoot(htmlElement);
93
- // // // Ignore these type errors
94
- // // domRoot.render(
95
- // // createElement(
96
- // // TesterantoComponent,
97
- // // {
98
- // // ...initializer,
99
- // // done: (reactElement) => {
100
- // // resolve({
101
- // // htmlElement,
102
- // // reactElement,
103
- // // domRoot,
104
- // // });
105
- // // },
106
- // // },
107
- // // []
108
- // // )
109
- // // );
110
- // });
111
- // },
64
+ beforeEach: async (
65
+ { domRoot, htmlElement },
66
+ initialValues,
67
+ testResource,
68
+ artificer
69
+ ): Promise<IStore> => {
70
+ return new Promise(async (resolve, rej) => {
71
+ domRoot.render(
72
+ createElement(
73
+ TesterantoComponent,
74
+ {
75
+ ...initialValues,
76
+ done: (reactElement) => {
77
+ resolve({
78
+ htmlElement,
79
+ reactElement,
80
+ domRoot,
81
+ });
82
+ },
83
+ },
84
+ []
85
+ )
86
+ );
87
+ });
88
+ },
112
89
  andWhen: function (s: IStore, whenCB): Promise<ISelection> {
113
90
  return whenCB(s);
114
91
  },
@@ -1,21 +1,18 @@
1
1
  import React from "react";
2
2
  import renderer, { act } from "react-test-renderer";
3
+
3
4
  import { ISelection, IStore } from ".";
4
5
 
5
6
  export const testInterface = {
6
7
  beforeEach: function (
7
8
  CComponent,
8
- propsAndChildren
9
+ propsAndChildren: () => any
9
10
  ): Promise<renderer.ReactTestRenderer> {
10
- function Link(props) {
11
- const p = props.props;
12
- const c = props.children;
13
- return React.createElement(CComponent, p, c);
11
+ function Link(proper) {
12
+ return React.createElement(CComponent, proper(), []);
14
13
  }
15
14
  return new Promise((res, rej) => {
16
15
  act(async () => {
17
- const p = propsAndChildren;
18
- const y = new CComponent(p.props);
19
16
  const testRenderer = await renderer.create(Link(propsAndChildren));
20
17
  res(testRenderer);
21
18
  });
@@ -25,7 +22,6 @@ export const testInterface = {
25
22
  renderer: renderer.ReactTestRenderer,
26
23
  whenCB: any
27
24
  ): Promise<renderer.ReactTestRenderer> {
28
- // console.log("andWhen", whenCB)
29
25
  await act(() => whenCB(renderer));
30
26
  return renderer;
31
27
  },
@@ -34,15 +30,12 @@ export const testInterface = {
34
30
  // return whenCB()(s);
35
31
  // },
36
32
  butThen: async function (s: IStore, thenCB, tr): Promise<ISelection> {
37
- console.log("butThen", thenCB.toString());
38
33
  return thenCB(s);
39
34
  },
40
35
  afterEach: async function (store: IStore, ndx, artificer) {
41
- // console.log("afterEach", store);
42
36
  return {};
43
37
  },
44
38
  afterAll: (store: IStore, artificer) => {
45
- // console.log("afterAll", store);
46
39
  return;
47
40
  },
48
41
  };
@@ -5,7 +5,22 @@ import type { ITestImpl, ITestSpec } from "../jsx-promised";
5
5
 
6
6
  import { IInput, testInterface } from "./index.js";
7
7
 
8
- export default <ITestShape extends IBaseTest>(
8
+ export default <
9
+ ITestShape extends IBaseTest<
10
+ unknown,
11
+ unknown,
12
+ unknown,
13
+ unknown,
14
+ unknown,
15
+ unknown,
16
+ unknown,
17
+ Record<string, any>,
18
+ Record<string, any>,
19
+ Record<string, any>,
20
+ Record<string, any>,
21
+ Record<string, any>
22
+ >
23
+ >(
9
24
  testImplementations: ITestImpl<ITestShape>,
10
25
  testSpecifications: ITestSpec<ITestShape>,
11
26
  testInput: IInput,