Skip to content
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

[Snapshot testing] Improve test consistency #1103

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
clickContinueNext,
} from '../../../utils/navigation.utils';
import { checkSnapshot } from '../../../utils/snapshotTesting';
import { TIMEOUT_XS } from '../../../utils/timeoutConstants';
import { ResultUploadMessage, uploadFile } from '../../../utils/uploadFile';
import { verifyDownloadableReport } from '../../../utils/verifyDownloadableReport';

Expand Down Expand Up @@ -70,6 +71,7 @@ test('Resolve Errors (Logic)', async ({ page, navigateToUploadFile }) => {
await expect(page3row1.getByRole('cell').nth(0)).toHaveText('62');
await expect(page3row1.getByRole('cell').nth(2)).toHaveText('999');
await expect(page3row1.getByRole('cell').nth(3)).toHaveText('1');
await page.waitForTimeout(2 * TIMEOUT_XS);
await checkSnapshot(page);
};

Expand Down
8 changes: 8 additions & 0 deletions e2e/utils/snapshotModifications.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
a {
/*
Dotted borders are inconsistently rendered, causing test flake.
Since this is a border style defined in the CFPB Design System,
we should be safe not validating this styling as part of our app testing.
*/
border-style: solid;
}
13 changes: 11 additions & 2 deletions e2e/utils/snapshotTesting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,17 @@ import { expect } from '@playwright/test';
export const checkSnapshot = async (page: Page, options = {}) => {
if (process.env.SBL_ENABLE_PLAYWRIGHT_SNAPSHOT_TESTING === 'true') {
await expect(page).toHaveScreenshot({
fullPage: true, // Verify the full page
mask: [page.locator('.snapshot-ignore')], // Ignore flagged areas
// Verify the full page
fullPage: true,
mask: [
// Ignore flagged areas
page.locator('.snapshot-ignore'),
// USA flag in header is flaky in very tall snapshots
page.locator('.u-usa-flag'),
],
// CSS modifications to reduce flake (see CSS file for details)
stylePath: 'e2e/utils/snapshotModifications.css',
// Any option overrides provided on a test-by-test basis
...options,
});
}
Expand Down
4 changes: 1 addition & 3 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ const config: PlaywrightTestConfig = {
timeout: TIMEOUT_EXPECT,
/* Snapshot testing */
toHaveScreenshot: {
// High enough to ignore dotted border flakiness
// but low enough to catch meaningful diffs??
maxDiffPixels: 25,
maxDiffPixels: 0,
},
},
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
Expand Down
Loading