Skip to content

Commit 3f3b24b

Browse files
committed
Add E2E test
1 parent a5aa02f commit 3f3b24b

File tree

5 files changed

+81
-0
lines changed

5 files changed

+81
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/* eslint-disable */
2+
// This file is used for the E2E watch test.
3+
4+
export const onRpcRequest = () => {
5+
// no-op
6+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "watch-e2e-test",
3+
"version": "0.0.0"
4+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import type { SnapConfig } from '@metamask/snaps-cli';
2+
3+
const config: SnapConfig = {
4+
input: 'input.mjs',
5+
output: {
6+
path: './dist',
7+
filename: 'bundle.js',
8+
},
9+
};
10+
11+
export default config;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"version": "0.0.0",
3+
"description": "E2E test for Snap `watch` command with invalid manifest",
4+
"proposedName": "E2E Test",
5+
"source": {
6+
"shasum": "9r/u7rEURvdwOi8MZc9nccNVNdIFgcMXjQCGIn9Mx/s=",
7+
"location": {
8+
"npm": {
9+
"filePath": "bundle.js",
10+
"packageName": "watch-e2e-test",
11+
"registry": "https://registry.npmjs.org/"
12+
}
13+
}
14+
},
15+
"initialPermissions": {},
16+
"platformVersion": "9.3.0",
17+
"manifestVersion": "0.1"
18+
}

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

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,46 @@ describe('mm-snap watch', () => {
6464
);
6565
},
6666
);
67+
68+
it('evaluates a bundle and reports manifest warnings', async () => {
69+
runner = getCommandRunner(
70+
'watch',
71+
['--port', '0'],
72+
resolve(__dirname, '__test__', 'invalid'),
73+
);
74+
75+
await runner.waitForStderr(
76+
/Compiled \d+ files? in \d+ms with \d+ warnings?\./u,
77+
);
78+
79+
expect(runner.stdout).toContainEqual(
80+
expect.stringMatching(/Checking the input file\./u),
81+
);
82+
expect(runner.stdout).toContainEqual(
83+
expect.stringMatching(/Starting the development server\./u),
84+
);
85+
expect(runner.stdout).toContainEqual(
86+
expect.stringMatching(
87+
/The server is listening on http:\/\/localhost:\d+\./u,
88+
),
89+
);
90+
expect(runner.stdout).toContainEqual(
91+
expect.stringMatching(/Building the Snap bundle\./u),
92+
);
93+
expect(runner.stderr).toContainEqual(
94+
expect.stringMatching(
95+
/Compiled \d+ files? in \d+ms with \d+ warnings?\./u,
96+
),
97+
);
98+
expect(runner.stderr).toContainEqual(
99+
expect.stringContaining(
100+
'No icon found in the Snap manifest. It is recommended to include an icon for the Snap. See https://docs.metamask.io/snaps/how-to/design-a-snap/#guidelines-at-a-glance for more information.',
101+
),
102+
);
103+
expect(runner.stderr).toContainEqual(
104+
expect.stringContaining(
105+
'The Snap exports the following handlers, but does not request permission for them: onRpcRequest (endowment:rpc).',
106+
),
107+
);
108+
});
67109
});

0 commit comments

Comments
 (0)