codeceptjs 4.0.0-beta.10.esm-aria → 4.0.0-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.
- package/lib/container.js +15 -1
- package/lib/plugin/htmlReporter.js +4 -4
- package/package.json +1 -1
package/lib/container.js
CHANGED
|
@@ -690,13 +690,27 @@ async function loadSupportObject(modulePath, supportObjectName) {
|
|
|
690
690
|
const tsContent = fs.readFileSync(filePath, 'utf8')
|
|
691
691
|
|
|
692
692
|
// Transpile TypeScript to JavaScript with ES module output
|
|
693
|
-
|
|
693
|
+
let jsContent = transpile(tsContent, {
|
|
694
694
|
module: 99, // ModuleKind.ESNext
|
|
695
695
|
target: 99, // ScriptTarget.ESNext
|
|
696
696
|
esModuleInterop: true,
|
|
697
697
|
allowSyntheticDefaultImports: true,
|
|
698
698
|
})
|
|
699
699
|
|
|
700
|
+
// Check if the code uses __dirname or __filename (CommonJS globals)
|
|
701
|
+
const usesCommonJSGlobals = /__dirname|__filename/.test(jsContent)
|
|
702
|
+
|
|
703
|
+
if (usesCommonJSGlobals) {
|
|
704
|
+
// Inject ESM equivalents at the top of the file
|
|
705
|
+
const esmGlobals = `import { fileURLToPath as __fileURLToPath } from 'url';
|
|
706
|
+
import { dirname as __dirname_fn } from 'path';
|
|
707
|
+
const __filename = __fileURLToPath(import.meta.url);
|
|
708
|
+
const __dirname = __dirname_fn(__filename);
|
|
709
|
+
|
|
710
|
+
`
|
|
711
|
+
jsContent = esmGlobals + jsContent
|
|
712
|
+
}
|
|
713
|
+
|
|
700
714
|
return jsContent
|
|
701
715
|
}
|
|
702
716
|
|
|
@@ -143,7 +143,7 @@ export default function (config) {
|
|
|
143
143
|
|
|
144
144
|
event.dispatcher.on(event.step.finished, step => {
|
|
145
145
|
if (step.htmlReporterStartTime) {
|
|
146
|
-
step.
|
|
146
|
+
step.htmlReporterDuration = Date.now() - step.htmlReporterStartTime
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
// Serialize args immediately to preserve them through worker serialization
|
|
@@ -170,7 +170,7 @@ export default function (config) {
|
|
|
170
170
|
actor: step.actor,
|
|
171
171
|
args: serializedArgs,
|
|
172
172
|
status: step.failed ? 'failed' : 'success',
|
|
173
|
-
duration: step.duration || 0,
|
|
173
|
+
duration: step.htmlReporterDuration || step.duration || 0,
|
|
174
174
|
})
|
|
175
175
|
})
|
|
176
176
|
|
|
@@ -210,13 +210,13 @@ export default function (config) {
|
|
|
210
210
|
|
|
211
211
|
event.dispatcher.on(event.bddStep.finished, step => {
|
|
212
212
|
if (step.htmlReporterStartTime) {
|
|
213
|
-
step.
|
|
213
|
+
step.htmlReporterDuration = Date.now() - step.htmlReporterStartTime
|
|
214
214
|
}
|
|
215
215
|
currentBddSteps.push({
|
|
216
216
|
keyword: step.actor || 'Given',
|
|
217
217
|
text: step.name,
|
|
218
218
|
status: step.failed ? 'failed' : 'success',
|
|
219
|
-
duration: step.duration || 0,
|
|
219
|
+
duration: step.htmlReporterDuration || step.duration || 0,
|
|
220
220
|
comment: step.comment,
|
|
221
221
|
})
|
|
222
222
|
})
|