I am developing API proxies in VS Code and testing them using the Apigee Emulator ( apigee-emulator-1.9.4 ), mocha and pactumJS. I would like to avoid having an Assign Message policy that returns dummy data for test purposes, because I would like to keep my code clean for production and also be able to test different request and response payloads without having to define several AMs.
My proxy will call a target endpoint and receive a response, which is then validated in a JS policy. In my tests, I am trying to mock the endpoint and get a predefined response back, using host: localhost/{path} and port:3000 , but I’m getting a 503 error back, with these details:
“body”: {
“fault”: {
“faultstring”: “The Service is temporarily unavailable”,
“detail”: {
“errorcode”: “messaging.adaptors.http.flow.ServiceUnavailable”,
“reason”: “TARGET_CONNECT_CONNECTION_REFUSED”
}
}
}
I think the mock server is working, as I get this message in the execution:
"[I] Mock server is listening on http://localhost/{path}:3000" . I have also defined the mock interaction.
Can someone point me to the correct way of doing this?