You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
jest-openapi v0.13.0 Server: Node / Express with CORS enabled Client: Axios (v0.21.1) via Jest (v26.6.3) configured (in Typescript) as described in use case #1 on the jest-openapi Github page
Error:
`GET /version › should satisfy OpenAPI spec
TypeError: The "url" argument must be of type string. Received undefinedTypeError [ERR_INVALID_ARG_TYPE]: The "url" argument must be of type string. Received undefined
at getPathname (node_modules/openapi-validator/lib/utils/common.utils.js:8:38)
at OpenApi3Spec.findExpectedPathItem (node_modules/openapi-validator/lib/classes/AbstractOpenApiSpec.js:71:28)
at OpenApi3Spec.findExpectedResponseOperation (node_modules/openapi-validator/lib/classes/AbstractOpenApiSpec.js:83:33)
at OpenApi3Spec.findExpectedResponse (node_modules/openapi-validator/lib/classes/AbstractOpenApiSpec.js:40:44)
at OpenApi3Spec.validateResponse (node_modules/openapi-validator/lib/classes/AbstractOpenApiSpec.js:91:31)
at Object.<anonymous>.module.exports (node_modules/jest-openapi/src/matchers/toSatisfyApiSpec.js:13:39)`
Cause:
The res.request object does not contain the url property.
This problem, and a subsequent one, can be fixed with the following hack:
Thanks @lightzephyr for raising this! I'm not sure why the request property is undefined - we're expecting it to have a path that is your url. How are you making the axios request, and is your jest env node or jsdom? (Our tests do it like this and use node). Perhaps we're not handling all the ways one can use axios
jest-openapi v0.13.0
Server: Node / Express with CORS enabled
Client: Axios (v0.21.1) via Jest (v26.6.3) configured (in Typescript) as described in use case #1 on the jest-openapi Github page
Error:
`GET /version › should satisfy OpenAPI spec
Cause:
The res.request object does not contain the url property.
This problem, and a subsequent one, can be fixed with the following hack:
const hackResObject = (res: AxiosResponse<any>) => { res.request.path = res.config.url; res.request.method = 'GET'; };
After doing this, the test works correctly and passes and fails when it should!
Why doesn't the use case work out of the box in this environment?
Is there anything that can be done to avoid this hack?
The text was updated successfully, but these errors were encountered: