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
@@ -1,18 +1,18 @@
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: ['./node_modules/testeranto/dist/cjs-shim.js'],
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
17
  "electron",
18
18
  "path",
@@ -28,18 +28,21 @@ export default (config, entryPoints) => {
28
28
  "readline",
29
29
  "zlib",
30
30
  "crypto",
31
- "https"
31
+ "https",
32
32
  ], platform: "browser", entryPoints: [...entryPoints], plugins: [
33
33
  ...(config.webPlugins || []),
34
34
  {
35
- name: 'rebuild-notify',
35
+ name: "rebuild-notify",
36
36
  setup(build) {
37
- build.onEnd(result => {
37
+ build.onEnd((result) => {
38
38
  console.log(`web build ended with ${result.errors.length} errors`);
39
- console.log(result);
40
- result.errors.length !== 0 && process.exit(-1);
39
+ if (result.errors.length > 0) {
40
+ console.log(result);
41
+ }
42
+ // console.log(result);
43
+ // result.errors.length !== 0 && process.exit(-1);
41
44
  });
42
- }
45
+ },
43
46
  },
44
47
  ] });
45
48
  };
@@ -43,7 +43,14 @@ export class BaseSuite {
43
43
  // @TODO fix me
44
44
  for (const k of Object.keys(this.givens)) {
45
45
  const giver = this.givens[k];
46
- giver.afterAll(this.store, artifactory, utils);
46
+ try {
47
+ giver.afterAll(this.store, artifactory, utils);
48
+ }
49
+ catch (e) {
50
+ console.error(e);
51
+ this.fails.push(giver);
52
+ return this;
53
+ }
47
54
  }
48
55
  ////////////////
49
56
  return this;
@@ -73,7 +80,7 @@ export class BaseGiven {
73
80
  features: this.features,
74
81
  };
75
82
  }
76
- async afterEach(store, key, artifactory) {
83
+ async afterEach(store, key, artifactory, utils) {
77
84
  return store;
78
85
  }
79
86
  async give(subject, key, testResourceConfiguration, tester, artifactory, tLog, utils) {
@@ -98,7 +105,7 @@ export class BaseGiven {
98
105
  }
99
106
  finally {
100
107
  try {
101
- await this.afterEach(this.store, key, givenArtifactory);
108
+ await this.afterEach(this.store, key, givenArtifactory, utils);
102
109
  }
103
110
  catch (e) {
104
111
  console.error("afterEach failed! no error will be recorded!", e);
@@ -143,7 +150,7 @@ export class BaseThen {
143
150
  async test(store, testResourceConfiguration, tLog, utils) {
144
151
  tLog(" Then:", this.name);
145
152
  try {
146
- const x = (await this.butThen(store, this.thenCB, testResourceConfiguration));
153
+ const x = await this.butThen(store, this.thenCB, testResourceConfiguration);
147
154
  return x;
148
155
  }
149
156
  catch (e) {
@@ -161,7 +168,7 @@ export class BaseCheck {
161
168
  this.whens = whens;
162
169
  this.thens = thens;
163
170
  }
164
- async afterEach(store, key, cb) {
171
+ async afterEach(store, key, cb, utils) {
165
172
  return;
166
173
  }
167
174
  async check(subject, key, testResourceConfiguration, tester, artifactory, tLog, utils) {
@@ -179,7 +186,7 @@ export class BaseCheck {
179
186
  };
180
187
  return a;
181
188
  }, {}));
182
- await this.afterEach(store, key);
189
+ await this.afterEach(store, key, () => { }, utils);
183
190
  return;
184
191
  }
185
192
  }
@@ -29,33 +29,33 @@ export class BaseBuilder {
29
29
  name: "",
30
30
  fs: ".",
31
31
  ports: [],
32
- scheduled: false
32
+ scheduled: false,
33
33
  }, y) {
34
34
  console.log(`testResourceConfiguration ${JSON.stringify(testResourceConfiguration, null, 2)}`);
35
- await logWriter.mkdirSync(testResourceConfiguration.fs);
35
+ // await logWriter.mkdirSync(testResourceConfiguration.fs);
36
+ // if (!fs.existsSync(destFolder)) {
37
+ // fs.mkdirSync(destFolder, { recursive: true });
38
+ // }
36
39
  logWriter.writeFileSync(`${testResourceConfiguration.fs}/tests.json`, JSON.stringify(this.toObj(), null, 2));
37
40
  const logFilePath = `${testResourceConfiguration.fs}/log.txt`;
38
41
  const access = await logWriter.createWriteStream(logFilePath);
39
- const tLog = (...l) => {
40
- // console.log(...l);
41
- access.write(`${l.toString()}\n`);
42
- };
42
+ const tLog = (...l) => access.write(`${l.toString()}\n`);
43
43
  const suiteDone = await runner(testResourceConfiguration, tLog, y);
44
- const resultsFilePath = (`${testResourceConfiguration.fs}/results.json`);
45
- logWriter.writeFileSync(resultsFilePath, JSON.stringify(suiteDone.toObj(), null, 2));
46
44
  const logPromise = new Promise((res, rej) => {
47
- access.on("finish", () => { res(true); });
45
+ access.on("finish", () => {
46
+ res(true);
47
+ });
48
48
  });
49
49
  access.end();
50
50
  const numberOfFailures = Object.keys(suiteDone.givens).filter((k) => {
51
- // console.log(`suiteDone.givens[k].error`, suiteDone.givens[k].error);
52
51
  return suiteDone.givens[k].error;
53
52
  }).length;
53
+ logWriter.writeFileSync(`${testResourceConfiguration.fs}/exitcode`, numberOfFailures.toString());
54
54
  console.log(`exiting gracefully with ${numberOfFailures} failures.`);
55
55
  return {
56
56
  failed: numberOfFailures,
57
57
  artifacts: this.artifacts || [],
58
- logPromise
58
+ logPromise,
59
59
  };
60
60
  },
61
61
  };
@@ -7,10 +7,9 @@ export class ClassBuilder extends BaseBuilder {
7
7
  };
8
8
  return a;
9
9
  }, {});
