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

    @quasar/testing appears to be broken

    CLI
    2
    12
    1664
    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.
    • Jezzta667
      Jezzta667 last edited by Jezzta667

      Whilst running Jest unit tests on a fresh install of Quasar and @quasar/testing, the following error is being logged to the console:

      $ yarn test:unit
      yarn run v1.12.3
      $ jest --updateSnapshot
      ● Validation Error:
      
        Module <rootDir>/node_modules/vue-jest in the transform option was no
      t found.
               <rootDir> is: C:\code\quasar-testing
      
        Configuration Documentation:
        https://jestjs.io/docs/configuration.html
      
      error Command failed with exit code 1.
      info Visit https://yarnpkg.com/en/docs/cli/run for documentation about
      this command.
      

      For some reason, vue-jest is not in the node-modules folder.

      After installing vue-jest, the following error is thrown:

      ● Validation Error:
      
        Module <rootDir>/node_modules/babel-jest in the transform option was
      not found.
               <rootDir> is: C:\code\quasar-testing
      
        Configuration Documentation:
        https://jestjs.io/docs/configuration.html
      

      After installing babel-jest, an error is thrown that begins with ERROR: Cannot find module 'babel-core'

      The commands that I executed to set up this fresh install were as follows:

      quasar create quasar-testing -b dev
      

      SELECT: All defaults

      cd quasar-testing
      quasar ext --add @quasar/testing
      

      SELECT: Jest Unit Testing
      SELECT: Overwrite babel.config.js and use additional .babelrc
      SELECT: SFC webpack <test> loader
      SELECT: extra “scripts” in your package.json

      quasar run @quasar/testing test -- --unit jest --dev="-m pwa"
      

      Same problem occurs with yarn test:unit

      1 Reply Last reply Reply Quote 0
      • Jezzta667
        Jezzta667 last edited by

        @nothingismagick I have now checked this on a second computer and the same issue persists.

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

          So I assume you are running this within a quasar 1.0 beta package, no? What does quasar info tell you when you run it within your project directory?

          Jezzta667 1 Reply Last reply Reply Quote 0
          • Jezzta667
            Jezzta667 @nothingismagick last edited by Jezzta667

            @nothingismagick quasar info on a fresh install of quasar and @quasar/testing with Jest outputs the following:

            $ quasar info
            
            Operating System - Windows_NT(10.0.17134) - win32/x64
            NodeJs - 8.12.0
            
            Global packages
              NPM - 6.4.1
              yarn - 1.12.3
              @quasar/cli - 1.0.0-beta.0
              cordova - Not installed
            
            Important local packages
              quasar - 1.0.0-beta.2 -- High performance, Material Design 2, full front end stack with Vue.js -- build SPA, SSR, PWA, Hybrid Mobile Apps and Electron apps, all simultaneously using the same codebase
              @quasar/app - 1.0.0-beta.4 -- Quasar Framework App CLI
              @quasar/extras - 1.0.0 -- Quasar Framework fonts, icons and animations
              vue - 2.6.6 -- Reactive, component-oriented view layer for modern web interfaces.
              vue-router - 3.0.2 -- Official router for Vue.js 2
              vuex - 3.1.0 -- state management for Vue.js
              electron - Not installed
              electron-packager - Not installed
              electron-builder - Not installed
              @babel/core - 7.2.2 -- Babel compiler core.
              webpack - 4.29.3 -- Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.
              webpack-dev-server - 3.1.14 -- Serves a webpack app. Updates the browser on changes.
              workbox-webpack-plugin - 3.6.3 -- A plugin for your Webpack build process, helping you generate a manifest of local files that workbox-sw should precache.
              register-service-worker - 1.6.1 -- Script for registering service worker, with hooks
            
            Quasar App Extensions
              @quasar/quasar-app-extension-testing-unit-jest - 1.0.0-beta.6 -- A Quasar App Extension for running Jest tests
              @quasar/quasar-app-extension-testing - 1.0.0-beta.6 -- A Quasar App Extension for managing Test Harnesses
            
            1 Reply Last reply Reply Quote 0
            • nothingismagick
              nothingismagick last edited by nothingismagick

              Please update your @quasar/cli global.

              + @quasar/cli@1.0.0-beta.2

              If that doesn’t work, I am at a bit of a loss, because in all of the windows tests that we ran before promoting uni-jest to beta there was never a problem. Are you running this within a lerna monorepo? Are you installing with yarn or npm?

              Here is the transform that we currently deliver:
              /jest.config.js

                transform: {
                  '.*\\.vue$': '<rootDir>/node_modules/vue-jest',
                  '.*\\.js$': '<rootDir>/node_modules/babel-jest'
                },
              
              Jezzta667 1 Reply Last reply Reply Quote 0
              • Jezzta667
                Jezzta667 @nothingismagick last edited by Jezzta667

                @nothingismagick

                I’m installing with yarn and I don’t know what a lerna monorepo is.

                I have tried updating the CLI with yarn upgrade global @quasar/cli
                The result is the same. I have also tried this on my Macbook and it was the same result.

                For whatever reason, vue-jest and babel-jest are there in the transform section but are not present in the node_modules folder.

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

                  Ok, I will try to replicate your problems.

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

                    I am not sure WHY this is happening all of the sudden, but can confirm. Thankyou for reporting. Please try this in your jest.config.js file:

                      transform: {
                        '.*\\.vue$': '<rootDir>/node_modules/@quasar/quasar-app-extension-testing-unit-jest/node_modules/vue-jest',
                        '.*\\.js$': '<rootDir>/node_modules/@quasar/quasar-app-extension-testing-unit-jest/node_modules/babel-jest'
                      },
                    
                    nothingismagick Jezzta667 2 Replies Last reply Reply Quote 1
                    • nothingismagick
                      nothingismagick @nothingismagick last edited by

                      After the change, this is what you should see:

                      0_1550487314643_Screen Shot 2019-02-18 at 11.54.31.png

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

                        @nothingismagick yes, that did the trick. Glad I can be of help!

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

                          Ok great. I will push beta.7 momentarily, but will continue digging in to figure out WHY these modules aren’t being installed in the consuming project all of the sudden.

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

                            @Jezzta667 - and then suddenly the fix stopped working. I am not sure what is going on, but my hunch is that the NPM servers are being flaky. I have refactored the transform to match the suggested approach, but left your solution “commented out”. For the time being this is the best I can do.

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