Skip to content

Commit 8bdcf8b

Browse files
committed
Anticipate asynchronous loads
1 parent e919b40 commit 8bdcf8b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/worker/subprocess.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require('./ensure-forked'); // eslint-disable-line import/no-unassigned-import
66
const ipc = require('./ipc');
77

88
ipc.send({type: 'ready-for-options'});
9-
ipc.options.then(options => {
9+
ipc.options.then(async options => {
1010
require('./options').set(options);
1111
require('../chalk').set(options.chalkOptions);
1212

@@ -126,7 +126,7 @@ ipc.options.then(options => {
126126
}
127127

128128
let requireFn = require;
129-
const load = ref => {
129+
const load = async ref => {
130130
for (const extension of extensionsToLoadAsModules) {
131131
if (ref.endsWith(`.${extension}`)) {
132132
ipc.send({type: 'internal-error', err: serializeError('Internal runner error', false, new Error('AVA cannot yet load ESM files.'))});
@@ -143,8 +143,8 @@ ipc.options.then(options => {
143143
};
144144

145145
try {
146-
for (const ref of (options.require || [])) {
147-
const mod = load(ref);
146+
for await (const ref of (options.require || [])) {
147+
const mod = await load(ref);
148148

149149
try {
150150
if (Reflect.has(mod, Symbol.for('esm:package'))) {
@@ -164,7 +164,7 @@ ipc.options.then(options => {
164164
}
165165
}
166166

167-
load(testPath);
167+
await load(testPath);
168168

169169
if (accessedRunner) {
170170
// Unreference the IPC channel if the test file required AVA. This stops it

0 commit comments

Comments
 (0)