codeceptjs 4.1.0-beta.1-esm-mocha → 4.2.0-beta.1

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 (49) hide show
  1. package/docs/alternative-browsers.md +153 -0
  2. package/docs/basics.md +9 -1
  3. package/docs/configuration.md +2 -0
  4. package/docs/helpers/CDPBrowser.md +2138 -0
  5. package/docs/helpers/Kitesurf.md +118 -0
  6. package/docs/helpers/Obscura.md +210 -0
  7. package/docs/migration-4.md +3 -1
  8. package/docs/parallel.md +10 -0
  9. package/docs/playwright.md +19 -0
  10. package/docs/plugins/screencast.md +18 -13
  11. package/docs/plugins.md +1 -1
  12. package/lib/command/info.js +11 -3
  13. package/lib/command/workers/runTests.js +14 -20
  14. package/lib/container.js +6 -0
  15. package/lib/data/context.js +10 -1
  16. package/lib/element/WebElement.js +5 -0
  17. package/lib/globals.js +2 -4
  18. package/lib/helper/Appium.js +22 -6
  19. package/lib/helper/CDPBrowser.js +3004 -0
  20. package/lib/helper/GraphQL.js +0 -8
  21. package/lib/helper/GraphQLDataFactory.js +0 -9
  22. package/lib/helper/Kitesurf.js +139 -0
  23. package/lib/helper/Obscura.js +344 -0
  24. package/lib/helper/Playwright.js +30 -3
  25. package/lib/helper/Puppeteer.js +43 -16
  26. package/lib/helper/WebDriver.js +43 -8
  27. package/lib/helper/clientscripts/cdpBrowserClient.js +486 -0
  28. package/lib/helper/clientscripts/xpathPolyfill.js +31 -0
  29. package/lib/helper/extras/CDPConnection.js +92 -0
  30. package/lib/helper/extras/CDPElementHandle.js +27 -0
  31. package/lib/helper/extras/apngAssembler.js +156 -0
  32. package/lib/html.js +9 -2
  33. package/lib/listener/retryEnhancer.js +2 -1
  34. package/lib/listener/steps.js +8 -0
  35. package/lib/mocha/hooks.js +10 -0
  36. package/lib/mocha/loadTests.js +9 -2
  37. package/lib/parser.js +14 -2
  38. package/lib/plugin/junitReporter.js +44 -7
  39. package/lib/plugin/screencast.js +116 -24
  40. package/lib/rerun.js +1 -1
  41. package/lib/step/base.js +15 -3
  42. package/lib/utils/loaderCheck.js +6 -0
  43. package/lib/utils/typescript.js +3 -1
  44. package/lib/utils.js +1 -1
  45. package/lib/workers.js +17 -0
  46. package/package.json +9 -6
  47. package/typings/index.d.ts +1 -0
  48. package/typings/promiseBasedTypes.d.ts +1833 -0
  49. package/typings/types.d.ts +1840 -0
@@ -385,7 +385,9 @@ const __dirname = __dirname_fn(__filename);
385
385
  )
386
386
 
387
387
  // Write the transpiled file with updated imports
388
- const tempFile = filePath.replace(/\.ts$/, '.temp.mjs')
388
+ // Include process.pid + a random suffix so concurrent run-multiple workers
389
+ // don't write to and delete each other's temp files (see issue #5642).
390
+ const tempFile = filePath.replace(/\.ts$/, `.${process.pid}.${Math.random().toString(36).slice(2, 10)}.temp.mjs`)
389
391
  fs.writeFileSync(tempFile, jsContent)
390
392
  transpiledFiles.set(filePath, tempFile)
391
393
  }
