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

*.svg?inline issues #2081

Open
arishojaei opened this issue Aug 3, 2023 · 0 comments
Open

*.svg?inline issues #2081

arishojaei opened this issue Aug 3, 2023 · 0 comments

Comments

@arishojaei
Copy link

Subject of the issue

There is no proper solution for easily reading svg?inline from the component that you want to test.

  • jest: "29.5.0"
  • jest-transform-stub: "2.0.0"
  • babel-jest: "^29.5.0"
  • @vue/test-utils: "1.3.4"
  • @vue/vue2-jest: "29.2.4"

Steps to reproduce

  1. Create a simple component and use *.svg?inline in it.
  2. Try to write a simple test for that component.

Actual behaviour

  ● Test suite failed to run

    Configuration error:

    Could not locate module @/static/fonts/icons/chevron-right.svg?inline mapped as:
    /Users/ari/Documents/Projects/noeku-boilerplate/src/$1.

    Please check your configuration for these entries:
    {
      "moduleNameMapper": {
        "/^@\/(.*)$/": "/Users/ari/Documents/Projects/noeku-boilerplate/src/$1"
      },
      "resolver": undefined
    }

       8 |       >
       9 |         <component
    > 10 |           :is="back ? 'a' : 'nuxt-link'"
         |                                        ^
      11 |           v-bind="{[back ? 'href' : 'to']: link}"
      12 |           :title="text"
      13 |           class="breadcrumb__link"

      at createNoMappedModuleFoundError (node_modules/jest-resolve/build/resolver.js:759:17)
      at Object.require (src/components/Shared/Breadcrumb.vue:10:40)
      at Object.require (src/components/Shared/tests/breadcrumb.test.js:6:1)

Tested Solutions

I found some solutions by creating a new transformer but they don't work on the latest test packages versions. Also one of the solutions was adding a new moduleNameMapper:

'^@/(.*svg)(\\?inline)$': '<rootDir>/src/$1'

But this also leads us to another error:

  ● Console

    console.error
      [Vue warn]: Invalid Component definition:

      found in

      ---> <Breadcrumb>
             <Root>

      81 |     list-style: none;
      82 |     display: flex;
    > 83 |     align-items: center;
         |               ^
      84 |
      85 |     &:last-child {
      86 |       > svg {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant