From ed928eb9496976349fe60f042e3800321a0a1e52 Mon Sep 17 00:00:00 2001 From: Frederik Bolding Date: Tue, 10 Dec 2024 12:29:03 +0100 Subject: [PATCH] Mock version in manifest test --- .../src/commands/manifest/implementation.test.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/snaps-cli/src/commands/manifest/implementation.test.ts b/packages/snaps-cli/src/commands/manifest/implementation.test.ts index b5dfbc32e8..a32da4f58a 100644 --- a/packages/snaps-cli/src/commands/manifest/implementation.test.ts +++ b/packages/snaps-cli/src/commands/manifest/implementation.test.ts @@ -1,4 +1,3 @@ -import { getPlatformVersion } from '@metamask/snaps-utils'; import { DEFAULT_SNAP_BUNDLE, DEFAULT_SNAP_ICON, @@ -6,6 +5,7 @@ import { getPackageJson, getSnapManifest, } from '@metamask/snaps-utils/test-utils'; +import type { SemVerVersion } from '@metamask/utils'; import normalFs from 'fs'; import ora from 'ora'; @@ -33,12 +33,20 @@ jest.mock('../../webpack', () => ({ }), })); +jest.mock('module', () => ({ + createRequire: jest.fn().mockImplementation(() => { + const fn = jest.fn().mockReturnValue({ version: '1.0.0' }) as any; + jest.spyOn(fn, 'resolve').mockImplementation(); + return fn; + }), +})); + describe('manifest', () => { beforeEach(async () => { const { manifest: newManifest } = await getMockSnapFilesWithUpdatedChecksum( { manifest: getSnapManifest({ - platformVersion: getPlatformVersion(), + platformVersion: '1.0.0' as SemVerVersion, }), }, ); @@ -164,7 +172,7 @@ describe('manifest', () => { "url": "https://github.com/MetaMask/example-snap.git" }, "source": { - "shasum": "xYFUdpKz+yNGb1LwDGRHmqsH1PXknt2tE9ZJr1P0kb4=", + "shasum": "itjh0enng42nO6BxNCEhDH8wm3yl4xlVclfd5LsZ2wA=", "location": { "npm": { "filePath": "dist/bundle.js", @@ -179,7 +187,7 @@ describe('manifest', () => { "chains": ["eip155:1", "eip155:2", "eip155:3"] } }, - "platformVersion": "6.13.0", + "platformVersion": "1.0.0", "manifestVersion": "0.1" } "