feat(@angular/build): run vitest browser with playwright with OS theme#32470
feat(@angular/build): run vitest browser with playwright with OS theme#32470clydin merged 1 commit intoangular:mainfrom
Conversation
|
Thank you for the contribution. |
b071ab2 to
626f76e
Compare
|
@clydin I tried to copying await writeFile(
'src/app/app.spec.ts',
`
import { test, expect } from 'vitest';
test('should pass', () => {
const mm = matchMedia('(prefers-color-scheme: dark)');
expect(mm.matches).toBe(true);
});
`,
);For now, I added a test that checks that |
|
There's a formatting issue for |
626f76e to
baee26d
Compare
Oops, sorry! 😅 I ran formatting and pushed the formatting changes. |
|
This PR was merged into the repository. The changes were merged into the following branches:
|
PR Checklist
Please check to confirm your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: #32469
Using Vitest with
@vitest/browser-playwrightwill open browser withlightmode every time when running tests, even if theme toggle is used.What is the new behavior?
Using Vitest with
@vitest/browser-playwrightwill open browser usingprefers-color-schemefrom OS overlightdefault in Playwright.Does this PR introduce a breaking change?
Setting the value like this affects the entire browser, and not just the Vitest UI. If any components with styles runs expecting
lightbut gettingdarkviaprefers-color-scheme, then tests may fail if tests rely onlightbeing the default.An alternative approach could be to only modify the
vueuse-color-schemeforlocalhost:<port>viacontextOptions.storageStateinstead.Another option would be to create an
angular.jsonoption for@angular/build:unit-testsuch that it's possible to opt-in to changing this default.Other information
I can create a test for this after feedback on which option would be best for this; current PR code, using
storageState, or adding aoptionconfig value.Would it be best to modify the existing playwright test, or add a new one, when testing this? (https://github.com/angular/angular-cli/blob/main/tests/e2e/tests/vitest/browser-playwright.ts#L19)