facing issue in Pactum cucumber undefined error
Asked Answered
E

1

0

I'm encountering an issue with Pactum Cucumber where I'm getting an undefined error, despite receiving the expected output when testing the same request in the Postman application. Below, I've attached the error message for reference

Then('the API should respond with a 6-digit numeric OTP and a transaction key', () => {
    console.log(spec.response.body);
    otp = spec.response.body.otp;
    TransactionId = spec.response.body.transaction_id;
    Status = spec.response.body.status;
    expect(otp).to.be.a('string').with.lengthOf(6); // Verify OTP format (6 digits)
    expect(TransactionId).to.be.a('string'); // Verify transaction key is a string
});

I've attempted to troubleshoot this problem but haven't been successful so far. Here are some steps I've taken:

Review of the Pactum Cucumber Configuration: I've double-checked the configuration settings for Pactum Cucumber to ensure they match the setup used in the Postman application.

Debugging Steps: I've tried debugging the code to isolate the source of the undefined error, but haven't been able to pinpoint it accurately.

Comparative Analysis: I've compared the request and response details between Pactum Cucumber and Postman to identify any discrepancies, but everything seems to be in order.

Despite these efforts, the issue persists. I'm seeking guidance on potential solutions or additional steps I can take to resolve this problem. Any insights or suggestions would be greatly appreciated. #Pactum cucumber

facing issue in Pactum cucumber undefined error

Elegit answered 11/2 at 16:26 Comment(1)
Please do not post images of errors. Just paste the actual error. meta.#286051Antecedents
R
0

Looks spec.response.body is undefined. Ensure the test finishes execution before accessing the response. Use spec.response.json for JSON responses.

Rivero answered 3/3 at 8:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.