testeranto 0.62.0 → 0.70.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 (151) hide show
  1. package/README.md +42 -21
  2. package/dist/cjs-shim.js +2 -2
  3. package/dist/common/Node.js +7 -24
  4. package/dist/common/NodeWriter.js +7 -9
  5. package/dist/common/Project.js +103 -266
  6. package/dist/common/SubPackages/puppeteer.js +1 -1
  7. package/dist/common/SubPackages/react-dom/component/web.js +1 -1
  8. package/dist/common/SubPackages/react-dom/jsx/web.js +15 -7
  9. package/dist/common/SubPackages/react-test-renderer/MemoExoticComponent/node.js +1 -1
  10. package/dist/common/SubPackages/react-test-renderer/component/index.js +0 -1
  11. package/dist/common/SubPackages/react-test-renderer/fc/web.js +1 -1
  12. package/dist/common/SubPackages/react-test-renderer/jsx/index.js +1 -2
  13. package/dist/common/SubPackages/react-test-renderer/jsx/web.js +1 -1
  14. package/dist/common/SubPackages/react-test-renderer/jsx-promised/index.js +1 -1
  15. package/dist/common/Types.js +2 -32
  16. package/dist/common/Web.js +25 -18
  17. package/dist/common/electron.js +177 -107
  18. package/dist/common/esbuildConfigs/index.js +5 -5
  19. package/dist/common/esbuildConfigs/node.js +17 -15
  20. package/dist/common/esbuildConfigs/report.js +12 -47
  21. package/dist/common/esbuildConfigs/tests.js +0 -1
  22. package/dist/common/esbuildConfigs/web.js +14 -11
  23. package/dist/common/lib/abstractBase.js +13 -6
  24. package/dist/common/lib/basebuilder.js +11 -11
  25. package/dist/common/lib/classBuilder.js +2 -3
  26. package/dist/common/lib/core.js +37 -8
  27. package/dist/common/lib/index.js +10 -8
  28. package/dist/common/lib/types.js +2 -0
  29. package/dist/common/preload.js +15 -25
  30. package/dist/common/puppeteerConfiger.js +24 -0
  31. package/dist/common/tsconfig.common.tsbuildinfo +1 -1
  32. package/dist/module/Node.js +7 -24
  33. package/dist/module/NodeWriter.js +7 -9
  34. package/dist/module/Project.js +104 -267
  35. package/dist/module/SubPackages/puppeteer.js +1 -1
  36. package/dist/module/SubPackages/react/jsx/web.js +1 -1
  37. package/dist/module/SubPackages/react-dom/component/node.js +2 -2
  38. package/dist/module/SubPackages/react-dom/component/web.js +1 -1
  39. package/dist/module/SubPackages/react-dom/jsx/web.js +17 -9
  40. package/dist/module/SubPackages/react-test-renderer/MemoExoticComponent/node.js +1 -1
  41. package/dist/module/SubPackages/react-test-renderer/component/index.js +0 -1
  42. package/dist/module/SubPackages/react-test-renderer/fc/web.js +1 -1
  43. package/dist/module/SubPackages/react-test-renderer/jsx/index.js +1 -2
  44. package/dist/module/SubPackages/react-test-renderer/jsx/web.js +1 -1
  45. package/dist/module/SubPackages/react-test-renderer/jsx-promised/index.js +1 -1
  46. package/dist/module/Types.js +3 -30
  47. package/dist/module/Web.js +26 -19
  48. package/dist/module/electron.js +179 -109
  49. package/dist/module/esbuildConfigs/index.js +5 -5
  50. package/dist/module/esbuildConfigs/node.js +17 -15
  51. package/dist/module/esbuildConfigs/report.js +11 -48
  52. package/dist/module/esbuildConfigs/tests.js +0 -1
  53. package/dist/module/esbuildConfigs/web.js +14 -11
  54. package/dist/module/lib/abstractBase.js +13 -6
  55. package/dist/module/lib/basebuilder.js +11 -11
  56. package/dist/module/lib/classBuilder.js +2 -3
  57. package/dist/module/lib/core.js +39 -10
  58. package/dist/module/lib/index.js +10 -8
  59. package/dist/module/lib/types.js +1 -0
  60. package/dist/module/preload.js +12 -25
  61. package/dist/module/puppeteerConfiger.js +19 -0
  62. package/dist/module/tsconfig.module.tsbuildinfo +1 -1
  63. package/dist/types/Node.d.ts +3 -2
  64. package/dist/types/Project.d.ts +1 -2
  65. package/dist/types/SubPackages/puppeteer.d.ts +3 -3
  66. package/dist/types/SubPackages/react/component/node.d.ts +1 -1
  67. package/dist/types/SubPackages/react/component/web.d.ts +1 -1
  68. package/dist/types/SubPackages/react/jsx/index.d.ts +1 -1
  69. package/dist/types/SubPackages/react/jsx/node.d.ts +1 -1
  70. package/dist/types/SubPackages/react/jsx/web.d.ts +2 -2
  71. package/dist/types/SubPackages/react-dom/component/node.d.ts +2 -2
  72. package/dist/types/SubPackages/react-dom/component/web.d.ts +1 -1
  73. package/dist/types/SubPackages/react-dom/jsx/node.d.ts +1 -1
  74. package/dist/types/SubPackages/react-dom/jsx/web.d.ts +1 -1
  75. package/dist/types/SubPackages/react-test-renderer/MemoExoticComponent/node.d.ts +1 -1
  76. package/dist/types/SubPackages/react-test-renderer/component/index.d.ts +1 -1
  77. package/dist/types/SubPackages/react-test-renderer/component/node.d.ts +1 -1
  78. package/dist/types/SubPackages/react-test-renderer/component/web.d.ts +1 -1
  79. package/dist/types/SubPackages/react-test-renderer/fc/node.d.ts +1 -1
  80. package/dist/types/SubPackages/react-test-renderer/fc/web.d.ts +1 -1
  81. package/dist/types/SubPackages/react-test-renderer/jsx/node.d.ts +1 -1
  82. package/dist/types/SubPackages/react-test-renderer/jsx/web.d.ts +3 -3
  83. package/dist/types/SubPackages/react-test-renderer/jsx-promised/index.d.ts +1 -1
  84. package/dist/types/SubPackages/react-test-renderer/jsx-promised/node.d.ts +1 -1
  85. package/dist/types/SubPackages/react-test-renderer/jsx-promised/web.d.ts +1 -1
  86. package/dist/types/Types.d.ts +19 -100
  87. package/dist/types/Web.d.ts +3 -2
  88. package/dist/types/esbuildConfigs/features.d.ts +1 -1
  89. package/dist/types/esbuildConfigs/index.d.ts +1 -1
  90. package/dist/types/esbuildConfigs/node.d.ts +1 -1
  91. package/dist/types/esbuildConfigs/report.d.ts +4 -0
  92. package/dist/types/esbuildConfigs/tests.d.ts +1 -1
  93. package/dist/types/esbuildConfigs/web.d.ts +1 -1
  94. package/dist/types/lib/abstractBase.d.ts +25 -24
  95. package/dist/types/lib/basebuilder.d.ts +8 -7
  96. package/dist/types/lib/classBuilder.d.ts +3 -2
  97. package/dist/types/lib/core.d.ts +3 -2
  98. package/dist/types/lib/index.d.ts +4 -3
  99. package/dist/types/lib/types.d.ts +70 -0
  100. package/dist/types/puppeteerConfiger.d.ts +4 -0
  101. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  102. package/package.json +4 -3
  103. package/src/Node.ts +24 -54
  104. package/src/NodeWriter.ts +21 -18
  105. package/src/Project.ts +165 -620
  106. package/src/Report.tsx +1 -1
  107. package/src/SubPackages/puppeteer.ts +19 -14
  108. package/src/SubPackages/react/component/node.ts +20 -32
  109. package/src/SubPackages/react/component/web.ts +20 -30
  110. package/src/SubPackages/react/jsx/index.ts +13 -24
  111. package/src/SubPackages/react/jsx/web.ts +10 -8
  112. package/src/SubPackages/react-dom/component/node.ts +17 -23
  113. package/src/SubPackages/react-dom/component/web.ts +30 -50
  114. package/src/SubPackages/react-dom/jsx/web.ts +41 -48
  115. package/src/SubPackages/react-test-renderer/MemoExoticComponent/node.ts +27 -37
  116. package/src/SubPackages/react-test-renderer/component/index.ts +16 -30
  117. package/src/SubPackages/react-test-renderer/component/node.ts +5 -11
  118. package/src/SubPackages/react-test-renderer/component/web.ts +5 -11
  119. package/src/SubPackages/react-test-renderer/fc/node.ts +36 -50
  120. package/src/SubPackages/react-test-renderer/fc/web.ts +37 -50
  121. package/src/SubPackages/react-test-renderer/jsx/index.ts +16 -21
  122. package/src/SubPackages/react-test-renderer/jsx/node.ts +6 -10
  123. package/src/SubPackages/react-test-renderer/jsx/web.ts +7 -7
  124. package/src/SubPackages/react-test-renderer/jsx-promised/index.ts +13 -16
  125. package/src/Types.ts +73 -307
  126. package/src/Web.ts +54 -53
  127. package/src/cjs-shim.js +2 -2
  128. package/src/electron.ts +258 -191
  129. package/src/esbuildConfigs/features.ts +3 -4
  130. package/src/esbuildConfigs/index.ts +8 -8
  131. package/src/esbuildConfigs/node.ts +21 -20
  132. package/src/esbuildConfigs/report.ts +15 -51
  133. package/src/esbuildConfigs/tests.ts +3 -9
  134. package/src/esbuildConfigs/web.ts +18 -18
  135. package/src/lib/abstractBase.ts +78 -125
  136. package/src/lib/basebuilder.ts +109 -134
  137. package/src/lib/classBuilder.ts +26 -45
  138. package/src/lib/core.ts +101 -69
  139. package/src/lib/index.ts +53 -52
  140. package/src/lib/types.ts +206 -0
  141. package/src/preload.ts +12 -28
  142. package/src/puppeteerConfiger.ts +26 -0
  143. package/src/web.html.ts +1 -1
  144. package/dist/common/lib/browser.js +0 -26
  145. package/dist/common/nodeWriterElectron.js +0 -55
  146. package/dist/module/lib/browser.js +0 -22
  147. package/dist/module/nodeWriterElectron.js +0 -52
  148. package/dist/types/lib/browser.d.ts +0 -6
  149. package/dist/types/nodeWriterElectron.d.ts +0 -2
  150. package/src/lib/browser.ts +0 -34
  151. package/src/nodeWriterElectron.ts +0 -71
