codeceptjs 4.0.1-beta.10 → 4.0.1-beta.12

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.
@@ -142,8 +142,13 @@ const __dirname = __dirname_fn(__filename);
142
142
  }
143
143
  }
144
144
 
145
- // Try adding .ts extension if file doesn't exist and no extension provided
146
- if (!path.extname(importedPath)) {
145
+ // Check for standard module extensions to determine if we should try adding .ts
146
+ const ext = path.extname(importedPath)
147
+ const standardExtensions = ['.js', '.mjs', '.cjs', '.json', '.node']
148
+ const hasStandardExtension = standardExtensions.includes(ext.toLowerCase())
149
+
150
+ // If it doesn't end with .ts and doesn't have a standard extension, try adding .ts
151
+ if (!importedPath.endsWith('.ts') && !hasStandardExtension) {
147
152
  const tsPath = importedPath + '.ts'
148
153
  if (fs.existsSync(tsPath)) {
149
154
  importedPath = tsPath
@@ -168,6 +173,7 @@ const __dirname = __dirname_fn(__filename);
168
173
  /from\s+['"](\..+?)(?:\.ts)?['"]/g,
169
174
  (match, importPath) => {
170
175
  let resolvedPath = path.resolve(fileBaseDir, importPath)
176
+ const originalExt = path.extname(importPath)
171
177
 
172
178
  // Handle .js extension that might be .ts
173
179
  if (resolvedPath.endsWith('.js')) {
@@ -181,6 +187,8 @@ const __dirname = __dirname_fn(__filename);
181
187
  }
182
188
  return `from '${relPath}'`
183
189
  }
190
+ // Keep .js extension as-is (might be a real .js file)
191
+ return match
184
192
  }
185
193
 
186
194
  // Try with .ts extension
@@ -197,6 +205,18 @@ const __dirname = __dirname_fn(__filename);
197
205
  return `from '${relPath}'`
198
206
  }
199
207
 
208
+ // If the import doesn't have a standard module extension (.js, .mjs, .cjs, .json)
209
+ // add .js for ESM compatibility
210
+ // This handles cases where:
211
+ // 1. Import has no real extension (e.g., "./utils" or "./helper")
212
+ // 2. Import has a non-standard extension that's part of the name (e.g., "./abstract.helper")
213
+ const standardExtensions = ['.js', '.mjs', '.cjs', '.json', '.node']
214
+ const hasStandardExtension = standardExtensions.includes(originalExt.toLowerCase())
215
+
216
+ if (!hasStandardExtension) {
217
+ return match.replace(importPath, importPath + '.js')
218
+ }
219
+
200
220
  // Otherwise, keep the import as-is
201
221
  return match
202
222
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeceptjs",
3
- "version": "4.0.1-beta.10",
3
+ "version": "4.0.1-beta.12",
4
4
  "type": "module",
5
5
  "description": "Supercharged End 2 End Testing Framework for NodeJS",
6
6
  "keywords": [