Skip to content

Commit bbd06b5

Browse files
Merge pull request #478 from preactjs/test-flaky
Guard against race condition in test assertion
2 parents 2c47fcc + e44f4a0 commit bbd06b5

File tree

1 file changed

+13
-3
lines changed
  • packages/wmr/test/fixtures/dynamic-import

1 file changed

+13
-3
lines changed

packages/wmr/test/fixtures/dynamic-import/index.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
console.log('hello from index.js');
2-
const pages = ['one', 'two'];
3-
const mods = Promise.all(pages.map(page => import(`./pages/${page}.js`))).then(m => {
2+
3+
// eslint-disable-next-line no-async-promise-executor
4+
const mods = new Promise(async resolve => {
5+
let out = [];
6+
7+
// Use a for loop to ensure a consistent loading order
8+
for (const page of ['one', 'two']) {
9+
const m = await import(`./pages/${page}.js`);
10+
out.push(m);
11+
}
12+
413
console.log('loaded pages');
5-
console.log(m.map(m => m.default).join());
14+
console.log(out.map(m => m.default).join());
15+
resolve(out);
616
});
717

818
export async function prerender() {

0 commit comments

Comments
 (0)