From 4068bd1c5f3cb4beaeb8e58a412168f942bbd065 Mon Sep 17 00:00:00 2001 From: Fedor Indutnyy Date: Wed, 5 Jan 2022 10:14:00 -0800 Subject: [PATCH] Fix tests --- test/snapshots/globTest.js.snap | 2 +- test/src/globTest.ts | 3 ++- test/src/helpers/packTester.ts | 19 +++++++++++++++++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/test/snapshots/globTest.js.snap b/test/snapshots/globTest.js.snap index 64799a8e6c0..e753b3ef41f 100644 --- a/test/snapshots/globTest.js.snap +++ b/test/snapshots/globTest.js.snap @@ -99,7 +99,7 @@ Object { exports[`outside link 2`] = ` Object { "offset": "5281", - "size": 4, + "size": "@size", } `; diff --git a/test/src/globTest.ts b/test/src/globTest.ts index afcc97c1ae3..e24b1ddc883 100644 --- a/test/src/globTest.ts +++ b/test/src/globTest.ts @@ -116,7 +116,8 @@ test.ifNotWindows( await fs.symlink(tempDir, path.join(projectDir, "o-dir")) }, packed: async context => { - expect((await readAsar(path.join(context.getResources(Platform.LINUX), "app.asar"))).getFile("o-dir/foo", false)).toMatchSnapshot() + const file = (await readAsar(path.join(context.getResources(Platform.LINUX), "app.asar"))).getFile("o-dir/foo", false) + expect(removeUnstableProperties(file)).toMatchSnapshot() }, } ) diff --git a/test/src/helpers/packTester.ts b/test/src/helpers/packTester.ts index 8173f8f203a..1fb9f402c48 100644 --- a/test/src/helpers/packTester.ts +++ b/test/src/helpers/packTester.ts @@ -521,6 +521,10 @@ export function removeUnstableProperties(data: any) { // to ensure that some property exists return `@${name}` } + // Keep existing test coverage + if (value.integrity) { + delete value.integrity + } return value }) ) @@ -528,8 +532,19 @@ export function removeUnstableProperties(data: any) { export async function verifyAsarFileTree(resourceDir: string) { const fs = await readAsar(path.join(resourceDir, "app.asar")) - // console.log(resourceDir + " " + JSON.stringify(fs.header, null, 2)) - expect(fs.header).toMatchSnapshot() + + const stableHeader = JSON.parse( + JSON.stringify(fs.header, (name, value) => { + // Keep existing test coverage + if (value.integrity) { + delete value.integrity + } + return value + }) + ) + + // console.log(resourceDir + " " + JSON.stringify(stableHeader, null, 2)) + expect(stableHeader).toMatchSnapshot() } export function toSystemIndependentPath(s: string): string {