AI generated playwright tests failing for simple use cases in firebase studio / How to setup playright \ testing in firebase studio?

All tests keep on failing with following config and test file
\playwright.config.ts
import { defineConfig, devices } from ‘@playwright/test’;

/**

  • See
    */
    export default defineConfig({
    testDir: ‘./tests’,

/* Run tests in files in parallel */
fullyParallel: true,

/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,

/* Retry on CI only */
retries: process.env.CI ? 2 : 0,

/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,

/* Reporter to use.
reporter: ‘html’,

/* Shared settings for all the projects below. See */
use: {

/* Base URL to use in actions like await page.goto('/'). */
baseURL: ’

/* Collect trace when retrying the failed test. See Trace viewer | Playwright */
trace: ‘on-first-retry’,

// Run in headless mode for containerized environments

// headless: true,
},

/* Configure projects for major browsers */
projects: [
{
name: ‘chromium’,
use: { …devices[‘Desktop Chrome’] },
},
],

/* Run your local dev server before starting the tests */
webServer: {
command: ‘npm run dev’,
url: ‘ht…’,
reuseExistingServer: !process.env.CI,
timeout: 120 * 1000,
},
});
smoke.ts
import { test, expect, Page } from ‘@playwright/test’;

test.describe(‘Smoke Test’, () => {
test(‘should load the homepage successfully’, async ({
page
}) => {

// 1. Navigate to the root URL
await
page
.goto(‘/’);

// 2. Wait for the authentication check to complete by looking for the login/dashboard button.

// This is a stable element to check against before proceeding.
await expect(

page
.getByRole(‘link’, { name: /Login|Go to Dashboard/ })
).toBeVisible();

// 3. Check for the main heading to ensure the page has rendered
const mainHeading =
page
.getByRole(‘heading’, { name: ‘’ });

// 4. Assert that the heading is visible
await expect(mainHeading).toBeVisible();
});
});
failed [chromium] › tests/smoke.spec.ts:4:7 › Smoke Test › should load the homepage successfully ──────
16 |
17 | // 4. Assert that the heading is visible

18 | await expect(mainHeading).toBeVisible();
| ^
19 | });
20 | });
21 |
at /home/use

Hi @firebasestudio
Are you using the airules.md file in your .idx directory to provide specific instructions and environment architecture rules?

No I am not using airules.md

Add playwright as your testing framework to airules.md or create a GEMINI.md file in your root directory and add it there. This will help when working with the model to understand your constraints.