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

Open
3 tasks done
zaaknafein opened this issue Nov 12, 2024 · 0 comments
Open
3 tasks done
Labels

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant