Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions jest.config.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ module.exports = {
// A preset that is used as a base for Jest's configuration
// preset: '',

// The path to the Prettier executable used to format snapshots
// Jest doesn't support Prettier 3 yet, so we use Prettier 2
prettierPath: require.resolve('prettier-2'),

// Run tests from one or more projects
// projects: undefined,

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
"lodash": "^4.17.21",
"minimatch": "^7.4.1",
"prettier": "^3.3.3",
"prettier-2": "npm:prettier@^2.8.8",
"prettier-plugin-packagejson": "^2.5.8",
"rimraf": "^4.1.2",
"semver": "^7.5.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/bip32/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "hKyk+E4FxoOrxVUot4h92CctQ35L8Zwo6y5x4DpdkZw=",
"shasum": "IPmfU5Yfr8CtU8hqE+sKtIvrtoKWeNZbjDWxck0Q1c8=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/bip44/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "KQiLG98qS86ThxbVvJW6DLpRtkSq238/rh2tHEZiJmA=",
"shasum": "Fe+hvYArPSD1N+RvmsAhRM2makxXA9xPJzMsT/xYDLU=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "t/mItLdi/miIU7FWJjijmmaFT/5svN1dK4Ik+1LMbqw=",
"shasum": "AAbLURsZMLxSRC5F69z6Un2W2wZ0v9UJfuPoYutZoH8=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/browserify/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "3kC/z0z6RjjarArtxcs+iltJRQgvZNIPBueMP0cLQJw=",
"shasum": "DpjsNMTfivqHjOV/NMrhSZR4o3dHAQOFIPkV0gzPeFU=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "Gk6JUIChMAQRJbHFCWyMtmMGmqknidjdE8nLnHyaM2Q=",
"shasum": "tiOQUmZUUEjlVRuK7Sb1t8Lmcy5TQXsdj8uJ8Ecfd4k=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/cronjobs/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "b/ZsZh0z0ieSBHzlazYSkpkLMUSV4c442IFQ8Zgepq0=",
"shasum": "Gw/JAlj3moUPfdWya3XTZV+mkROKZpUQ7spUAHsu8zE=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/dialogs/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "asBcwQ0fIXFCZ6skpbENtZiyskGDEdEIrAbWkOvEQ0s=",
"shasum": "nsXCGehK5VQDG0DBaUuQKx9tfOQsWcgyyJptTEE+Glw=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "Vm44DmG3HizDFI1VHohwXafP+dnv3evvlhgFmB8DX98=",
"shasum": "E5FILDC9eOuFG+3qvKiAFRTzTitjBDzFPcTicdFqB9k=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/ethers-js/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "Aq+JN0IumEWkpEV1WAMMcj8tFCjJc2JIgz6ngW1ghCI=",
"shasum": "Rc5OrsLKdb7+9YsGjgbNGEH2XmU+RMcpphb7IHPqC2s=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/file-upload/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "cVHHqNAq33UzS3K9AQEFn/P/qA9IF/v2Ru4Wp4Prolw=",
"shasum": "2hqQJlHUZ3ilXiDVHuKHL5SZK2MrdlC09b/a939g3X0=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/get-entropy/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "jHLW/TPnr+5WCVVKton++heY7ANqnmdXYIos57bJMFg=",
"shasum": "+qBVdCwt/nJF4ufkvmWG9CSGhko6Ygybd8TE2bSmNnk=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/get-file/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "EjJkL2kQyJLWRx+MVHrfMyrxnQCidkDIg4j9VW/4e+0=",
"shasum": "2l842tQwt+3opl3b1GAgibYz9L23WfLAK3y7Xy4jc1k=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/home-page/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "jsrLxUR5DtPf/77zAm3jiCCPqOg8YZRF7vsYgEim+vg=",
"shasum": "G7eD8MRIlkvYr4vjurbcLuLGIvUGxnLcLxP89QaHqQk=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/images/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "0ltirRoW8OBkrJUSnIAql4rdR9k00Gp30Pp8anO8SyQ=",
"shasum": "gK5w9WgWgbAA8nzQLRJEl6Vm3GZ4tQG/Mckp4gyOb64=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "2XAIve/Nn/RGKdyrooukRjz+ixn0c9n10gqme9HGJxY=",
"shasum": "Od2jws/OlpvhBImWFXQ3QQ3jpYMKc34HWAzz3CxMDIc=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "Ybacx795qo9tN0TCqRc2PhpqSag8K56p6aomjpPJl+o=",
"shasum": "0QMZsmHgfBj0XikEblYpf4Ylwmx+UrJFMDsCJCm1Yis=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "mOeSPVTlrbYhU4ueYFtxYX2jdgautNZJqatqcl8xHcY=",
"shasum": "uXGZpRIKkYANInV1jD2+aW5haQbrtt/9AwVmSJpV+9I=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/json-rpc/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "An0r5dIP8lHzsMGaYcJqJIq1ynF0MZADyjoAo4trirs=",
"shasum": "A5COdI8IhqSN9zwvjqbms2my1m1PfmiSrkkZKkgaXC8=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/jsx/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "slB8CHO9cqeUog9kw6E0ODJf6Dkcm05/GQ+vDLxvAas=",
"shasum": "AyIHrzAYbEJVr+/QGqXeE8Hw2OrWdnPB6UsF4hon4RA=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/localization/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "anygDtewBP8eXfF4VfpT5S2He80rvy5Hb/RdXUpOmOA=",
"shasum": "neXtE4zGwyszoQ111WzsK1SAqvzReg8Ulf2eeRO/w30=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/manage-state/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "uNotSODL7gl8JK/sSWL/jR87bsxsuBkaO6F414X3qwQ=",
"shasum": "Vvd5VIY75Ny8vY47iZ3GSELOYLLgRz71RhIvKJpS1Ag=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "yhTtMDHnm4sYAHiV7TQ0OXi1WlkV8gAPXj+OCbJdmKw=",
"shasum": "2qzcNy1Reotfc2mDLOx/aE6/UTcZ5HV6CehG3PNTe8Q=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "AqdUpB8Q3S80ndYGDMIiSXAhNIA2y+QBdZL09x5MN/k=",
"shasum": "UDZMY2SiJ1Wbk5H/+mgZie+Xbt40YuLvJ55aqYplK8I=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/preinstalled/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "nMtsXN1K9BkY6zSrF8nii2pxbKBpWaAq7eUOOZ04ajs=",
"shasum": "v8FsOM57C+tH3MQOinkpVbg90L3iytd+8JeLk+ecWkA=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/protocol/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "XCSzJbcyYNaEve/S9QSQiUzs5IPqWPoF3sEKJpg5KTQ=",
"shasum": "GZWLGz4J9wN1TiZDI+BkDvS7+Kluvro2rWVFRUczAt0=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "91lc41gLDh3TQY+Wv6aP/szcbaT0Z9aeVfoBY+lmlcc=",
"shasum": "C8GH13QQb3N3OceJKkvKQG0Iz0o2KOUHPPWP/uTa6U4=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/send-flow/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "KZtEm+Gz8nWwCiyEtiQRmnVvp0J5F91e/bUWY1rJUNI=",
"shasum": "GaRBzrcpkF3Jc1W+VFfpd11RH7cvHgbsosxM2DFwJKI=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "JtztKgU1DtgTq/mvEpzZ3mllvHm07Wo8PmUd19dBApU=",
"shasum": "L5YsHe35++DnUuKt5YTWdztehVDU3m80jSZ65i4Bc1M=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "KXDRKn0g31gllneOBkzJXNedjFKklSZh7DW2We2+Pm0=",
"shasum": "qBiJMFzBD+/X07YrtirrFuq4Qfs0wRSl5/MaYAutpAM=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/wasm/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "cM4+w95k5SocDfGu9CStTDP1YYAUkjCOvIBNBf7aJHc=",
"shasum": "mscQHxQMt0q+EZPpoSR+5Y/EHmIJR7opSBX3usAln0k=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "Az6qvsHGwGKNwWgEZI34jzkwXoHbaadbLgygwwfLHwI=",
"shasum": "mYG34iCWxtAQRxIUr+Ge2n+N8b9RcVjMv4/SSBxuGeM=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
13 changes: 9 additions & 4 deletions packages/snaps-cli/src/commands/build/implementation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import type * as webpack from '../../webpack';
import type * as utils from '../../webpack/utils';
import { BROWSERSLIST_FILE } from '../../webpack/utils';
import { build } from './implementation';
import { SemVerVersion } from '@metamask/utils';

const { promises: fs } = normalFs;

Expand All @@ -36,7 +37,10 @@ jest.mock('../../webpack', () => ({
.requireActual<typeof webpack>('../../webpack')
.getCompiler(...args);

// @ts-expect-error: Type mismatch.
compiler.inputFileSystem = normalFs;

// @ts-expect-error: Type mismatch.
compiler.outputFileSystem = normalFs;

return compiler;
Expand All @@ -48,6 +52,7 @@ jest.mock('../../webpack/utils', () => ({
getDefaultLoader: jest.fn<
ReturnType<typeof utils.getDefaultLoader>,
Parameters<typeof utils.getDefaultLoader>
// @ts-expect-error: Type mismatch.
>(async (config) => {
if (config.legacy) {
return {
Expand All @@ -66,7 +71,7 @@ describe('build', () => {
beforeEach(async () => {
const { manifest } = await getMockSnapFilesWithUpdatedChecksum({
manifest: getSnapManifest({
platformVersion: getPlatformVersion(),
platformVersion: getPlatformVersion() as SemVerVersion,
}),
});

Expand Down Expand Up @@ -129,7 +134,7 @@ describe('build', () => {

const output = await fs.readFile('/snap/output.js', 'utf8');
expect(output).toMatchInlineSnapshot(
`"(()=>{var r={67:r=>{r.exports.onRpcRequest=({request:r})=>{console.log("Hello, world!");const{method:e,id:o}=r;return e+o}}},e={};var o=function o(t){var s=e[t];if(void 0!==s)return s.exports;var n=e[t]={exports:{}};return r[t](n,n.exports,o),n.exports}(67);module.exports=o})();"`,
`"(()=>{var r={157:r=>{r.exports.onRpcRequest=({request:r})=>{console.log("Hello, world!");const{method:e,id:o}=r;return e+o}}},e={};var o=function o(t){var s=e[t];if(void 0!==s)return s.exports;var n=e[t]={exports:{}};return r[t](n,n.exports,o),n.exports}(157);module.exports=o})();"`,
);
});

Expand Down Expand Up @@ -165,7 +170,7 @@ describe('build', () => {
expect(output).toMatchInlineSnapshot(`
"(() => {
var __webpack_modules__ = {
67: module => {
157: module => {
module.exports.onRpcRequest = ({
request
}) => {
Expand All @@ -190,7 +195,7 @@ describe('build', () => {
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
return module.exports;
}
var __webpack_exports__ = __webpack_require__(67);
var __webpack_exports__ = __webpack_require__(157);
module.exports = __webpack_exports__;
})();"
`);
Expand Down
5 changes: 5 additions & 0 deletions packages/snaps-cli/src/commands/watch/implementation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ jest.mock('../../webpack', () => ({
.requireActual<typeof webpack>('../../webpack')
.getCompiler(...args);

// @ts-expect-error: Type mismatch.
compiler.inputFileSystem = normalFs;

// @ts-expect-error: Type mismatch.
compiler.outputFileSystem = normalFs;

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 All @@ -78,6 +82,7 @@ describe('watch', () => {
// @ts-expect-error - Partial mock.
mock.mockImplementationOnce(() => ({
watch: watchMock,
watching: {},
}));

await expect(
Expand Down
Loading
Loading