codeceptjs 4.0.1-beta.15 → 4.0.1-beta.17

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.
@@ -41,7 +41,7 @@ const getDefinitionsFileContent = ({ hasCustomHelper, hasCustomStepsFile, helper
41
41
 
42
42
  const importPathsFragment = importPaths.join('\n')
43
43
  const supportObjectsTypeFragment = convertMapToType(supportObject)
44
- const methodsTypeFragment = helperNames.length > 0 ? `interface Methods extends ${helperNames.join(', ')} {}` : ''
44
+ const methodsTypeFragment = helperNames.length > 0 ? `interface Methods extends ${helperNames.join(', ')} {}` : 'interface Methods {}'
45
45
  const translatedActionsFragment = JSON.stringify(translations.vocabulary.actions, null, 2)
46
46
 
47
47
  return generateDefinitionsContent({
@@ -1389,6 +1389,7 @@ class Playwright extends Helper {
1389
1389
  }
1390
1390
  }
1391
1391
 
1392
+ // Close browserContext if recordHar is enabled
1392
1393
  if (this.options.recordHar && this.browserContext) {
1393
1394
  try {
1394
1395
  await this.browserContext.close()
@@ -1398,16 +1399,16 @@ class Playwright extends Helper {
1398
1399
  }
1399
1400
  this.browserContext = null
1400
1401
 
1402
+ // Initiate browser close without waiting for it to complete
1403
+ // The browser process will be cleaned up when the Node process exits
1401
1404
  if (this.browser) {
1402
1405
  try {
1403
- // Add timeout to prevent browser.close() from hanging indefinitely
1404
- await Promise.race([this.browser.close(), new Promise((_, reject) => setTimeout(() => reject(new Error('Browser close timeout')), 5000))])
1406
+ // Fire and forget - don't wait for close to complete
1407
+ this.browser.close().catch(() => {
1408
+ // Silently ignore any errors during async close
1409
+ })
1405
1410
  } catch (e) {
1406
- // Ignore errors if browser is already closed or timeout
1407
- if (!e.message?.includes('Browser close timeout')) {
1408
- // Non-timeout error, can be ignored as well
1409
- }
1410
- // Force cleanup even on error
1411
+ // Ignore any synchronous errors
1411
1412
  }
1412
1413
  }
1413
1414
  this.browser = null
@@ -62,34 +62,9 @@ class MochaFactory {
62
62
  const jsFiles = this.files.filter(file => !file.match(/\.feature$/))
63
63
  this.files = this.files.filter(file => !file.match(/\.feature$/))
64
64
 
65
- // Load JavaScript test files using ESM imports
65
+ // Load JavaScript test files using original loadFiles
66
66
  if (jsFiles.length > 0) {
67
- try {
68
- // Try original loadFiles first for compatibility
69
- originalLoadFiles.call(this, fn)
70
- } catch (e) {
71
- // If original loadFiles fails, load ESM files manually
72
- if (e.message.includes('not in cache') || e.message.includes('ESM') || e.message.includes('getStatus')) {
73
- // Load ESM files by importing them synchronously using top-level await workaround
74
- for (const file of jsFiles) {
75
- try {
76
- // Convert file path to file:// URL for dynamic import
77
- const fileUrl = `file://${file}`
78
- // Use import() but don't await it - let it load in the background
79
- import(fileUrl).catch(importErr => {
80
- // If dynamic import fails, the file may have syntax errors or other issues
81
- console.error(`Failed to load test file ${file}:`, importErr.message)
82
- })
83
- if (fn) fn()
84
- } catch (fileErr) {
85
- console.error(`Error processing test file ${file}:`, fileErr.message)
86
- if (fn) fn(fileErr)
87
- }
88
- }
89
- } else {
90
- throw e
91
- }
92
- }
67
+ originalLoadFiles.call(this, fn)
93
68
  }
94
69
 
95
70
  // add ids for each test and check uniqueness
@@ -65,9 +65,18 @@ CodeceptJS 4.x uses ES Modules (ESM) and requires a loader to run TypeScript tes
65
65
  ✅ Complete: Handles all TypeScript features
66
66
 
67
67
  ┌─────────────────────────────────────────────────────────────────────────────┐
68
- │ Option 2: ts-node/esm (Alternative - Established, Requires Config)
68
+ │ Option 2: ts-node/esm (Not Recommended - Has Module Resolution Issues)
69
69
  └─────────────────────────────────────────────────────────────────────────────┘
70
70
 
71
+ ⚠️ ts-node/esm has significant limitations and is not recommended:
72
+ - Doesn't work with "type": "module" in package.json
73
+ - Module resolution doesn't work like standard TypeScript ESM
74
+ - Import statements must use explicit file paths
75
+
76
+ We strongly recommend using tsx/cjs instead.
77
+
78
+ If you still want to use ts-node/esm:
79
+
71
80
  Installation:
72
81
  npm install --save-dev ts-node
73
82
 
@@ -84,11 +93,12 @@ CodeceptJS 4.x uses ES Modules (ESM) and requires a loader to run TypeScript tes
84
93
  "esModuleInterop": true
85
94
  },
86
95
  "ts-node": {
87
- "esm": true,
88
- "experimentalSpecifierResolution": "node"
96
+ "esm": true
89
97
  }
90
98
  }
91
99
 
100
+ 3. Do NOT use "type": "module" in package.json
101
+
92
102
  📚 Documentation: https://codecept.io/typescript
93
103
 
94
104
  Note: TypeScript config files (codecept.conf.ts) and helpers are automatically
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeceptjs",
3
- "version": "4.0.1-beta.15",
3
+ "version": "4.0.1-beta.17",
4
4
  "type": "module",
5
5
  "description": "Supercharged End 2 End Testing Framework for NodeJS",
6
6
  "keywords": [