How can I test the connection refused case? #62
Answered
by
ASaiAnudeep
LonelyGriffin
asked this question in
Q&A
-
Beta Was this translation helpful? Give feedback.
Answered by
ASaiAnudeep
Apr 29, 2021
Replies: 1 comment 1 reply
-
Welcome to PactumJS Discussions & Thanks a lot for using this library.This is an interesting use case. PactumJS doesn't have a native method to support error expectations. I too agree that we should have one. As you mentioned having a method like Instead, I will add a method something like // expect any error
await pactum.spec().get(healthUrl).expectError();
// expect ECONNREFUSED error
await pactum.spec().get(healthUrl).expectError('ECONNREFUSED');
// expect error object
await pactum.spec().get(healthUrl).expectError({ code: 'ECONNREFUSED' }); And once again thank you for your valuable suggestion. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
ASaiAnudeep
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Welcome to PactumJS Discussions & Thanks a lot for using this library.
This is an interesting use case. PactumJS doesn't have a native method to support error expectations. I too agree that we should have one.
As you mentioned having a method like
expectConnectionRefused
would solve this issue but it is explicit. We will discuss further and consider adding this method.Instead, I will add a method something like
expectError
that would be generic for broader use cases.