Issue 1:
Context:

Playwright Version: [1.16.3]

Operating System: [Mac]

Node.js version: [16.12.0]

Browser: [Chrome]

Extra: [#10150]

This bug is follow up of #10150

I ran into issues while doing further testing with the suggested approach.

Code Snippet

Issue #1

If i have same title in multiple spec files, i get warning message, although i have different spec files, i see this warning when i run the test with suggested approach.

` duplicate test titles are not allowed.

title: pw1_test test
test/pw1_test_spec.js:6
test/pw2_test_spec.js:6
`

Issue #2

storageState in test.use is not respected, if i have different storage states in each spec file, it doesn't load the storageState when the test runs

playwright.config

// playwright.config.js
// @ts-check

/** @type {import('@playwright/test').PlaywrightTestConfig} */
const config = {
workers: 1,
globalTimeout: 0,
globalSetup: './global-setup.js',
reporter: [
['list']
],
reportSlowTests: null,
projects: [
{
name: 'Test1',
testDir: './test',
testMatch: 'sequence1.spec.js',
retries: 0,
use: {
browserName: 'chromium',
channel: 'chrome',
headless: false,
viewport: {width: 1600, height: 825},
ignoreHTTPSErrors: true,
trace: "off",
screenshot: "only-on-failure",
acceptDownloads:true,
},
},
]

};
module.exports = config;

global-setup.js

const { chromium, Browser, BrowserContext } = require('@playwright/test');

module.exports = async () => {

const browser = await chromium.launch({
headless: false
});
const context = await browser.newContext();

// Open new page
const page = await context.newPage();
await page.context().storageState({path: 'empty_storage.json'});

// Go to https://github.com/
await page.goto('https://github.com/');

// Click text=Sign in
await page.click('text=Sign in');
// assert.equal(page.url(), 'https://github.com/login');

// Fill input[name="login"]
await page.fill('input[name="login"]', '');

// Fill input[name="password"]
await page.fill('input[name="password"]', '');

// Click input:has-text("Sign in")
await page.click('input:has-text("Sign in")');
// assert.equal(page.url(), 'https://github.com/');

await page.context().storageState({path: 'login_storage.json'});

// ---------------------
await context.close();
await browser.close();

}

sequence1.spec.js

require('./pw1_test_spec.js');
require('./pw2_test_spec.js');

pw1_test_spec.js

const {test,expect} = require("@playwright/test");

test.use({storageState: 'login_storage.json'});
test.describe('pw1_test', () => {

test('test', async ({ page }) => {

// Go to https://github.com/
await page.goto('https://github.com/');

// Click text=Pull requests
await page.click('text=Pull requests');
await expect(page).toHaveURL('https://github.com/pulls');

});
});

pw2_test_spec.js

const {test,expect} = require("@playwright/test");

test.use({storageState: 'empty_storage.json'});
test.describe('pw2_test', () => {

test('test', async ({ page }) => {

// Go to https://github.com/
await page.goto('https://gmail.com/');

});
});

Describe the bug

Provide login credentials to GitHub in global-setup.js

global-setup will create two storageState files, one for GitHub and other for empty storageState

When pw1_test_spec.js is executed, it will redirect to login page instead of using the storageState

If i exclude pw2_test_spec.js from the sequence file, i won't be redirected to login page

Kindly let me know if you need any other information.

Issue 2:
Context:

Playwright Version: 1.17.1

Operating System: Windows

Node.js version: 17.0.1

Browser: Chromium

Describe the bug

A first step for migrating our Protractor tests most likely will be to migrate them 1:1.

Lengthy tests depending on the previous tests, also doing UI-based login and some other setup steps in beforeAll blocks. So not nearly as isolated as we'd like.

I noticed the tracing behaves a bit odd for when the page was created in the beforeAll like this.

I've attached playwright-beforeall-trace-strangeness.zip with source code and html report with traces.

When viewing the report and navigating to the traces:

The filmstrips for both test 1 and test 2 are mostly dominated by the beforeAll step.

The first action of the actual test (page.goto) occupies a large part of the timeline bar.

But the filmstrip for the same time period shows only screenshots of the beforeAll step.

Further to the right, the timeline bars are also out of sync with the film strip.

The actions pane is showing only the actual test actions (nothing from the beforeAll).

(Hard to describe, but hope it's clear like this)

My preferred fix would be one of:

beforeAll and first test combined in one trace, but with also the beforeAll actions shown, and timeline bars and filmstrip properly aligned/in sync.

a separate trace for beforeAll (ideally also with a separate beforeAll item in the report).