Bernard Baker
04/08/2022, 10:32 AMPOST **/api/v2/login (stubbed) Yes (alias) login (count) -
The request
POST https://<our domain>.<http://pactflow.io/pacts/provider/<our|pactflow.io/pacts/provider/<our> provider>/consumer/<our consumer>/latest/stub/api/v2/login
The Cypress test
const loginResponse = require(`../../../fixtures/login.json`);
describe(`Login API`, () => {
Cypress.config({ defaultCommandTimeout: 120000 });
beforeEach(() => {
cy.intercept(
{
method: `POST`,
url: `**/api/v2/login`
},
{
statusCode: 200,
body: { ...loginResponse },
headers: {
"access-control-allow-origin": `*`
}
}
).as(`login`); <----- The alias
cy.visit(`/`);
cy.setupPact(`<our consumer>`, Cypress.env(`PACT_PROVIDER`));
});
it(`should log into Studio Frontend`, () => {
cy.login(
`/api/v2/login`,
`user`,
`password`
);
});
after(() => {
cy.usePactWait(`login`); <---- This doesn't match the route
});
});
The error
Error: CypressError: Timed out retrying after 5000ms: `cy.wait()` timed out waiting `5000ms` for the 1st request to the route: `login`. No request ever occurred.
Yousaf Nabi (pactflow.io)
cy.login
method look like? Are you making a a cy.request
call via your customer cy.login
method?
If so, you would wish to use cy.usePactRequest
https://github.com/pactflow/pact-cypress-adapter#cyusepactrequestoption-alias-and-cyusepactgetalias--aliasBernard Baker
04/08/2022, 1:25 PMlogin
command looks like...
Cypress.Commands.add(`login`, (api, user, passphrase) => {
cy.request({
method: `POST`,
url: `${Cypress.env(`PACT_PROVIDER_STUB_URL`)}${api}`,
body: {
user,
passphrase
},
headers: {
Authorization: `Bearer ${Cypress.env(`PACT_PROVIDER_TOKEN`)}`,
Accept: `application/json, text/plain, */*`
}
});
});
Bernard Baker
04/08/2022, 2:05 PMYousaf Nabi (pactflow.io)
Yousaf Nabi (pactflow.io)
Bernard Baker
04/11/2022, 10:41 AMYousaf Nabi (pactflow.io)
Yousaf Nabi (pactflow.io)
Bernard Baker
04/11/2022, 1:53 PMYousaf Nabi (pactflow.io)
Bernard Baker
04/11/2022, 2:05 PMYousaf Nabi (pactflow.io)
Ada, C# (ASP.NET Core, Azure Functions), C++ (Pistache, Restbed, Qt5 QHTTPEngine), Erlang, F# (Giraffe), Go (net/http, Gin, Echo), Haskell (Servant, Yesod), Java (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, Jersey, RestEasy, Play Framework, PKMST, Vert.x, Apache Camel), Kotlin (Spring Boot, Ktor, Vertx), PHP (Laravel, Lumen, Mezzio (fka Zend Expressive), Slim, Silex, Symfony), Python (FastAPI, Flask), NodeJS, Ruby (Sinatra, Rails5), Rust (rust-server), Scala (Akka, Finch, Lagom, Play, Scalatra)I previously created one for serverless-offline that you could feed a pact file into and spin up a stub server, and have also hosted stub servers in ECS via a docker container.
Yousaf Nabi (pactflow.io)
Yousaf Nabi (pactflow.io)
Bernard Baker
04/11/2022, 3:28 PMBernard Baker
04/11/2022, 3:28 PMBernard Baker
04/11/2022, 3:29 PMBernard Baker
04/11/2022, 3:30 PMBernard Baker
04/11/2022, 3:31 PMYousaf Nabi (pactflow.io)
Yousaf Nabi (pactflow.io)
Yousaf Nabi (pactflow.io)