Skip to content

Commit

Permalink
Update test and fix type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrtenz committed Jan 14, 2025
1 parent 7606353 commit fdc68b1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
14 changes: 10 additions & 4 deletions packages/snaps-cli/src/commands/build/implementation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
import normalFs from 'fs';
import { dirname, resolve } from 'path';
import type { Configuration } from 'webpack';
import type webpackModule from 'webpack';

import { getMockConfig } from '../../test-utils';
import { getCompiler } from '../../webpack';
Expand Down Expand Up @@ -36,8 +37,10 @@ jest.mock('../../webpack', () => ({
.requireActual<typeof webpack>('../../webpack')
.getCompiler(...args);

compiler.inputFileSystem = normalFs;
compiler.outputFileSystem = normalFs;
compiler.inputFileSystem =
normalFs as unknown as webpackModule.InputFileSystem;
compiler.outputFileSystem =
normalFs as unknown as webpackModule.OutputFileSystem;

return compiler;
}),
Expand All @@ -48,11 +51,14 @@ jest.mock('../../webpack/utils', () => ({
getDefaultLoader: jest.fn<
ReturnType<typeof utils.getDefaultLoader>,
Parameters<typeof utils.getDefaultLoader>
>(async (config) => {
>(async (config): ReturnType<typeof utils.getDefaultLoader> => {
if (config.legacy) {
return {
loader: BROWSERIFY_LOADER_PATH,
options: config.legacy,
options: {
...config.legacy,
fn: jest.fn(),
},
};
}

Expand Down
8 changes: 6 additions & 2 deletions packages/snaps-cli/src/commands/watch/implementation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
getSnapManifest,
} from '@metamask/snaps-utils/test-utils';
import normalFs from 'fs';
import type webpackModule from 'webpack';

import { getMockConfig } from '../../test-utils';
import { getCompiler } from '../../webpack';
Expand All @@ -24,8 +25,10 @@ jest.mock('../../webpack', () => ({
.requireActual<typeof webpack>('../../webpack')
.getCompiler(...args);

compiler.inputFileSystem = normalFs;
compiler.outputFileSystem = normalFs;
compiler.inputFileSystem =
normalFs as unknown as webpackModule.InputFileSystem;
compiler.outputFileSystem =
normalFs as unknown as webpackModule.OutputFileSystem;

return compiler;
}),
Expand Down Expand Up @@ -57,6 +60,7 @@ describe('watch', () => {
// @ts-expect-error - Partial mock.
mock.mockImplementationOnce(() => ({
watch: watchMock,
watching: {},
}));

await watch(
Expand Down
5 changes: 3 additions & 2 deletions packages/snaps-utils/src/platform-version.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import packageJson from '@metamask/snaps-sdk/package.json';
import type { SemVerVersion } from '@metamask/utils';

/**
* Get the current supported platform version.
Expand All @@ -9,6 +10,6 @@ import packageJson from '@metamask/snaps-sdk/package.json';
*
* @returns The platform version.
*/
export function getPlatformVersion() {
return packageJson.version;
export function getPlatformVersion(): SemVerVersion {
return packageJson.version as SemVerVersion;
}

0 comments on commit fdc68b1

Please sign in to comment.