Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,17 @@ export async function setupBrowserConfiguration(
launchOptions: {
executablePath: process.env.CHROME_BIN,
},
contextOptions: {
// Enables `prefer-color-scheme` for Vitest browser instead of `light`
colorScheme: null,
},
});
} else if (providerName === 'playwright') {
provider = providerFactory({
contextOptions: {
// Enables `prefer-color-scheme` for Vitest browser instead of `light`
colorScheme: null,
},
});
} else {
provider = providerFactory();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('setupBrowserConfiguration', () => {
);
await writeFile(
join(playwrightPkgPath, 'index.js'),
'module.exports = { playwright: () => ({ name: "playwright" }) };',
'module.exports = { playwright: (options) => ({ name: "playwright", options }) };',
);
});

Expand Down Expand Up @@ -135,6 +135,23 @@ describe('setupBrowserConfiguration', () => {
}
});

// See: https://github.com/angular/angular-cli/issues/32469
it('should pass colorScheme=null to Playwright provider', async () => {
const { browser } = await setupBrowserConfiguration(
['ChromeHeadless'],
undefined,
false,
workspaceRoot,
undefined,
);

expect(browser?.provider?.options).toEqual(jasmine.objectContaining({
contextOptions: jasmine.objectContaining({
colorScheme: null,
}),
}));
});

it('should support Preview provider forcing headless false', async () => {
// Create mock preview package
const previewPkgPath = join(workspaceRoot, 'node_modules/@vitest/browser-preview');
Expand Down
Loading