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

fix: allow toMatchSnapshot to use text comparator for text data #12934

Merged

Conversation

aslushnikov
Copy link
Collaborator

@aslushnikov aslushnikov commented Mar 21, 2022

This was regressed awhile ago.

In v1.17 we shipped the following code:

const expected = fs.readFileSync(snapshotFile);
const extension = path.extname(snapshotFile).substring(1);
const mimeType = extensionToMimeType[extension] || 'application/octet-string';
const comparator = GoldenComparators[mimeType];
if (!comparator) {
return {
pass: false,
message: 'Failed to find comparator with type ' + mimeType + ': ' + snapshotFile,
};
}

toMatchSnapshot should fallback to text comparator in case of
unknown extension and string data.

Fixes #12862

@aslushnikov aslushnikov force-pushed the default-to-text-comparison-comparator branch from 3509708 to 079dda4 Compare March 21, 2022 21:55
@aslushnikov aslushnikov changed the title default to text comparison comparator fix: allow toMatchSnapshot to use text comparator for text data Mar 21, 2022
`toMatchSnapshot` should fallback to text comparator in case of
unknown extension and string data.

Fixes microsoft#12862
@aslushnikov aslushnikov force-pushed the default-to-text-comparison-comparator branch from 92a6bef to 456b5b4 Compare March 21, 2022 22:28
@aslushnikov aslushnikov merged commit 7f51336 into microsoft:main Mar 21, 2022
@aslushnikov aslushnikov deleted the default-to-text-comparison-comparator branch March 21, 2022 23:42
aslushnikov added a commit to aslushnikov/playwright that referenced this pull request Mar 21, 2022
…rator for text data

This was regressed awhile ago.

In v1.17 we shipped the following code: https://github.com/microsoft/playwright/blob/30e15ad36f011c7adf5bad86beadd50ca93b01b8/packages/playwright-test/src/matchers/golden.ts#L122-L131

`toMatchSnapshot` should fallback to text comparator in case of
unknown extension and string data.

Fixes microsoft#12862
aslushnikov added a commit that referenced this pull request Mar 22, 2022
… text data (#12938)

This was regressed awhile ago.

In v1.17 we shipped the following code: https://github.com/microsoft/playwright/blob/30e15ad36f011c7adf5bad86beadd50ca93b01b8/packages/playwright-test/src/matchers/golden.ts#L122-L131

`toMatchSnapshot` should fallback to text comparator in case of
unknown extension and string data.

Fixes #12862
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Allow to use toMatchSnapshot for file formats other than txt (e.g. csv)
2 participants