Skip to content
This repository was archived by the owner on Sep 1, 2022. It is now read-only.

Commit 2490974

Browse files
committed
test(request): catch network error
1 parent 37cacfc commit 2490974

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/lib/sdk.spec.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,25 @@ test('Make a request with custom axios config', t => {
132132
);
133133
});
134134

135+
test('Catch a network request', async t => {
136+
t.context.axiosRequest.rejects(new Error('Network Error'));
137+
138+
await t.throwsAsync(
139+
async () => {
140+
await t.context.strapi.request('get', '/foo');
141+
},
142+
{ message: 'Network Error' }
143+
);
144+
});
145+
135146
test('Catch a request', async t => {
136-
t.context.axiosRequest.rejects(new Error('error'));
147+
t.context.axiosRequest.rejects({
148+
response: {
149+
data: {
150+
message: 'error'
151+
}
152+
}
153+
});
137154

138155
await t.throwsAsync(
139156
async () => {

0 commit comments

Comments
 (0)