[optimizer] pretty-print jest snapshots to help reviews (#119404)

This commit is contained in:
Spencer 2021-11-22 16:40:33 -08:00 committed by GitHub
parent 220c8e9729
commit 03afedefe8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 625 additions and 9 deletions

File diff suppressed because one or more lines are too long

View file

@ -10,6 +10,7 @@ import Path from 'path';
import Fs from 'fs';
import Zlib from 'zlib';
import { inspect } from 'util';
import prettier from 'prettier';
import cpy from 'cpy';
import del from 'del';
@ -245,9 +246,13 @@ it('prepares assets for distribution', async () => {
* Verifies that the file matches the expected output and has matching compressed variants.
*/
const expectFileMatchesSnapshotWithCompression = (filePath: string, snapshotLabel: string) => {
const raw = Fs.readFileSync(Path.resolve(MOCK_REPO_DIR, filePath), 'utf8');
const path = Path.resolve(MOCK_REPO_DIR, filePath);
const raw = Fs.readFileSync(path, 'utf8');
const pretty = prettier.format(raw, {
filepath: path,
});
expect(raw).toMatchSnapshot(snapshotLabel);
expect(pretty).toMatchSnapshot(snapshotLabel);
// Verify the brotli variant matches
expect(