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

Co-authored-by: Spencer <email@spalger.com>
This commit is contained in:
Kibana Machine 2021-11-22 21:01:35 -05:00 committed by GitHub
parent f9ca3485b9
commit 3b847efc59
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(