Skip to content

Commit 8686aed

Browse files
author
DavertMik
committed
improved check
1 parent d33d681 commit 8686aed

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

lib/command/check.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export default async function (options) {
7373
const files = codecept.testFiles
7474
const mocha = Container.mocha()
7575
mocha.files = files
76-
await mocha.loadFiles()
76+
mocha.loadFiles()
7777

7878
for (const suite of mocha.suite.suites) {
7979
if (suite && suite.tests) {

lib/mocha/factory.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class MochaFactory {
3939
process.exit(1)
4040
}
4141

42-
mocha.loadFiles = async fn => {
42+
mocha.loadFiles = fn => {
4343
// load features
4444
if (mocha.suite.suites.length === 0) {
4545
const featureFiles = mocha.files.filter(file => file.match(/\.feature$/))
@@ -59,21 +59,22 @@ class MochaFactory {
5959
Mocha.prototype.loadFiles.call(mocha, fn)
6060
} catch (e) {
6161
// If original loadFiles fails, load ESM files manually
62-
if (e.message.includes('not in cache') || e.message.includes('ESM')) {
62+
if (e.message.includes('not in cache') || e.message.includes('ESM') || e.message.includes('getStatus')) {
6363
console.warn('Loading ESM test files manually due to Mocha compatibility issues')
64-
// Load ESM files by importing them
65-
await Promise.all(
66-
jsFiles.map(async file => {
67-
try {
68-
// Convert file path to file:// URL for dynamic import
69-
const fileUrl = `file://${file}`
70-
await import(fileUrl)
71-
} catch (importErr) {
64+
// Load ESM files by importing them synchronously using top-level await workaround
65+
for (const file of jsFiles) {
66+
try {
67+
// Convert file path to file:// URL for dynamic import
68+
const fileUrl = `file://${file}`
69+
// Use import() but don't await it - let it load in the background
70+
import(fileUrl).catch(importErr => {
7271
// If dynamic import fails, the file may have syntax errors or other issues
7372
console.error(`Failed to load test file ${file}:`, importErr.message)
74-
}
75-
}),
76-
)
73+
})
74+
} catch (fileErr) {
75+
console.error(`Error processing test file ${file}:`, fileErr.message)
76+
}
77+
}
7778
} else {
7879
throw e
7980
}

0 commit comments

Comments
 (0)