Skip to content

Commit 1576d0c

Browse files
Fix tests
1 parent 0080d68 commit 1576d0c

File tree

5 files changed

+34
-12
lines changed

5 files changed

+34
-12
lines changed

packages/snaps-cli/src/commands/build/implementation.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,10 @@ describe('build', () => {
106106

107107
await build(config);
108108

109-
// Manifest checksum mismatch is the warning
110109
expect(warn).toHaveBeenCalledWith(
111-
expect.stringMatching(/Compiled 1 file in \d+ms with 1 warning\./u),
110+
expect.stringMatching(
111+
/Compiled \d+ files? in \d+ms with \d+ warnings?\./u,
112+
),
112113
);
113114

114115
const output = await fs.readFile('/snap/output.js', 'utf8');
@@ -140,9 +141,10 @@ describe('build', () => {
140141

141142
await build(config);
142143

143-
// Manifest checksum mismatch is the warning
144144
expect(warn).toHaveBeenCalledWith(
145-
expect.stringMatching(/Compiled 1 file in \d+ms with 1 warning\./u),
145+
expect.stringMatching(
146+
/Compiled \d+ files? in \d+ms with \d+ warnings?\./u,
147+
),
146148
);
147149

148150
const output = await fs.readFile('/snap/output.js', 'utf8');

packages/snaps-cli/src/commands/watch/watch.e2e.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ describe('mm-snap watch', () => {
2626
async (command) => {
2727
runner = getCommandRunner(command, ['--port', '0']);
2828
await runner.waitForStderr(
29-
/Compiled \d+ files? in \d+ms with 1 warning\./u,
29+
/Compiled \d+ files? in \d+ms with \d+ warnings?\./u,
3030
);
3131

3232
await fs.writeFile(SNAP_FILE, originalFile);
3333
await runner.waitForStdout(/Changes detected in .+, recompiling\./u);
3434
await runner.waitForStderr(
35-
/Compiled \d+ files? in \d+ms with 1 warning\./u,
35+
/Compiled \d+ files? in \d+ms with \d+ warnings?\./u,
3636
);
3737

3838
expect(runner.stdout).toContainEqual(
@@ -50,7 +50,9 @@ describe('mm-snap watch', () => {
5050
expect.stringMatching(/Building the Snap bundle\./u),
5151
);
5252
expect(runner.stderr).toContainEqual(
53-
expect.stringMatching(/Compiled \d+ files? in \d+ms with 1 warning\./u),
53+
expect.stringMatching(
54+
/Compiled \d+ files? in \d+ms with \d+ warnings?\./u,
55+
),
5456
);
5557
expect(runner.stderr).toContainEqual(
5658
expect.stringContaining(

packages/snaps-utils/coverage.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"branches": 99.76,
3-
"functions": 99.01,
4-
"lines": 98.62,
5-
"statements": 97.18
2+
"branches": 99.53,
3+
"functions": 99.02,
4+
"lines": 98.52,
5+
"statements": 97.12
66
}

packages/snaps-utils/src/manifest/manifest.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { promises as fs } from 'fs';
2+
import fetchMock from 'jest-fetch-mock';
23
import { join } from 'path';
34

45
import {
@@ -34,6 +35,17 @@ const BASE_PATH = '/snap';
3435
const MANIFEST_PATH = join(BASE_PATH, NpmSnapFileNames.Manifest);
3536
const PACKAGE_JSON_PATH = join(BASE_PATH, NpmSnapFileNames.PackageJson);
3637

38+
const MOCK_GITHUB_RESPONSE = JSON.stringify({
39+
// eslint-disable-next-line @typescript-eslint/naming-convention
40+
target_commitish: '5fceb7ed2ef18a3984786db1161a76ca5c8e15b9',
41+
});
42+
43+
const MOCK_PACKAGE_JSON = JSON.stringify({
44+
dependencies: {
45+
'@metamask/snaps-sdk': getPlatformVersion(),
46+
},
47+
});
48+
3749
/**
3850
* Get the default manifest for the current platform version.
3951
*
@@ -73,9 +85,16 @@ async function resetFileSystem() {
7385

7486
describe('checkManifest', () => {
7587
beforeEach(async () => {
88+
fetchMock.enableMocks();
89+
fetchMock.mockResponses(MOCK_GITHUB_RESPONSE, MOCK_PACKAGE_JSON);
90+
7691
await resetFileSystem();
7792
});
7893

94+
afterAll(() => {
95+
fetchMock.disableMocks();
96+
});
97+
7998
it('returns the status and warnings after processing', async () => {
8099
const { updated, reports } = await checkManifest(BASE_PATH);
81100
expect(reports).toHaveLength(0);

packages/snaps-utils/src/manifest/validators/production-platform-version.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ const determineProductionVersion = useFileSystemCache(
1515
inMilliseconds(7, Duration.Day),
1616
async () => {
1717
try {
18-
// TODO: Cache this check.
1918
const latestRelease = await fetch(
2019
'https://api.github.com/repos/metamask/metamask-extension/releases/latest',
2120
);

0 commit comments

Comments
 (0)