package/src/lib/core.ts CHANGED
@@ -1,7 +1,11 @@
1
- import type {
2
- IBaseTest, ITestImplementation, ITestInterface, ITestSpecification, IUtils
3
- } from "../Types";
1
+ import { IStore } from "../SubPackages/react/jsx";
2
+ import {
3
+ IBaseTest,
4
+ ITestSpecification,
5
+ ITestImplementation,
6
+ } from "../Types.js";
4
7
 
8
+ import { ITestInterface, IUtils } from "./types.js";
5
9
  import {
6
10
  DefaultTestInterface,
7
11
  ILogWriter,
@@ -9,24 +13,27 @@ import {
9
13
  ITTestResourceRequest,
10
14
  ITestArtifactory,
11
15
  ITestJob,
12
- defaultTestResourceRequirement
16
+ defaultTestResourceRequirement,
13
17
  } from "./index.js";
14
18
  import {
15
- BaseSuite, BaseGiven, BaseWhen, BaseThen, BaseCheck
19
+ BaseSuite,
20
+ BaseGiven,
21
+ BaseWhen,
22
+ BaseThen,
23
+ BaseCheck,
16
24
  } from "./abstractBase.js";
17
- import {
18
- ClassBuilder
19
- } from "./classBuilder.js";
20
- import { IStore } from "../SubPackages/react/jsx";
25
+ import { ClassBuilder } from "./classBuilder.js";
21
26
 
22
- export default abstract class Testeranto<ITestShape extends IBaseTest> extends ClassBuilder<ITestShape> {
27
+ export default abstract class Testeranto<
28
+ ITestShape extends IBaseTest
29
+ > extends ClassBuilder<ITestShape> {
23
30
  constructor(
24
- input: ITestShape['iinput'],
31
+ input: ITestShape["iinput"],
25
32
  testSpecification: ITestSpecification<ITestShape>,
26
- testImplementation: ITestImplementation<ITestShape, object>,
33
+ testImplementation: ITestImplementation<ITestShape>,
27
34
  testResourceRequirement: ITTestResourceRequest = defaultTestResourceRequirement,
28
35
  logWriter: ILogWriter,
29
- testInterface: Partial<ITestInterface<ITestShape>>,
36
+ testInterface: Partial<ITestInterface<ITestShape>>
30
37
  ) {
31
38
  const fullTestInterface = DefaultTestInterface(testInterface);
32
39
 
@@ -35,39 +42,30 @@ export default abstract class Testeranto<ITestShape extends IBaseTest> extends C
35
42
  testSpecification,
36
43
  input,
37
44
 
38
- class extends BaseSuite<
39
- ITestShape
40
- > {
41
-
45
+ class extends BaseSuite<ITestShape> {
42
46
  assertThat(t) {
43
47
  fullTestInterface.assertThis(t);
44
48
  }
45
49
 
46
50
  async setup(
47
- s: ITestShape['iinput'],
51
+ s: ITestShape["iinput"],
48
52
  artifactory: ITestArtifactory,
49
53
  tr,
50
- // utils: ITestInterface<ITestShape>
51
- ): Promise<
52
- ITestShape['isubject']
53
- > {
54
- return (fullTestInterface.beforeAll || (async (
55
- input: ITestShape['iinput'],
56
- artifactory: ITestArtifactory,
57
- tr,
58
- // utils: ITestInterface<ITestShape>
59
- ) => input as any))(
60
- s,
61
- this.testResourceConfiguration,
62
- artifactory
63
- );
54
+ utils
55
+ ): Promise<ITestShape["isubject"]> {
56
+ return (
57
+ fullTestInterface.beforeAll ||
58
+ (async (
59
+ input: ITestShape["iinput"],
60
+ artifactory: ITestArtifactory,
61
+ tr,
62
+ utils: ITestInterface<ITestShape>
63
+ ) => input as any)
64
+ )(s, this.testResourceConfiguration, artifactory, utils);
64
65
  }
65
66
  } as any,
66
67
 
67
- class Given extends BaseGiven<
68
- ITestShape
69
- > {
70
-
68
+ class Given extends BaseGiven<ITestShape> {
71
69
  async givenThat(subject, testResource, artifactory, initializer) {
72
70
  return fullTestInterface.beforeEach(
73
71
  subject,
@@ -76,61 +74,87 @@ export default abstract class Testeranto<ITestShape extends IBaseTest> extends C
76
74
  // TODO does not work?
77
75
  artifactory(`beforeEach/${fPath}`, value),
78
76
  testResource,
79
- this.initialValues,
77
+ this.initialValues
80
78
  // utils,
81
79
  );
82
80
  }
83
81
 
84
82
  afterEach(
85
- store: ITestShape['istore'],
83
+ store: ITestShape["istore"],
86
84
  key: string,
87
- artifactory
85
+ artifactory,
86
+ utils
88
87
  ): Promise<unknown> {
89
88
  return new Promise((res) =>
90
- res(fullTestInterface.afterEach(store, key, (fPath: string, value: unknown) =>
91
- artifactory(`after/${fPath}`, value)))
89
+ res(
90
+ fullTestInterface.afterEach(
91
+ store,
92
+ key,
93
+ (fPath: string, value: unknown) =>
94
+ artifactory(`after/${fPath}`, value),
95
+ utils
96
+ )
97
+ )
92
98
  );
93
99
  }
94
- afterAll(
95
- store: IStore,
96
- artifactory: ITestArtifactory,
97
- utils: IUtils,
98
- ) {
99
- return fullTestInterface.afterAll(store, (fPath: string, value: unknown) =>
100
- // TODO does not work?
101
- { artifactory(`afterAll4-${this.name}/${fPath}`, value) },
100
+ afterAll(store: IStore, artifactory: ITestArtifactory, utils: IUtils) {
101
+ const pagesHandler = {
102
+ get(target, prop) {
103
+ console.log(`Getting pages property ${prop}`);
104
+ return target[prop];
105
+ },
106
+ };
107
+
108
+ const browserHandler = {
109
+ get(target, prop) {
110
+ console.log(`Getting browser property ${prop}`);
111
+ if (prop === "pages") {
112
+ // return target[prop];
113
+ return new Proxy(target[prop], pagesHandler);
114
+ } else {
115
+ return target[prop];
116
+ }
117
+ },
118
+ };
119
+ const proxy = new Proxy(utils.browser, browserHandler);
120
+
121
+ return fullTestInterface.afterAll(
122
+ store,
123
+ (fPath: string, value: unknown) =>
124
+ // TODO does not work?
125
+ {
126
+ artifactory(`afterAll4-${this.name}/${fPath}`, value);
127
+ },
102
128
  utils
129
+ // {
130
+ // ...utils,
131
+ // browser: proxy,
132
+ // }
103
133
  );
104
134
  }
105
135
  } as any,
106
136
 
107
- class When extends BaseWhen<
108
- ITestShape
109
- > {
137
+ class When extends BaseWhen<ITestShape> {
110
138
  async andWhen(store, whenCB, testResource) {
111
139
  return await fullTestInterface.andWhen(store, whenCB, testResource);
112
140
  }
113
141
  } as any,
114
142
 
115
- class Then extends BaseThen<
116
- ITestShape
117
- > {
118
-
143
+ class Then extends BaseThen<ITestShape> {
119
144
  async butThen(
120
145
  store: any,
121
146
  thenCB,
122
147
  testResourceConfiguration?: any
123
- ): Promise<ITestShape['iselection']> {
148
+ ): Promise<ITestShape["iselection"]> {
124
149
  return await fullTestInterface.butThen(
125
150
  store,
126
151
  thenCB,
127
- testResourceConfiguration);
152
+ testResourceConfiguration
153
+ );
128
154
  }
129
155
  } as any,
130
156
 
131
- class Check extends BaseCheck<
132
- ITestShape
133
- > {
157
+ class Check extends BaseCheck<ITestShape> {
134
158
  initialValues: any;
135
159
 
136
160
  constructor(
@@ -149,27 +173,36 @@ export default abstract class Testeranto<ITestShape extends IBaseTest> extends C
149
173
  return fullTestInterface.beforeEach(
150
174
  subject,
151
175
  this.initialValues,
152
- (fPath: string, value: unknown) => artifactory(`before/${fPath}`, value),
176
+ (fPath: string, value: unknown) =>
177
+ artifactory(`before/${fPath}`, value),
153
178
  testResourceConfiguration,
154
179
  this.initialValues
155
180
  );
156
181
  }
157
182
 
158
183
  afterEach(
159
- store: ITestShape['istore'],
184
+ store: ITestShape["istore"],
160
185
  key: string,
161
- artifactory
186
+ artifactory,
187
+ utils
162
188
  ): Promise<unknown> {
163
189
  return new Promise((res) =>
164
- res(fullTestInterface.afterEach(store, key, (fPath: string, value: unknown) =>
165
- // TODO does not work?
166
- artifactory(`afterEach2-${this.name}/${fPath}`, value)))
190
+ res(
191
+ fullTestInterface.afterEach(
192
+ store,
193
+ key,
194
+ (fPath: string, value: unknown) =>
195
+ // TODO does not work?
196
+ artifactory(`afterEach2-${this.name}/${fPath}`, value),
197
+ utils
198
+ )
199
+ )
167
200
  );
168
201
  }
169
202
  } as any,
170
203
 
171
204
  testResourceRequirement,
172
- logWriter,
205
+ logWriter
173
206
  );
174
207
  }
175
208
 
@@ -178,5 +211,4 @@ export default abstract class Testeranto<ITestShape extends IBaseTest> extends C
178
211
  partialTestResource: ITTestResourceConfiguration,
179
212
  utils: IUtils
180
213
  );
181
-
182
214
  }
package/src/lib/index.ts CHANGED
@@ -1,23 +1,39 @@
1
+ import { IBaseTest } from "../Types.js";
1
2
 
2
- import { IBaseTest, ITestInterface, IUtils } from "../Types.js";
3
- import { IGivens, BaseCheck, BaseSuite, BaseWhen, BaseThen } from "./abstractBase.js";
3
+ import {
4
+ IGivens,
5
+ BaseCheck,
6
+ BaseSuite,
7
+ BaseWhen,
8
+ BaseThen,
9
+ } from "./abstractBase.js";
10
+
11
+ import { INodeUtils, ITestInterface, IUtils, IWebUtils } from "./types.js";
4
12
 
5
13
  export const BaseTestInterface: ITestInterface<IBaseTest> = {
6
- beforeAll: (async (s) => s),
7
- beforeEach: async function (subject: any, initialValues: any, testResource: any) { return subject as any; },
8
- afterEach: (async (s) => s),
9
- afterAll: ((store: IBaseTest['istore']) => undefined),
10
- butThen: (async (store: IBaseTest['istore'], thenCb) => thenCb(store)),
11
- andWhen: ((a) => a),
12
- assertThis: (() => null),
14
+ beforeAll: async (s) => s,
15
+ beforeEach: async function (
16
+ subject: any,
17
+ initialValues: any,
18
+ testResource: any
19
+ ) {
20
+ return subject as any;
21
+ },
22
+ afterEach: async (s) => s,
23
+ afterAll: (store: IBaseTest["istore"]) => undefined,
24
+ butThen: async (store: IBaseTest["istore"], thenCb) => thenCb(store),
25
+ andWhen: (a) => a,
26
+ assertThis: () => null,
13
27
  };
14
28
 
15
- export const DefaultTestInterface = (p: Partial<ITestInterface<any>>): ITestInterface<any> => {
29
+ export const DefaultTestInterface = (
30
+ p: Partial<ITestInterface<any>>
31
+ ): ITestInterface<any> => {
16
32
  return {
17
33
  ...BaseTestInterface,
18
- ...p
19
- }
20
- }
34
+ ...p,
35
+ };
36
+ };
21
37
 
22
38
  export type ITTestResourceConfiguration = {
23
39
  name: string;
@@ -39,51 +55,47 @@ export type ITTestResourceRequest = {
39
55
  export type ITLog = (...string) => void;
40
56
 
41
57
  export type ILogWriter = {
42
- createWriteStream: (line: string) => any | any,
43
- writeFileSync: (fp: string, contents: string) => any
44
- mkdirSync: (fp: string) => any
45
- testArtiFactoryfileWriter: (tLog: ITLog, n: (Promise) => void) =>
46
- (fPath: string, value: unknown) =>
47
- void
48
- }
58
+ createWriteStream: (line: string) => any | any;
59
+ writeFileSync: (fp: string, contents: string) => any;
60
+ mkdirSync: (fp: string) => any;
61
+ testArtiFactoryfileWriter: (
62
+ tLog: ITLog,
63
+ n: (Promise) => void
64
+ ) => (fPath: string, value: unknown) => void;
65
+ };
49
66
 
50
67
  export type ITestArtificer = (key: string, data: any) => void;
51
68
 
52
69
  type ITest = {
53
70
  toObj(): object;
54
71
  name: string;
55
- givens: IGivens<
56
- IBaseTest
57
- >;
58
- checks: BaseCheck<
59
- IBaseTest
60
- >[];
72
+ givens: IGivens<IBaseTest>;
73
+ checks: BaseCheck<IBaseTest>[];
61
74
  testResourceConfiguration: ITTestResourceConfiguration;
62
75
  };
63
76
 
64
- export type ITestJob = {
77
+ export type ITestJob<T = INodeUtils | IWebUtils> = {
65
78
  toObj(): object;
66
79
  test: ITest;
67
- runner: (x: ITTestResourceConfiguration, t: ITLog) => Promise<
68
- BaseSuite<
69
- IBaseTest
70
- >
71
- >;
80
+ runner: (
81
+ x: ITTestResourceConfiguration,
82
+ t: ITLog
83
+ ) => Promise<BaseSuite<IBaseTest>>;
72
84
  testResourceRequirement: ITTestResourceRequirement;
73
85
  receiveTestResourceConfig: (
74
86
  testResource,
75
- utils: IUtils
87
+ utils: T
76
88
  ) => Promise<{
77
- failed: number,
78
- artifacts: Promise<unknown>[],
79
- logPromise: Promise<unknown>
80
- }>
89
+ failed: number;
90
+ artifacts: Promise<unknown>[];
91
+ logPromise: Promise<unknown>;
92
+ }>;
81
93
  };
82
94
 
83
95
  export type ITestResults = Promise<{ test: ITest }>[];
84
96
 
85
97
  export const defaultTestResourceRequirement: ITTestResourceRequest = {
86
- ports: 0
98
+ ports: 0,
87
99
  };
88
100
 
89
101
  export type ITestArtifactory = (key: string, value: unknown) => unknown;
@@ -94,23 +106,12 @@ export type ITestCheckCallback<ITestShape extends IBaseTest> = {
94
106
  features: string[],
95
107
  callbackA: (
96
108
  whens: {
97
- [K in keyof ITestShape["whens"]]: (
98
- ...unknown
99
- ) => BaseWhen<
100
- ITestShape
101
- >;
109
+ [K in keyof ITestShape["whens"]]: (...unknown) => BaseWhen<ITestShape>;
102
110
  },
103
111
  thens: {
104
- [K in keyof ITestShape["thens"]]: (
105
- ...unknown
106
- ) => BaseThen<
107
- ITestShape
108
- >;
112
+ [K in keyof ITestShape["thens"]]: (...unknown) => BaseThen<ITestShape>;
109
113
  }
110
114
  ) => Promise<any>,
111
115
  ...xtrasA: ITestShape["checks"][K]
112
- ) => BaseCheck<
113
- ITestShape
114
- >;
116
+ ) => BaseCheck<ITestShape>;
115
117
  };
116
-
@@ -0,0 +1,206 @@
1
+ import { IBaseTest } from "../Types";
2
+
3
+ import puppeteer from "puppeteer-core";
4
+ import {
5
+ IGivens,
6
+ BaseCheck,
7
+ BaseSuite,
8
+ BaseGiven,
9
+ BaseWhen,
10
+ BaseThen,
11
+ } from "./abstractBase";
12
+ import { ITTestResourceConfiguration, ITestArtificer } from ".";
13
+
14
+ export type IRunTime = `node` | `web`;
15
+
16
+ export type ITestTypes = [string, IRunTime, ITestTypes[]];
17
+
18
+ export type IJsonConfig = {
19
+ outdir: string;
20
+ tests: ITestTypes[];
21
+ features: string;
22
+ };
23
+
24
+ export type IBaseConfig = {
25
+ clearScreen: boolean;
26
+ debugger: boolean;
27
+ devMode: boolean;
28
+ externals: string[];
29
+ features: string;
30
+ minify: boolean;
31
+ nodePlugins: any[];
32
+ outbase: string;
33
+ outdir: string;
34
+ ports: string[];
35
+ tests: ITestTypes[];
36
+ webPlugins: any[];
37
+ };
38
+
39
+ export type IBuiltConfig = { buildDir: string } & IBaseConfig;
40
+
41
+ export type INodeUtils = {
42
+ browser: puppeteer.Browser;
43
+ ipc: Electron.ParentPort;
44
+ };
45
+
46
+ export type IWebUtils = {
47
+ browser: puppeteer.Browser;
48
+ ipc: Electron.IpcRenderer;
49
+ };
50
+ export type IUtils = INodeUtils | IWebUtils;
51
+
52
+ export type IWebTestInterface<ITestShape extends IBaseTest> = {
53
+ assertThis: (x: ITestShape["then"]) => void;
54
+
55
+ andWhen: (
56
+ store: ITestShape["istore"],
57
+ whenCB: ITestShape["when"],
58
+ testResource: ITTestResourceConfiguration
59
+ ) => Promise<ITestShape["istore"]>;
60
+ butThen: (
61
+ store: ITestShape["istore"],
62
+ thenCB,
63
+ testResource: ITTestResourceConfiguration
64
+ ) => Promise<ITestShape["iselection"]>;
65
+
66
+ afterAll: (
67
+ store: ITestShape["istore"],
68
+ artificer: ITestArtificer,
69
+ browser: IWebUtils
70
+ ) => any;
71
+ afterEach: (
72
+ store: ITestShape["istore"],
73
+ key: string,
74
+ artificer: ITestArtificer,
75
+ utils: IWebUtils
76
+ ) => Promise<unknown>;
77
+ beforeAll: (
78
+ input: ITestShape["iinput"],
79
+ testResource: ITTestResourceConfiguration,
80
+ artificer: ITestArtificer,
81
+ utils: IWebUtils
82
+ ) => Promise<ITestShape["isubject"]>;
83
+ beforeEach: (
84
+ subject: ITestShape["isubject"],
85
+ initializer: (c?) => ITestShape["given"],
86
+ artificer: ITestArtificer,
87
+ testResource: ITTestResourceConfiguration,
88
+ initialValues
89
+ // utils: IUtils
90
+ ) => Promise<ITestShape["istore"]>;
91
+ };
92
+ // & ITestInterface<ITestShape>;
93
+
94
+ export type INodeTestInterface<ITestShape extends IBaseTest> = {
95
+ assertThis: (x: ITestShape["then"]) => void;
96
+ andWhen: (
97
+ store: ITestShape["istore"],
98
+ whenCB: ITestShape["when"],
99
+ testResource: ITTestResourceConfiguration
100
+ ) => Promise<ITestShape["istore"]>;
101
+ butThen: (
102
+ store: ITestShape["istore"],
103
+ thenCB,
104
+ testResource: ITTestResourceConfiguration
105
+ ) => Promise<ITestShape["iselection"]>;
106
+ afterAll: (
107
+ store: ITestShape["istore"],
108
+ artificer: ITestArtificer,
109
+ utils: INodeUtils
110
+ ) => any;
111
+ afterEach: (
112
+ store: ITestShape["istore"],
113
+ key: string,
114
+ artificer: ITestArtificer,
115
+ utils: INodeUtils
116
+ ) => Promise<unknown>;
117
+ beforeAll: (
118
+ input: ITestShape["iinput"],
119
+ testResource: ITTestResourceConfiguration,
120
+ artificer: ITestArtificer,
121
+ utils: INodeUtils
122
+ ) => Promise<ITestShape["isubject"]>;
123
+ beforeEach: (
124
+ subject: ITestShape["isubject"],
125
+ initializer: (c?) => ITestShape["given"],
126
+ artificer: ITestArtificer,
127
+ testResource: ITTestResourceConfiguration,
128
+ initialValues
129
+ // utils: IUtils
130
+ ) => Promise<ITestShape["istore"]>;
131
+ };
132
+ // & ITestInterface<ITestShape>;
133
+
134
+ export type ITestInterface<ITestShape extends IBaseTest> = {
135
+ assertThis: (x: ITestShape["then"]) => void;
136
+
137
+ andWhen: (
138
+ store: ITestShape["istore"],
139
+ whenCB: ITestShape["when"],
140
+ testResource: ITTestResourceConfiguration
141
+ ) => Promise<ITestShape["istore"]>;
142
+ butThen: (
143
+ store: ITestShape["istore"],
144
+ thenCB,
145
+ testResource: ITTestResourceConfiguration
146
+ ) => Promise<ITestShape["iselection"]>;
147
+
148
+ afterAll: (
149
+ store: ITestShape["istore"],
150
+ artificer: ITestArtificer,
151
+ utils: IUtils
152
+ ) => any;
153
+ afterEach: (
154
+ store: ITestShape["istore"],
155
+ key: string,
156
+ artificer: ITestArtificer,
157
+ utils: IUtils
158
+ ) => Promise<unknown>;
159
+ beforeAll: (
160
+ input: ITestShape["iinput"],
161
+ testResource: ITTestResourceConfiguration,
162
+ artificer: ITestArtificer,
163
+ utils: IUtils
164
+ ) => Promise<ITestShape["isubject"]>;
165
+ beforeEach: (
166
+ subject: ITestShape["isubject"],
167
+ initializer: (c?) => ITestShape["given"],
168
+ artificer: ITestArtificer,
169
+ testResource: ITTestResourceConfiguration,
170
+ initialValues
171
+ // utils: IUtils
172
+ ) => Promise<ITestShape["istore"]>;
173
+ };
174
+
175
+ export type ISuiteKlasser<ITestShape extends IBaseTest> = (
176
+ name: string,
177
+ index: number,
178
+ givens: IGivens<ITestShape>,
179
+ checks: BaseCheck<ITestShape>[]
180
+ ) => BaseSuite<ITestShape>;
181
+
182
+ export type IGivenKlasser<ITestShape extends IBaseTest> = (
183
+ name,
184
+ features,
185
+ whens,
186
+ thens,
187
+ givenCB
188
+ ) => BaseGiven<ITestShape>;
189
+
190
+ export type IWhenKlasser<ITestShape extends IBaseTest> = (
191
+ s,
192
+ o
193
+ ) => BaseWhen<ITestShape>;
194
+
195
+ export type IThenKlasser<ITestShape extends IBaseTest> = (
196
+ s,
197
+ o
198
+ ) => BaseThen<ITestShape>;
199
+
200
+ export type ICheckKlasser<ITestShape extends IBaseTest> = (
201
+ n,
202
+ f,
203
+ cb,
204
+ w,
205
+ t
206
+ ) => BaseCheck<ITestShape>;
package/src/preload.ts CHANGED
@@ -1,33 +1,17 @@
1
- import { ipcRenderer } from "electron";
1
+ import puppeteer from "puppeteer-core";
2
2
 
3
- console.log("hello preloader");
4
3
  import { NodeWriter } from "./NodeWriter";
4
+ import puppeteerConfiger from "./puppeteerConfiger";
5
5
 
6
6
  (window as any).NodeWriter = NodeWriter;
7
- (window as any).exit = (x) => {
8
- ipcRenderer.invoke('quit-app', x);
9
- }
10
7
 
11
- // var oldLog = console.log;
12
- // console.log = function (message) {
13
- // ipcRenderer.invoke('web-log', message.toString());
14
- // oldLog.apply(console, arguments);
15
- // };
16
-
17
- // var oldLog = console.error;
18
- // console.error = function (message) {
19
- // ipcRenderer.invoke('web-error', message.toString());
20
- // oldLog.apply(console, arguments);
21
- // };
22
-
23
- // var oldLog = console.warn;
24
- // console.warn = function (message) {
25
- // ipcRenderer.invoke('web-warn', message.toString());
26
- // oldLog.apply(console, arguments);
27
- // };
28
-
29
- // var oldLog = console.info;
30
- // console.info = function (message) {
31
- // ipcRenderer.invoke('web-info', message.toString());
32
- // oldLog.apply(console, arguments);
33
- // };
8
+ (window as any).browser = new Promise(async (res, rej) => {
9
+ const browser = await puppeteerConfiger("2999").then(async (json) => {
10
+ const b = await puppeteer.connect({
11
+ browserWSEndpoint: json.webSocketDebuggerUrl,
12
+ defaultViewport: null,
13
+ });
14
+ console.log("connected!", b.isConnected());
15
+ return res(b);
16
+ });
17
+ });