Skip to content

Commit bfa0550

Browse files
committed
[playground] Wait for Monaco to fully load
I'm not sure what exactly is causing the flakiness in the playground e2e tests but I suspect it's some kind of timing issue. Let's try waiting for Monaco to be fully initialized before running tests.
1 parent daade36 commit bfa0550

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

compiler/apps/playground/__tests__/e2e/page.spec.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ function nonReactFn() {
105105

106106
test('editor should open successfully', async ({page}) => {
107107
await page.goto(`/`, {waitUntil: 'networkidle'});
108+
await page.waitForFunction(
109+
() => typeof window['MonacoEnvironment'] !== 'undefined',
110+
);
108111
await page.screenshot({
109112
fullPage: true,
110113
path: 'test-results/00-fresh-page.png',
@@ -120,6 +123,9 @@ test('editor should compile from hash successfully', async ({page}) => {
120123
};
121124
const hash = encodeStore(store);
122125
await page.goto(`/#${hash}`, {waitUntil: 'networkidle'});
126+
await page.waitForFunction(
127+
() => typeof window['MonacoEnvironment'] !== 'undefined',
128+
);
123129

124130
// User input from hash compiles
125131
await page.screenshot({
@@ -143,6 +149,9 @@ test('reset button works', async ({page}) => {
143149
};
144150
const hash = encodeStore(store);
145151
await page.goto(`/#${hash}`, {waitUntil: 'networkidle'});
152+
await page.waitForFunction(
153+
() => typeof window['MonacoEnvironment'] !== 'undefined',
154+
);
146155

147156
// Reset button works
148157
page.on('dialog', dialog => dialog.accept());
@@ -166,6 +175,9 @@ TEST_CASE_INPUTS.forEach((t, idx) =>
166175
};
167176
const hash = encodeStore(store);
168177
await page.goto(`/#${hash}`, {waitUntil: 'networkidle'});
178+
await page.waitForFunction(
179+
() => typeof window['MonacoEnvironment'] !== 'undefined',
180+
);
169181
await page.screenshot({
170182
fullPage: true,
171183
path: `test-results/03-0${idx}-${t.name}.png`,

0 commit comments

Comments
 (0)