Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: The "url" argument must be of type string. Received undefined #272

Open
AK3030 opened this issue Mar 7, 2022 · 2 comments
Open
Labels
bug Something isn't working

Comments

@AK3030
Copy link

AK3030 commented Mar 7, 2022

Are you using jest or chai?
Jest

Are you using OpenAPI 2, 3.0.X, or 3.1.0?
3.0.X

Describe the bug clearly
TypeError: The "url" argument must be of type string. Received undefined

  48 |     console.log('response', response)
  49 |
> 50 |     expect(response).toSatisfyApiSpec()
     |                      ^
  51 |     // console.log('response', response)
  52 |     // expect(response.data).toSatisfySchemaInApiSpec("/api/v2/example");
  53 |   })

  at getPathname (node_modules/openapi-validator/lib/utils/common.utils.ts:14:7)
  at OpenApi3Spec.findExpectedPathItem (node_modules/openapi-validator/lib/classes/AbstractOpenApiSpec.ts:113:39)
  at OpenApi3Spec.findExpectedResponseOperation (node_modules/openapi-validator/lib/classes/AbstractOpenApiSpec.ts:122:33)
  at OpenApi3Spec.findExpectedResponse (node_modules/openapi-validator/lib/classes/AbstractOpenApiSpec.ts:89:12)
  at OpenApi3Spec.validateResponse (node_modules/openapi-validator/lib/classes/AbstractOpenApiSpec.ts:131:31)
  at Object.default_1 (node_modules/jest-openapi/src/matchers/toSatisfyApiSpec.ts:26:39)
  at Object.toSatisfyApiSpec (node_modules/jest-openapi/src/index.ts:28:31)
  at __EXTERNAL_MATCHER_TRAP__ (node_modules/expect/build/index.js:386:30)
  at Object.toSatisfyApiSpec (node_modules/expect/build/index.js:387:15)
  at Object.<anonymous> (tests/unit/example.spec.js:50:22)

Steps to reproduce the bug:
jestOpenAPI(path.join(__dirname, './validationAPISpecs/example.json'))

describe('Example description', () => {
it('tests getExample method', async () => {

const response = await getExample() //this is an axios request, the response is printing correctly so i know thats working
console.log('response', response)

expect(response).toSatisfyApiSpec()

})
})

What did you expect to happen instead?
I expected the package to compare the response with the api spec. But I am unable to resolve the error.

@AK3030 AK3030 added the bug Something isn't working label Mar 7, 2022
@rwalle61
Copy link
Collaborator

rwalle61 commented Mar 7, 2022

Hi @AK3030, thanks for raising this 🙂 this is strange - we have tests covering axios. The error is thrown from here, suggesting that response.request.path is undefined.

Would you mind pasting response, response.request or response.request.path? (whichever is most helpful)

And what version of axios are you using?

@AK3030
Copy link
Author

AK3030 commented Mar 9, 2022

I actually found the solution here: #228

I changed the jest environment to node and it fixed the issue.

axios version is 0.26.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants