Issue 1:
System info

Playwright Version: 1.32.3

Operating System: Windows 10 Pro

Browser: Chromium

Other info:

Source code

[x ] I provided exact source code that allows reproducing the issue locally.

Link to the GitHub repository with the repro

or

Config file

import { defineConfig, devices } from '@playwright/test';

export default defineConfig({

testMatch: '*.e2e.test.ts',

testDir: './tests',

fullyParallel: true,

forbidOnly: !!process.env.CI,

retries: process.env.CI ? 2 : 0,

workers: process.env.CI ? 1 : undefined,

reporter: 'html',

use: {

headless: true,

trace: 'on-first-retry',

screenshot: 'only-on-failure',

video: 'retain-on-failure',

},

projects: [

// Setup project for authentication and capturing the authenticated state in user.json file.

{

name: 'setup',

testDir: './src/common',

testMatch: /.*.e2e.setup.ts/,

},

{

name: 'chromium',

use: {

...devices['Desktop Chrome'],

// Use prepared auth state.

storageState: 'playwright/.auth/user.json',

},

dependencies: ['setup'],

},

]

});

Test file (self-contained)

import { test as setup, expect } from '@playwright/test'
import {fxLoginConfig} from '../config/test-tenant-config'
const authFile = 'playwright/.auth/user.json';

//This test will authenticate and store the state of authentication in a cookie. That cookie will be used to run all the tests in chromium project.
setup('authenticate', async ({ page,context}) => {
const managerTabName= 'manager';
await context.clearCookies();
await setup.step('authenticate', async() =>{
await page.goto(fxLoginConfig.address);
const logo = page.locator('data-testid=login-logo');
await expect(logo).toBeVisible();

await page.locator('data-testid=login-page-wrapper');
await page.locator('data-testid=input-login-email-input').fill(fxLoginConfig.username);
await page.locator('data-testid=input-login-pw-input').fill(fxLoginConfig.username);
await page.locator('data-testid=login-button').click();

await page.waitForURL(/.*\/manager/);
await expect(page).toHaveURL(/.*\/manager/);
await expect(page.locator(`id=${managerTabName}`)).toBeVisible();
(await page.context().storageState({ path: authFile }));
});

});

navigation.ts
import { test, expect, Page } from '@playwright/test';
import {navigateToSideBar, navigateToTab,clickBackButton} from '../src/common/navigation';
import {performanceMark, performanceMeasure} from '../src/common/';

test.describe('navigation flow tests', () => {
const manager = 'manager',
modeler:string ='modeler',

test.beforeEach(async ({ page }, testInfo) => {
console.log(`Running ${testInfo.title}`);
await page.goto('/');
});

test('navigate from Manager Tab to Modeler> Members ', async ({ page },testinfo) => {
await performanceMark("mark1");

await test.step('navigate to Modeler Tab', async() =>{
await goToModlerTab(page, modeler);
})

await test.step('navigate to Data Modeler ', async() =>{
await navigateToSideBar(page,'Data Modeler',modeler);
})

await test.step('navigate to Members', async() =>{
await navigateToSideBar(page,'Members',members);
})

await performanceMark("mark2");
await performanceMeasure(testinfo.title,"measuring Navigation", "mark1", "mark2")
});

Steps

[Run the test]

[...]

Expected

Authentication test should run first, which updated the storage state in user.json file. Then Navigation test runs based on logged in state.

Actual

When running the tests, user.json file gets updated at the end of test run, rather than at the end of dependency project test run.

1st run, navigation test gives error 'SyntaxError: Error reading storage state from playwright/.auth/user.json:

Unexpected end of JSON input'.

Authentication test runs and passes and updated user.json file.

2nd run, since user.json is now populated, the navigation test runs.

First Run:

2nd run:

Issue 2:
System info

Playwright Version: 1.31.2

Operating System: All

Browser: Chromium

Other info:

Source code

I provided exact source code that allows reproducing the issue locally.

Test file (self-contained) test.js

const { chromium } = require('playwright');

(async () => {
const browser = await chromium.launch({
headless: false
});
const context = await browser.newContext();
const page = await context.newPage();
page.on('console', msg => console.log("> CONSOLE:", msg));
page.on('pageerror', err => console.log("> PAGEERROR:", err));

await page.goto(`https://vaadin-database-example.demo.vaadin.com/`);
await page.waitForTimeout(2000);

await context.close();
await browser.close();
})();

Steps

install playwright dependency npm install playwright

run the provided .js script node test.js

Expected

In the terminal output we should see a message like:

> CONSOLE: Could not find style data in module named shared-styles
> CONSOLE: Failed to load resource: the server responded with a status of 404 (https://vaadin-database-example.demo.vaadin.com/favicon.ico)

Actual

Resource url is not displayed

> CONSOLE: Could not find style data in module named shared-styles
> CONSOLE: Failed to load resource: the server responded with a status of 404 ()

Note that if you open the chromium console in dev tools the resource is correctly displayed