[playground] Wait for Monaco to fully load (#32584)
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. --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/32584). * __->__ #32584 * #32583
lauren committed
Mar 12, 2025 at 17:47 UTC
26bca0005c7ef82a733c23f08baa1e2b8d702ec9
1 file changed
+12
compiler/apps/playground/__tests__/e2e/page.spec.ts
+12
@@ -105,6 +105,9 @@ function nonReactFn() {
105
106
test('editor should open successfully', async ({page}) => {
107
await page.goto(`/`, {waitUntil: 'networkidle'});
108
+ await page.waitForFunction(
109
+ () => typeof window['MonacoEnvironment'] !== 'undefined',
110
+ );
111
await page.screenshot({
112
fullPage: true,
113
path: 'test-results/00-fresh-page.png',
@@ -120,6 +123,9 @@ test('editor should compile from hash successfully', async ({page}) => {
123
};
124
const hash = encodeStore(store);
125
await page.goto(`/#${hash}`, {waitUntil: 'networkidle'});
126
+ await page.waitForFunction(
127
+ () => typeof window['MonacoEnvironment'] !== 'undefined',
128
+ );
129
130
// User input from hash compiles
131
await page.screenshot({
@@ -143,6 +149,9 @@ test('reset button works', async ({page}) => {
149
};
150
const hash = encodeStore(store);
151
await page.goto(`/#${hash}`, {waitUntil: 'networkidle'});
152
+ await page.waitForFunction(
153
+ () => typeof window['MonacoEnvironment'] !== 'undefined',
154
+ );
155
156
// Reset button works
157
page.on('dialog', dialog => dialog.accept());
@@ -166,6 +175,9 @@ TEST_CASE_INPUTS.forEach((t, idx) =>
175
};
176
const hash = encodeStore(store);
177
await page.goto(`/#${hash}`, {waitUntil: 'networkidle'});
178
+ await page.waitForFunction(
179
+ () => typeof window['MonacoEnvironment'] !== 'undefined',
180
+ );
181
await page.screenshot({
182
fullPage: true,
183
path: `test-results/03-0${idx}-${t.name}.png`,