Issue 1:
System info

Playwright Version: v1.33.0

Operating System: macOS 13.3.1

Browser: Chromium

Other info:

Source code

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

Config file

// playwright.config.ts
const config = defineConfig({
testDir: './e2e',
/* Maximum time one test can run for - 30s */
timeout: 30000,
expect: {
/**
* Maximum time expect() should wait for the condition to be met.
* For example in `await expect(locator).toHaveText();`
*/
timeout: 10000,
},
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: IS_CI,
/* Retry on CI only */
retries: IS_CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: IS_CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
actionTimeout: 0,

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',

screenshot: 'only-on-failure',
},

globalTeardown: './e2e/setup/global-teardown.js',
globalSetup: './e2e/setup/global-setup.js',

/* Configure projects for major browsers */
projects,

/* Run your local dev server before starting the tests */
// webServer: {
// command: 'npm run start',
// url: 'http://127.0.0.1:3000',
// reuseExistingServer: !process.env.CI,
// },
});

// global-setup.js
async function globalSetup() {
console.log('SETUP....');
}

export default globalSetup;

// global-teardown.js
async function globalTeardown() {
console.log('TEARDOWN....');
}

export default globalTeardown;

Steps

[Run any test]

Observe that the globalSetup will log SETUP...

Observe that the globalTearDown will never run

Expected

globalTearDown should run after the test finishes

Actual

globalTearDown never runs after the test finishes

Screenshot:

[Describe actual behavior]

I expect globalTeardown to run once all tests finish, but this is not happening.

Any help on what I could be doing wrong would be much appreciated, but since globalSetup is running I believe it could be a bug.

Issue 2:
Context:

Playwright Version: 1.22

Operating System: Mac with Docker

Node.js version: 14.19

Browser: All

Extra: We are using Playwright for Visual Regression

Code Snippet

Running command:

docker run --rm --network=host --ipc=host -v $(pwd):/work/ mcr.microsoft.com/playwright:v1.22.0-focal bash -c 'cd work && npx playwright install && npx playwright test --update-snapshots'

playwright.config.ts

/* eslint-disable no-console */
import type { PlaywrightTestConfig } from '@playwright/test';
import { devices } from '@playwright/test';

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();

const port = global.process.env.PORT ? parseInt(global.process.env.PORT, 10) : 4200;
const url = `http://localhost:${port}`;

/**
* See https://playwright.dev/docs/test-configuration.
*/
const config: PlaywrightTestConfig = {
testDir: './tests',
/* Maximum time one test can run for. */
timeout: 100000,
expect: {
/**
* Maximum time expect() should wait for the condition to be met.
* For example in `await expect(locator).toHaveText();`
*/
timeout: 100000,
},
/* 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. See https://playwright.dev/docs/test-reporters */
reporter: [['line'], ['html']],
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
actionTimeout: 0,
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: url,

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},

/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: {
...devices['Desktop Chrome'],
},
},

{
name: 'firefox',
use: {
...devices['Desktop Firefox'],
},
},

{
name: 'webkit',
use: {
...devices['Desktop Safari'],
},
},
{
name: 'Mobile Chrome Portrait',
use: {
...devices['Pixel 5'],
},
},
{
name: 'Mobile Safari Portrait',
use: {
...devices['iPhone 12'],
},
},
{
name: 'Tablet Safari Portrait',
use: {
...devices['iPad (gen 7)'],
},
},
],

/* Folder for test artifacts such as screenshots, videos, traces, etc. */
// outputDir: 'test-results/',
webServer: {
command: `yarn start --port ${port}`,
url,
timeout: 300000,
},
/* Run your local dev server before starting the tests */
};

export default config;

urls.ts

/* eslint-disable sonarjs/no-duplicate-string */
interface PlaywrightUrl {
url: string;
pageName: string;
mask?: string[];
}

export const URLS: PlaywrightUrl[] = [
{
url: '/sign/in',
pageName: 'sign-in',
},
{
url: '/contact',
pageName: 'contact',
},
{
url: '/faq',
pageName: 'faq',
mask: ['app-faq-items'],
},
{
url: '/dashboard?login-token=token-demo',
pageName: 'dashboard',
mask: ['.layout__main-content'],
},
{
url: '/services/wizbii-drive/lessons?login-token=token-demo',
pageName: 'wizbii-drive-lessons',
},
{
url: '/services/wizbii-drive/series?login-token=token-demo',
pageName: 'wizbii-drive-series',
mask: ['.serie__action', '.serie__status'],
},
{
url: '/services/wizbii-drive/series?mode=training&login-token=token-demo',
pageName: 'wizbii-drive-series-training',
mask: ['.serie__action', '.serie__status'],
},
{
url: '/services/wizbii-drive/series?group-by=thematics&login-token=token-demo',
pageName: 'wizbii-drive-thematics',
},
{
url: '/services/wizbii-drive/series/thematics/l_legales?login-token=token-demo',
pageName: 'wizbii-drive-series-theme',
mask: ['.serie__action', '.serie__status'],
},
{
url: '/services/wizbii-drive/series/thematics/l_legales?mode=training&login-token=token-demo',
pageName: 'wizbii-drive-series-theme-training',
mask: ['.serie__action', '.serie__status'],
},
{
url: '/services/wizbii-drive/progress?login-token=token-demo',
pageName: 'wizbii-drive-progress',
mask: ['.serie__action', '.serie__status', '.graph-section'],
},
{
url: '/services/wizbii-drive/advices?login-token=token-demo',
pageName: 'wizbii-drive-advices',
mask: ['drive-advice-list-item'],
},
{
url: '/services/wizbii-blog?login-token=token-demo',
pageName: 'wizbii-blog-list',
mask: ['app-article-item'],
},
{
url: '/services/wizbii-blog?category=entrepreneuriat&login-token=token-demo',
pageName: 'wizbii-blog-list-category',
mask: ['app-article-item'],
},
];

visual-testing.spec.ts

import { expect, test } from '@playwright/test';
import { URLS } from './urls';

test.describe.configure({ mode: 'parallel' });

URLS.forEach(({ url, pageName, mask }) => {
test(`${pageName}`, async ({ page }) => {
await page.goto(url);
await page.waitForTimeout(5000);
expect(
await page.screenshot({
fullPage: true,
type: 'jpeg',
quality: 50,
...(mask && mask.length > 0 ? { mask: mask.map((m) => page.locator(m)) } : {}),
})
).toMatchSnapshot(`${pageName}.jpeg`, {
threshold: 0.4,
});
});
});

Describe the bug

When I'm running the command to update the local screenshots, i have this error on some pages

Error: maxMemoryUsageInMB limit exceeded by at least 6MB

I'm guessing it's from jpeg-js but i don't know how to increase the memory limit to not have this bug :/