Skip to content

[pull] main from microsoft:main #119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/src/test-api/class-testproject.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ Filter to only run tests with a title matching one of the patterns. For example,
* since: v1.10
- type: ?<[RegExp]|[Array]<[RegExp]>>

Filter to only run tests with a title **not** matching one of the patterns. This is the opposite of [`property: TestProject.grep`]. Also available globally and in the [command line](../test-cli.md) with the `--grep-invert` option.
Filter to only run tests with a title **not** matching any of the patterns. This is the opposite of [`property: TestProject.grep`]. Also available globally and in the [command line](../test-cli.md) with the `--grep-invert` option.

`grepInvert` option is also useful for [tagging tests](../test-annotations.md#tag-tests).

Expand Down
3 changes: 2 additions & 1 deletion packages/playwright/src/common/configLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const defineConfig = (...configs: any[]) => {
let result = configs[0];
for (let i = 1; i < configs.length; ++i) {
const config = configs[i];
const prevProjects = result.projects;
result = {
...result,
...config,
Expand Down Expand Up @@ -63,7 +64,7 @@ export const defineConfig = (...configs: any[]) => {
projectOverrides.set(project.name, project);

const projects = [];
for (const project of result.projects || []) {
for (const project of prevProjects || []) {
const projectOverride = projectOverrides.get(project.name);
if (projectOverride) {
projects.push({
Expand Down
2 changes: 1 addition & 1 deletion packages/playwright/types/test.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ interface TestProject<TestArgs = {}, WorkerArgs = {}> {
grep?: RegExp|Array<RegExp>;

/**
* Filter to only run tests with a title **not** matching one of the patterns. This is the opposite of
* Filter to only run tests with a title **not** matching any of the patterns. This is the opposite of
* [testProject.grep](https://playwright.dev/docs/api/class-testproject#test-project-grep). Also available globally
* and in the [command line](https://playwright.dev/docs/test-cli) with the `--grep-invert` option.
*
Expand Down
31 changes: 29 additions & 2 deletions tests/playwright-test/config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -661,8 +661,8 @@ test('should merge configs', async ({ runInlineTest }) => {
use: { foo: 1, bar: 2 },
expect: { timeout: 12 },
projects: [
{ name: 'B', timeout: 40, use: {} },
{ name: 'A', timeout: 50, use: {} }
{ name: 'A', timeout: 50, use: {} },
{ name: 'B', timeout: 40 },
],
webServer: [{
command: 'echo 123',
Expand All @@ -680,6 +680,33 @@ test('should merge configs', async ({ runInlineTest }) => {
expect(result.exitCode).toBe(0);
});

test('should merge projects in the config', async ({ runInlineTest }) => {
const result = await runInlineTest({
'playwright.config.ts': `
import { defineConfig, expect } from '@playwright/test';
const baseConfig = defineConfig({
projects: [{ name: 'A', timeout: 5_000 }, { name: 'B', timeout: 6_000 }],
});
const derivedConfig = defineConfig(baseConfig, {
projects: [{ name: 'A', timeout: 7_000 }, { name: 'C', timeout: 8_000 }],
});

expect(derivedConfig).toEqual(expect.objectContaining({
projects: [
{ name: 'A', timeout: 7_000, use: {} },
{ name: 'B', timeout: 6_000 },
{ name: 'C', timeout: 8_000 },
],
}));
`,
'a.test.ts': `
import { test } from '@playwright/test';
test('pass', async ({}) => {});
`
});
expect(result.exitCode).toBe(0);
});

test('should merge ct configs', async ({ runInlineTest }) => {
const result = await runInlineTest({
'playwright.config.ts': `
Expand Down
Loading