10
- const classyGivens = Object.entries(testImplementation.givens)
11
- .reduce((a, [key, givEn]) => {
10
+ const classyGivens = Object.entries(testImplementation.givens).reduce((a, [key, givEn]) => {
12
11
  a[key] = (features, whens, thens, givEn) => {
13
- return new (givenKlasser.prototype).constructor(key, features, whens, thens, testImplementation.givens[key], givEn);
12
+ return new givenKlasser.prototype.constructor(key, features, whens, thens, testImplementation.givens[key], givEn);
14
13
  };
15
14
  return a;
16
15
  }, {});
@@ -1,5 +1,5 @@
1
- import { DefaultTestInterface, defaultTestResourceRequirement } from "./index.js";
2
- import { BaseSuite, BaseGiven, BaseWhen, BaseThen, BaseCheck } from "./abstractBase.js";
1
+ import { DefaultTestInterface, defaultTestResourceRequirement, } from "./index.js";
2
+ import { BaseSuite, BaseGiven, BaseWhen, BaseThen, BaseCheck, } from "./abstractBase.js";
3
3
  import { ClassBuilder } from "./classBuilder.js";
4
4
  export default class Testeranto extends ClassBuilder {
5
5
  constructor(input, testSpecification, testImplementation, testResourceRequirement = defaultTestResourceRequirement, logWriter, testInterface) {
@@ -8,20 +8,49 @@ export default class Testeranto extends ClassBuilder {
8
8
  assertThat(t) {
9
9
  fullTestInterface.assertThis(t);
10
10
  }
11
- async setup(s, artifactory, tr) {
12
- return (fullTestInterface.beforeAll || (async (input, artifactory, tr) => input))(s, this.testResourceConfiguration, artifactory);
11
+ async setup(s, artifactory, tr, utils) {
12
+ return (fullTestInterface.beforeAll ||
13
+ (async (input, artifactory, tr, utils) => input))(s, this.testResourceConfiguration, artifactory, utils);
13
14
  }
14
15
  }, class Given extends BaseGiven {
15
16
  async givenThat(subject, testResource, artifactory, initializer) {
16
17
  return fullTestInterface.beforeEach(subject, initializer, (fPath, value) =>
17
18
  // TODO does not work?
18
- artifactory(`beforeEach/${fPath}`, value), testResource, this.initialValues);
19
+ artifactory(`beforeEach/${fPath}`, value), testResource, this.initialValues
20
+ // utils,
21
+ );
19
22
  }
20
- afterEach(store, key, artifactory) {
21
- return new Promise((res) => res(fullTestInterface.afterEach(store, key, (fPath, value) => artifactory(`after/${fPath}`, value))));
23
+ afterEach(store, key, artifactory, utils) {
24
+ return new Promise((res) => res(fullTestInterface.afterEach(store, key, (fPath, value) => artifactory(`after/${fPath}`, value), utils)));
22
25
  }
23
26
  afterAll(store, artifactory, utils) {
24
- return fullTestInterface.afterAll(store, (fPath, value) => { artifactory(`afterAll4-${this.name}/${fPath}`, value); }, utils);
27
+ const pagesHandler = {
28
+ get(target, prop) {
29
+ console.log(`Getting pages property ${prop}`);
30
+ return target[prop];
31
+ },
32
+ };
33
+ const browserHandler = {
34
+ get(target, prop) {
35
+ console.log(`Getting browser property ${prop}`);
36
+ if (prop === "pages") {
37
+ // return target[prop];
38
+ return new Proxy(target[prop], pagesHandler);
39
+ }
40
+ else {
41
+ return target[prop];
42
+ }
43
+ },
44
+ };
45
+ const proxy = new Proxy(utils.browser, browserHandler);
46
+ return fullTestInterface.afterAll(store, (fPath, value) => {
47
+ artifactory(`afterAll4-${this.name}/${fPath}`, value);
48
+ }, utils
49
+ // {
50
+ // ...utils,
51
+ // browser: proxy,
52
+ // }
53
+ );
25
54
  }
26
55
  }, class When extends BaseWhen {
27
56
  async andWhen(store, whenCB, testResource) {
@@ -39,10 +68,10 @@ export default class Testeranto extends ClassBuilder {
39
68
  async checkThat(subject, testResourceConfiguration, artifactory) {
40
69
  return fullTestInterface.beforeEach(subject, this.initialValues, (fPath, value) => artifactory(`before/${fPath}`, value), testResourceConfiguration, this.initialValues);
41
70
  }
42
- afterEach(store, key, artifactory) {
71
+ afterEach(store, key, artifactory, utils) {
43
72
  return new Promise((res) => res(fullTestInterface.afterEach(store, key, (fPath, value) =>
44
73
  // TODO does not work?
45
- artifactory(`afterEach2-${this.name}/${fPath}`, value))));
74
+ artifactory(`afterEach2-${this.name}/${fPath}`, value), utils)));
46
75
  }
47
76
  }, testResourceRequirement, logWriter);
48
77
  }
@@ -1,15 +1,17 @@
1
1
  export const BaseTestInterface = {
2
- beforeAll: (async (s) => s),
3
- beforeEach: async function (subject, initialValues, testResource) { return subject; },
4
- afterEach: (async (s) => s),
5
- afterAll: ((store) => undefined),
6
- butThen: (async (store, thenCb) => thenCb(store)),
7
- andWhen: ((a) => a),
8
- assertThis: (() => null),
2
+ beforeAll: async (s) => s,
3
+ beforeEach: async function (subject, initialValues, testResource) {
4
+ return subject;
5
+ },
6
+ afterEach: async (s) => s,
7
+ afterAll: (store) => undefined,
8
+ butThen: async (store, thenCb) => thenCb(store),
9
+ andWhen: (a) => a,
10
+ assertThis: () => null,
9
11
  };
10
12
  export const DefaultTestInterface = (p) => {
11
13
  return Object.assign(Object.assign({}, BaseTestInterface), p);
12
14
  };
13
15
  export const defaultTestResourceRequirement = {
14
- ports: 0
16
+ ports: 0,
15
17
  };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,27 +1,14 @@
1
- import { ipcRenderer } from "electron";
2
- console.log("hello preloader");
1
+ import puppeteer from "puppeteer-core";
3
2
  import { NodeWriter } from "./NodeWriter";
3
+ import puppeteerConfiger from "./puppeteerConfiger";
4
4
  window.NodeWriter = NodeWriter;
5
- window.exit = (x) => {
6
- ipcRenderer.invoke('quit-app', x);
7
- };
8
- // var oldLog = console.log;
9
- // console.log = function (message) {
10
- // ipcRenderer.invoke('web-log', message.toString());
11
- // oldLog.apply(console, arguments);
12
- // };
13
- // var oldLog = console.error;
14
- // console.error = function (message) {
15
- // ipcRenderer.invoke('web-error', message.toString());
16
- // oldLog.apply(console, arguments);
17
- // };
18
- // var oldLog = console.warn;
19
- // console.warn = function (message) {
20
- // ipcRenderer.invoke('web-warn', message.toString());
21
- // oldLog.apply(console, arguments);
22
- // };
23
- // var oldLog = console.info;
24
- // console.info = function (message) {
25
- // ipcRenderer.invoke('web-info', message.toString());
26
- // oldLog.apply(console, arguments);
27
- // };
5
+ window.browser = new Promise(async (res, rej) => {
6
+ const browser = await puppeteerConfiger("2999").then(async (json) => {
7
+ const b = await puppeteer.connect({
8
+ browserWSEndpoint: json.webSocketDebuggerUrl,
9
+ defaultViewport: null,
10
+ });
11
+ console.log("connected!", b.isConnected());
12
+ return res(b);
13
+ });
14
+ });
@@ -0,0 +1,19 @@
1
+ import http from "http";
2
+ export default async (port) => new Promise((resolve, reject) => {
3
+ let json = "";
4
+ const request = http.request({
5
+ host: "127.0.0.1",
6
+ path: "/json/version",
7
+ port,
8
+ }, (response) => {
9
+ response.on("error", reject);
10
+ response.on("data", (chunk) => {
11
+ json += chunk.toString();
12
+ });
13
+ response.on("end", () => {
14
+ resolve(JSON.parse(json));
15
+ });
16
+ });
17
+ request.on("error", reject);
18
+ request.end();
19
+ });