@@ -5,7 +5,15 @@ import { isMainThread } from 'worker_threads'
55import debugModule from 'debug'
66const debug = debugModule ( 'codeceptjs:container' )
77import { MetaStep } from './step.js'
8- import { methodsOfObject , fileExists , isFunction , isAsyncFunction , installedLocally , deepMerge } from './utils.js'
8+ import {
9+ methodsOfObject ,
10+ fileExists ,
11+ isFunction ,
12+ isAsyncFunction ,
13+ installedLocally ,
14+ deepMerge ,
15+ isWindows ,
16+ } from './utils.js'
917import { transpileTypeScript , cleanupTempFiles , fixErrorStack } from './utils/typescript.js'
1018import Translation from './translation.js'
1119import MochaFactory from './mocha/factory.js'
@@ -17,6 +25,7 @@ import Result from './result.js'
1725import ai from './ai.js'
1826import actorFactory from './actor.js'
1927import Config from './config.js'
28+ import { pathToFileURL } from 'url'
2029
2130let asyncHelperPromise
2231
@@ -434,7 +443,7 @@ async function requireHelperFromModule(helperName, config, HelperClass) {
434443 try {
435444 // For built-in helpers, use direct relative import with .js extension
436445 const helperPath = `${ moduleName } .js`
437- const mod = await import ( helperPath )
446+ const mod = isWindows ( ) ? await import ( pathToFileURL ( helperPath ) . href ) : await import ( helperPath )
438447 HelperClass = mod . default || mod
439448 } catch ( err ) {
440449 throw err
@@ -472,7 +481,7 @@ async function requireHelperFromModule(helperName, config, HelperClass) {
472481 // check if the new syntax export default HelperName is used and loads the Helper, otherwise loads the module that used old syntax export = HelperName.
473482 try {
474483 // Try dynamic import for both CommonJS and ESM modules
475- const mod = await import ( importPath )
484+ const mod = isWindows ( ) ? await import ( pathToFileURL ( importPath ) . href ) : await import ( importPath )
476485 if ( ! mod && ! mod . default ) {
477486 throw new Error ( `Helper module '${ moduleName } ' was not found. Make sure you have installed the package correctly.` )
478487 }
@@ -488,7 +497,7 @@ async function requireHelperFromModule(helperName, config, HelperClass) {
488497 if ( fileMapping ) {
489498 fixErrorStack ( err , fileMapping )
490499 }
491-
500+
492501 // Clean up temp files before rethrowing
493502 if ( tempJsFile ) {
494503 const filesToClean = Array . isArray ( tempJsFile ) ? tempJsFile : [ tempJsFile ]
@@ -683,7 +692,7 @@ async function loadPluginAsync(modulePath, config) {
683692 let pluginMod
684693 try {
685694 // Try dynamic import first (works for both ESM and CJS)
686- pluginMod = await import ( modulePath )
695+ pluginMod = isWindows ( ) ? await import ( pathToFileURL ( modulePath ) . href ) : await import ( modulePath )
687696 } catch ( err ) {
688697 throw new Error ( `Could not load plugin from '${ modulePath } ': ${ err . message } ` )
689698 }
@@ -896,7 +905,7 @@ async function loadSupportObject(modulePath, supportObjectName) {
896905 if ( fileMapping ) {
897906 fixErrorStack ( importError , fileMapping )
898907 }
899-
908+
900909 // Clean up temp files if created before rethrowing
901910 if ( tempJsFile ) {
902911 const filesToClean = Array . isArray ( tempJsFile ) ? tempJsFile : [ tempJsFile ]
0 commit comments