Skip to content

Commit

Permalink
fix(toHaveScreenshot): stylePath as first arg (#29372)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxschmitt authored Feb 5, 2024
1 parent 57d841f commit 8c007fd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/playwright/src/matchers/toMatchSnapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ export async function toHaveScreenshot(
expectTypes(pageOrLocator, ['Page', 'Locator'], 'toHaveScreenshot');
return await zones.preserve(async () => {
// Loading from filesystem resets zones.
const style = await loadScreenshotStyles(optOptions.stylePath || config?.stylePath);
const style = await loadScreenshotStyles(helper.allOptions.stylePath || config?.stylePath);
return toHaveScreenshotContinuation.call(this, helper, page, locator, config, style);
});
}
Expand Down
4 changes: 4 additions & 0 deletions tests/playwright-test/to-have-screenshot.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1272,6 +1272,7 @@ test('should support stylePath option', async ({ runInlineTest }) => {
snapshotPathTemplate: '__screenshots__/{testFilePath}/{arg}{ext}',
}),
'__screenshots__/tests/a.spec.js/snapshot.png': createImage(IMG_WIDTH, IMG_HEIGHT, 0, 255, 0),
'__screenshots__/tests/a.spec.js/png-1.png': createImage(IMG_WIDTH, IMG_HEIGHT, 0, 255, 0),
'screenshot.css': 'body { background: #00FF00; }',
'tests/a.spec.js': `
const { test, expect } = require('@playwright/test');
Expand All @@ -1280,6 +1281,9 @@ test('should support stylePath option', async ({ runInlineTest }) => {
await expect(page).toHaveScreenshot('snapshot.png', {
stylePath: './screenshot.css',
});
await expect(page).toHaveScreenshot({
stylePath: './screenshot.css',
});
});
`,
});
Expand Down

0 comments on commit 8c007fd

Please sign in to comment.