No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Testing

    Help
    25
    55
    23741
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Jaxon
      Jaxon @visiond last edited by

      @visiond Hey Vision, unfortunately not. I’m just putting testing on ‘Ice’ tell its out of the box with the Quasar CLI, should be after v1.0 hopefully.

      V 1 Reply Last reply Reply Quote 0
      • V
        visiond @Jaxon last edited by visiond

        @jaxon I found the solution, in your package.json, inside moduleNameMapper use
        "quasar": "<rootDir>/node_modules/quasar-framework/dist/umd/quasar.mat.umd.js"

        Hope it helps 😃

        1 Reply Last reply Reply Quote 0
        • V
          visiond last edited by visiond

          Also if someone runs into warnings like unknown custom element: <router-link> child component when using q-item with routes like <q-item to="/path"></q-item>, a solution is to stub it to router-link and stub router links again, its hacky but it works

          const wrapper = shallowMount(MyComponent, {
            localVue,
            stubs: {
              'q-item': '<router-link to=""></router-link>',
              RouterLink: RouterLinkStub
            }
          })
          1 Reply Last reply Reply Quote 0
          • P
            ppal last edited by

            I’ve successfully run test with jest and Quasar 0.16 using below steps:

            • npm i --save-dev jest babel-core@7.0.0-bridge.0 @vue/test-utils

            • modify package.json:
              “scripts”: {
              …
              “test”: “jest”
              }

            • modify .babelrc by adding the “env” section
              {
              “env”: {
              “test”: {
              “presets”: [ [
              “@babel/preset-env”, {
              “modules”: “commonjs”
              }
              ]
              ]
              }
              },
              “presets”: [
              …

            Test run successfully using test scripts from https://github.com/vuejs/vue-test-utils-getting-started.

            A 1 Reply Last reply Reply Quote 1
            • A
              april @ppal last edited by

              This post is deleted!
              1 Reply Last reply Reply Quote 0
              • A
                april last edited by

                In the package.json file,

                • under “jest” --> “moduleNameMapper” , I added “quasar”: “<rootDir>/node_modules/quasar-framework/dist/umd/quasar.mat.umd.js”
                • under “jest” --> “transform”, I use “.*\.(vue)$”: “<rootDir>/node_modules/jest-vue-preprocessor”. I was unable to make the test run with vue-jest.
                  When running, npm test, I got this error
                TypeError: Cannot read property 'adjustDate' of undefined
                
                      1 | import {date} from 'quasar'
                      2 | 
                    > 3 | const { adjustDate } = date
                

                Does anyone know why?

                Full “jest” config in package.json file

                "jest": {
                        "moduleFileExtensions": [
                            "js",
                            "vue"
                        ],
                        "collectCoverageFrom": [
                            "**/*.{vue}"
                        ],
                        "transformIgnorePatterns": [
                            "node_modules/core-js",
                            "node_modules/babel-runtime",
                            "node_modules/lodash",
                            "node_modules/vue"
                        ],
                        "moduleNameMapper": {
                            "^src/(.*)$": "<rootDir>/src/$1",
                            "^assets/(.*)$": "<rootDir>/src/assets/$1",
                            "^@/(.*)$": "<rootDir>/src/components/$1",
                            "^variables/(.*)$": "<rootDir>/src/themes/quasar.variables.sty/$1",
                            "^vue$": "<rootDir>/node_modules/vue/dist/vue.common.js",
                            "quasar": "<rootDir>/node_modules/quasar-framework/dist/umd/quasar.mat.umd.js"
                        },
                        "transform": {
                            "^.+\\.js$": "<rootDir>/node_modules/babel-jest",
                            ".*\\.(vue)$": "<rootDir>/node_modules/jest-vue-preprocessor"
                        }
                    }
                
                1 Reply Last reply Reply Quote 0
                • N
                  niallobrien last edited by

                  Hi all, now that Vue CLI 3 has been released, can we solidify a testing solution with Quasar out of the box?

                  Thanks in advance.

                  1 Reply Last reply Reply Quote 1
                  • Akaryatrh
                    Akaryatrh last edited by

                    @niallobrien https://github.com/quasarframework/quasar-testing (work in progress)

                    1 Reply Last reply Reply Quote 1
                    • nothingismagick
                      nothingismagick last edited by

                      You can also check out a working example as a starter kit here:
                      https://github.com/nothingismagick/quasar-starter-ssr-pwa-jest-cypress

                      (with full integration of quasar components in Jest)

                      1 Reply Last reply Reply Quote 1
                      • nothingismagick
                        nothingismagick last edited by

                        @quasar/testing is NOW beta quality and in use in a number of production projects. Requires 1.0, but everything is prerigged @Frosty-Z - check it out.
                        You just need to:

                        $ quasar ext add @quasar/testing
                        

                        and choose your test harnesses (currently jest, ava, cypress and webdriver are available, more to follow!)

                        1 Reply Last reply Reply Quote 1
                        • First post
                          Last post