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

bug: Error on test when using axios with stencil (MockAnchorElement) #6047

Closed
3 tasks done
zaaknafein opened this issue Nov 12, 2024 · 2 comments · Fixed by #6051
Closed
3 tasks done

bug: Error on test when using axios with stencil (MockAnchorElement) #6047

zaaknafein opened this issue Nov 12, 2024 · 2 comments · Fixed by #6051
Assignees
Labels
Bug: Validated This PR or Issue is verified to be a bug within Stencil

Comments

@zaaknafein
Copy link

Prerequisites

Stencil Version

4.22.2

Current Behavior

An error is displayed when importing Axios in spec / e2e file.
No problem at runtime in the application.

FAIL  src/services/user.service.spec.ts
  ● Test suite failed to run

    TypeError: Invalid URL

> 1 | import axios from "axios";
        | ^
      2 | import { User, UserService } from "./user.service";
      3 |
      4 | describe('UserService', () => {

      at MockAnchorElement.get pathname [as pathname] (node_modules/@stencil/core/mock-doc/index.cjs:7848:12)
      at resolveURL (node_modules/axios/lib/helpers/isURLSameOrigin.js:41:35)
      at standardBrowserEnv (node_modules/axios/lib/helpers/isURLSameOrigin.js:47:17)
      at Object.<anonymous> (node_modules/axios/lib/helpers/isURLSameOrigin.js:60:4)
      at Object.<anonymous> (src/services/user.service.spec.ts:1:1)

Expected Behavior

You should be able to test services while mocking Axios comportment without any problem.

System Info

System: node 20.17.0
    Platform: windows (10.0.19045)
   CPU Model: 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz (8 cpus)
    Compiler: C:\dev\projects\bandeau-patient\node_modules\@stencil\core\compiler\stencil.js
       Build: 1729874537
     Stencil: 4.22.2
  TypeScript: 5.5.4
      Rollup: 2.56.3
      Parse5: 7.1.2
      jQuery: 4.0.0-pre
      Terser: 5.31.1

Steps to Reproduce

  • Use Axios in a service
  • Write a test with jest while mocking Axios

Code Reproduction URL

https://github.com/zaaknafein/stencil-test

Additional Information

Maybe similar to this problem.

Dunno why this method is call on test initialization...

@ionitron-bot ionitron-bot bot added the triage label Nov 12, 2024
@christian-bromann christian-bromann added Bug: Validated This PR or Issue is verified to be a bug within Stencil and removed triage labels Nov 20, 2024
@christian-bromann christian-bromann self-assigned this Nov 20, 2024
@christian-bromann
Copy link
Member

This has been released in https://github.com/ionic-team/stencil/releases/tag/v4.22.3

@zaaknafein
Copy link
Author

Great news, thank you for your responsiveness :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug: Validated This PR or Issue is verified to be a bug within Stencil
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants