Describe the bug
I'm trying to import Specmatic in a Cypress test, like
import { setHttpStubExpectations } from "specmatic";
and I'm getting the following error while running the tests by npx cypress run --browser electron:
TypeError: The following error originated from your test code, not from Cypress. > _fs.default.existsSync is not a function
Desktop:
- OS: Windows 10
- Node version: 18.12.
- Specmatic Version: 1.2.14
- "cypress": "^13.2.0",
Additional context
I'm trying to achieve that from a Cypress test, using the cy.intercept() and cy.reply() functions, the tests are backed with the Specmatic stub and it returns the example/transient stubs always verified against the API specification.
For example:
cy.intercept("/api/v1/foo/list", async (req) => {
// fetch test data from Specmatic stub
const data = await fetch("http://localhost:35337" + req.url, {
headers: {
Accept: "application/json",
"Content-Type": "application/json",
Authorization: "Bearer token"
}
});
req.reply(data);
});
Should this work?
Describe the bug
I'm trying to import Specmatic in a Cypress test, like
and I'm getting the following error while running the tests by
npx cypress run --browser electron:Desktop:
Additional context
I'm trying to achieve that from a Cypress test, using the
cy.intercept()andcy.reply()functions, the tests are backed with the Specmatic stub and it returns the example/transient stubs always verified against the API specification.For example:
Should this work?