You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
attempt currently does not catch errors that come from promises. Instead, it will throw. I tried to send a PR for this, but the contribution docs look old (test files are named with .spec, not .test). I don't see how you're running tests.
For example, this will throw:
constrequest=newRequest('http://example.com',{body: '',method: 'POST',});// STILL THROWSconstbody=awaitattempt(async()=>{returnrequest.json();});
However, if we have an async version that awaits the promise before, we can get the same results:
constrequest=newRequest('http://example.com',{body: '',method: 'POST',});constbody=awaitattemptAsync(async()=>{returnrequest.json();});expect(isError(body)).toBe(true);expect(body).toBeInstanceOf(SyntaxError);if(bodyinstanceofSyntaxError){expect(body.message).toBe('Unexpected end of JSON input');}
The text was updated successfully, but these errors were encountered:
attempt currently does not catch errors that come from promises. Instead, it will throw. I tried to send a PR for this, but the contribution docs look old (test files are named with .spec, not .test). I don't see how you're running tests.
For example, this will throw:
However, if we have an async version that awaits the promise before, we can get the same results:
Now we get the expected results:
The text was updated successfully, but these errors were encountered: