Replies: 9 comments 40 replies
-
Hey @Mrtenz this looks amazing I'm excited to try it out. Not sure if you've seen this error yet if you might be able to give some guidance?
I installed using the same process as mentioned. I can see the package installed within my node_modules, but importing it seems to be the issue. I also tried removing yarn.lock and node_modules then re-installing but no luck. To make sure it wasn't an issue with my setup, I cloned down the snaps repo to try running the transaction-insights project tests locally but ran into a similar error. Any advice would be appreciated. |
Beta Was this translation helpful? Give feedback.
-
Hey @Mrtenz I'm back :) I think there's a bug with the network mocking. Mocking 4XX status codes is causing the Example:
Running the Snap in Flask produces the correct result of showing the |
Beta Was this translation helpful? Give feedback.
-
Getting type issues if I reinstall anytime after
|
Beta Was this translation helpful? Give feedback.
-
@Mrtenz Any idea how to use this to work with the keyring API? I'm trying to add tests that confirm the behavior of the I think doing something like the is resulting in a superstruct assertion issue. const { request } = await installSnap();
const response = await request({
origin : "Jest",
method : SnapKeyringMethod.CreateAccount,
params : {
"options" : {
"name" : "my-account"
}
}
}); And, I can't figure out how to use some rewrapping of the |
Beta Was this translation helpful? Give feedback.
-
"Hi, I'm working on writing tests on our Snap using '@metamask/snaps-jest', but I keep encountering an error:
in the response to this request, snap will send a request to metamask, like this:
and I believe this request will make this error: would you help me to fix this issue, please? |
Beta Was this translation helpful? Give feedback.
-
Hi! I'm currently implementing tests between snap and backend APIs. There's 1 endpoint that is authenticated by JWT and I'm trying to mock the network call to that endpoint as below: const sendMsgUrl = baseUrl + `/sendMessage`;
await mock({
url: sendMsgUrl,
response: {
contentType: 'application/json',
body: JSON.stringify({ response: {} }),
},
});
"token is not correct or expired"
Thanks for your great work! |
Beta Was this translation helpful? Give feedback.
-
Hi there, I have an issue when running my test after I upgraded from My project is in JS ES6, wondering how to fix it. Error:
|
Beta Was this translation helpful? Give feedback.
-
I wrote a snap test, the output is |
Beta Was this translation helpful? Give feedback.
-
We recently released a new tool for end-to-end testing snaps with Jest, called
@metamask/snaps-jest
. It consists of a Jest environment and Jest matchers, which make it easier to run snaps in a MetaMask-like environment, without any of the hassle of setting up end-to-end tests yourself.We'd love feedback on the API design, any features you'd like to see, or anything else regarding
@metamask/snaps-jest
!Getting started
To get started, all you need to do is:
Install the package using
yarn add -D @metamask/snaps-jest@^0.35.2-flask.1
.-flask.1
release to test your snap.Add a preset to your Jest config:
Then you can use the
installSnap
function to install a snap, and send requests to it:For full details on the API, Jest matchers, options, etc., you can refer to the documentation.
More examples
All of our example snaps have end-to-end tests written using this tool. Take a look at the
examples
folder for an overview.Beta Was this translation helpful? Give feedback.
All reactions