mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
fix(expect): toHaveCSS with custom CSS properties (#12709)
This commit is contained in:
parent
acae63c409
commit
adcd32fc6e
@ -999,7 +999,7 @@ export class InjectedScript {
|
|||||||
} else if (expression === 'to.have.class') {
|
} else if (expression === 'to.have.class') {
|
||||||
received = element.className;
|
received = element.className;
|
||||||
} else if (expression === 'to.have.css') {
|
} else if (expression === 'to.have.css') {
|
||||||
received = (window.getComputedStyle(element) as any)[options.expressionArg];
|
received = window.getComputedStyle(element).getPropertyValue(options.expressionArg);
|
||||||
} else if (expression === 'to.have.id') {
|
} else if (expression === 'to.have.id') {
|
||||||
received = element.id;
|
received = element.id;
|
||||||
} else if (expression === 'to.have.text') {
|
} else if (expression === 'to.have.text') {
|
||||||
|
@ -308,9 +308,15 @@ test('should support toHaveCSS', async ({ runInlineTest }) => {
|
|||||||
const locator = page.locator('#node');
|
const locator = page.locator('#node');
|
||||||
await expect(locator).toHaveCSS('color', 'rgb(255, 0, 0)');
|
await expect(locator).toHaveCSS('color', 'rgb(255, 0, 0)');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('pass with custom css properties', async ({ page }) => {
|
||||||
|
await page.setContent('<div id=node style="--custom-color-property:#FF00FF;">Text content</div>');
|
||||||
|
const locator = page.locator('#node');
|
||||||
|
await expect(locator).toHaveCSS('--custom-color-property', '#FF00FF');
|
||||||
|
});
|
||||||
`,
|
`,
|
||||||
}, { workers: 1 });
|
}, { workers: 1 });
|
||||||
expect(result.passed).toBe(1);
|
expect(result.passed).toBe(2);
|
||||||
expect(result.exitCode).toBe(0);
|
expect(result.exitCode).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user