package/lib/utils.js CHANGED
@@ -108,7 +108,7 @@ export const methodsOfObject = function (obj, className) {
108
108
  export const template = function (template, data) {
109
109
  return template.replace(/{{([^{}]*)}}/g, (a, b) => {
110
110
  const r = data[b]
111
- if (r === undefined) return ''
111
+ if (r === undefined || r === null) return ''
112
112
  return r.toString()
113
113
  })
114
114
  }
package/lib/workers.js CHANGED
@@ -508,10 +508,27 @@ class Workers extends EventEmitter {
508
508
  // Create workers and set up message handlers immediately (not in recorder queue)
509
509
  // This prevents a race condition where workers start sending messages before handlers are attached
510
510
  const workerThreads = []
511
+ const staggerDelay = this.codecept.config.workerInitializationDelay !== undefined
512
+ ? this.codecept.config.workerInitializationDelay
513
+ : 200
514
+
515
+ // Maximum total stagger window (default 10 seconds). Allows capping total delay regardless of worker count.
516
+ const maxStagger = this.codecept.config.workerInitializationMaxDelay ?? 10000
517
+ // Compute effective per-worker delay to keep total stagger within maxStagger.
518
+ const effectiveDelay = staggerDelay > 0
519
+ ? Math.min(staggerDelay, Math.floor(maxStagger / Math.max(1, this.workers.length - 1)))
520
+ : 0
521
+
511
522
  for (const worker of this.workers) {
512
523
  const workerThread = createWorker(worker, this.isPoolMode)
513
524
  this._listenWorkerEvents(workerThread)
514
525
  workerThreads.push(workerThread)
526
+
527
+ // Stagger worker creation to prevent CPU spikes
528
+ // from massive V8 isolate creation and naturally stagger browser init
529
+ if (this.workers.length > 1 && effectiveDelay > 0) {
530
+ await new Promise(resolve => setTimeout(resolve, effectiveDelay))
531
+ }
515
532
  }
516
533
 
517
534
  recorder.add('workers started', () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeceptjs",
3
- "version": "4.1.0-beta.1-esm-mocha",
3
+ "version": "4.2.0-beta.1",
4
4
  "type": "module",
5
5
  "description": "Supercharged End 2 End Testing Framework for NodeJS",
6
6
  "keywords": [
@@ -78,6 +78,8 @@
78
78
  "test:unit:webbapi:puppeteer": "mocha test/helper/Puppeteer_test.js --reporter @testomatio/reporter/mocha",
79
79
  "test:unit:webbapi:webDriver": "mocha test/helper/WebDriver_test.js --timeout 10000 --reporter @testomatio/reporter/mocha",
80
80
  "test:unit:webbapi:webDriver:noSeleniumServer": "mocha test/helper/WebDriver.noSeleniumServer_test.js --timeout 10000 --reporter @testomatio/reporter/mocha",
81
+ "test:unit:webbapi:cdpbrowser": "mocha test/helper/CDPBrowser_chrome_test.js --timeout 30000 --reporter @testomatio/reporter/mocha",
82
+ "test:unit:webbapi:obscura": "mocha test/helper/CDPBrowser_obscura_test.js --timeout 30000 --reporter @testomatio/reporter/mocha",
81
83
  "test:unit:expect": "mocha test/helper/Expect_test.js --reporter @testomatio/reporter/mocha",
82
84
  "test:plugin": "mocha test/plugin/plugin_test.js --reporter @testomatio/reporter/mocha",
83
85
  "def": "./runok.cjs def",
@@ -97,7 +99,7 @@
97
99
  "@cucumber/gherkin": "38.0.0",
98
100
  "@cucumber/messages": "32.3.1",
99
101
  "@modelcontextprotocol/sdk": "^1.26.0",
100
- "@xmldom/xmldom": "0.9.8",
102
+ "@xmldom/xmldom": "0.9.10",
101
103
  "acorn": "8.15.0",
102
104
  "ai": "^6.0.43",
103
105
  "arrify": "3.0.0",
@@ -125,7 +127,7 @@
125
127
  "lodash.shuffle": "4.2.0",
126
128
  "mkdirp": "3.0.1",
127
129
  "mocha": "11.7.5",
128
- "monocart-coverage-reports": "2.12.9",
130
+ "monocart-coverage-reports": "2.12.12",
129
131
  "ms": "2.1.3",
130
132
  "multer": "^2.0.2",
131
133
  "ora-classic": "5.4.2",
@@ -134,6 +136,7 @@
134
136
  "promise-retry": "1.1.1",
135
137
  "sprintf-js": "1.1.3",
136
138
  "uuid": "11.1.0",
139
+ "ws": "^8.21.2",
137
140
  "xpath": "0.0.34",
138
141
  "zod": "^4.1.11"
139
142
  },
@@ -155,7 +158,7 @@
155
158
  "@wdio/sauce-service": "9.12.5",
156
159
  "@wdio/selenium-standalone-service": "8.15.0",
157
160
  "@wdio/utils": "9.23.3",
158
- "@xmldom/xmldom": "0.9.8",
161
+ "@xmldom/xmldom": "0.9.10",
159
162
  "bunosh": "latest",
160
163
  "chai": "^6.2.1",
161
164
  "chai-as-promised": "^8.0.2",
@@ -164,11 +167,11 @@
164
167
  "electron": "40.2.1",
165
168
  "eslint": "^9.36.0",
166
169
  "eslint-plugin-import": "2.32.0",
167
- "eslint-plugin-mocha": "11.2.0",
170
+ "eslint-plugin-mocha": "11.3.0",
168
171
  "expect": "30.2.0",
169
172
  "express": "^5.1.0",
170
173
  "globals": "17.3.0",
171
- "graphql": "16.12.0",
174
+ "graphql": "16.14.2",
172
175
  "graphql-tag": "^2.12.6",
173
176
  "husky": "9.1.7",
174
177
  "jsdoc": "^3.6.11",
@@ -464,6 +464,7 @@ declare namespace CodeceptJS {
464
464
  | { shadow: string[] }
465
465
  | { custom: string }
466
466
  | { pw: string }
467
+ | { role: string; name?: string; text?: string; exact?: boolean }
467
468
  interface CustomLocators {}
468
469
  interface OtherLocators {
469
470
  props?: object