quasar-testing icon indicating copy to clipboard operation
quasar-testing copied to clipboard

Default Jest implementation is not working out of the box

Open HarisSpahija opened this issue 3 years ago • 0 comments

Software version

OS: Windows 11 / Mac Monterey Node: v16.16.0 NPM: 8.11.0 Any other software related to your bug:

What did you get as the error?

When running unit tests with default configuration the following error is returned on npm run test:unit

$ npm run test:unit
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.

> [email protected] test:unit
> jest --updateSnapshot

 FAIL  test/jest/__tests__/MyDialog.spec.js
  ● Test suite failed to run
                                                                                                                                                                                                          
    Cannot find module '@babel/preset-env'                                                                                                                                                                
    Require stack:                                                                                                                                                                                        
    - C:\Users\haris\Documents\Development\quasar-project\node_modules\@babel\core\lib\config\files\plugins.js                                                                                            
    - C:\Users\haris\Documents\Development\quasar-project\node_modules\@babel\core\lib\config\files\index.js                                                                                              
    - C:\Users\haris\Documents\Development\quasar-project\node_modules\@babel\core\lib\index.js                                                                                                           
    - C:\Users\haris\Documents\Development\quasar-project\node_modules\vue-jest\lib\process.js
    - C:\Users\haris\Documents\Development\quasar-project\node_modules\vue-jest\lib\index.js
    - C:\Users\haris\Documents\Development\quasar-project\node_modules\@jest\transform\build\ScriptTransformer.js
    - C:\Users\haris\Documents\Development\quasar-project\node_modules\@jest\transform\build\index.js
    - C:\Users\haris\Documents\Development\quasar-project\node_modules\jest-runtime\build\index.js
    - C:\Users\haris\Documents\Development\quasar-project\node_modules\jest-runner\build\testWorker.js
    - C:\Users\haris\Documents\Development\quasar-project\node_modules\jest-worker\build\workers\processChild.js

    Require stack:
      node_modules/@babel/core/lib/config/files/plugins.js
      node_modules/@babel/core/lib/config/files/index.js
      node_modules/@babel/core/lib/index.js
      node_modules/vue-jest/lib/process.js
      node_modules/vue-jest/lib/index.js
      node_modules/@jest/transform/build/ScriptTransformer.js
      node_modules/@jest/transform/build/index.js
      node_modules/jest-runtime/build/index.js
      node_modules/jest-runner/build/testWorker.js
      node_modules/jest-worker/build/workers/processChild.js


    However, Jest was able to find:
        'demo/MyDialog.ts'
        'demo/MyDialog.vue'

    You might want to include a file extension in your import, or update your 'moduleFileExtensions', which is currently ['vue', 'js', 'jsx', 'json', 'ts', 'tsx'].

    See https://jestjs.io/docs/en/configuration#modulefileextensions-arraystring

      at tryRequireResolve (node_modules/@babel/core/lib/config/files/plugins.js:157:9)
      at resolveStandardizedNameForRequire (node_modules/@babel/core/lib/config/files/plugins.js:195:19)
      at sync (node_modules/@babel/core/lib/config/files/plugins.js:224:12)
      at sync (node_modules/gensync/index.js:182:19)
      at node_modules/gensync/index.js:210:24
      at resolvePreset (node_modules/@babel/core/lib/config/files/plugins.js:87:17)
          at resolvePreset.next (<anonymous>)

 FAIL  test/jest/__tests__/MyButton.spec.ts
  ● Test suite failed to run                                                                                                                                                                              
                                                                                                                                                                                                          
    Cannot find module '@babel/preset-env'                                                                                                                                                                
    Require stack:                                                                                                                                                                                        
    - C:\Users\haris\Documents\Development\quasar-project\node_modules\@babel\core\lib\config\files\plugins.js                                                                                            
    - C:\Users\haris\Documents\Development\quasar-project\node_modules\@babel\core\lib\config\files\index.js                                                                                              
    - C:\Users\haris\Documents\Development\quasar-project\node_modules\@babel\core\lib\index.js                                                                                                           
    - C:\Users\haris\Documents\Development\quasar-project\node_modules\vue-jest\lib\process.js
    - C:\Users\haris\Documents\Development\quasar-project\node_modules\vue-jest\lib\index.js
    - C:\Users\haris\Documents\Development\quasar-project\node_modules\@jest\transform\build\ScriptTransformer.js
    - C:\Users\haris\Documents\Development\quasar-project\node_modules\@jest\transform\build\index.js
    - C:\Users\haris\Documents\Development\quasar-project\node_modules\jest-runtime\build\index.js
    - C:\Users\haris\Documents\Development\quasar-project\node_modules\jest-runner\build\testWorker.js
    - C:\Users\haris\Documents\Development\quasar-project\node_modules\jest-worker\build\workers\processChild.js

    Require stack:
      node_modules/@babel/core/lib/config/files/plugins.js
      node_modules/@babel/core/lib/config/files/index.js
      node_modules/@babel/core/lib/index.js
      node_modules/vue-jest/lib/process.js
      node_modules/vue-jest/lib/index.js
      node_modules/@jest/transform/build/ScriptTransformer.js
      node_modules/@jest/transform/build/index.js
      node_modules/jest-runtime/build/index.js
      node_modules/jest-runner/build/testWorker.js
      node_modules/jest-worker/build/workers/processChild.js


    However, Jest was able to find:
        'demo/MyButton.ts'
        'demo/MyButton.vue'

    You might want to include a file extension in your import, or update your 'moduleFileExtensions', which is currently ['vue', 'js', 'jsx', 'json', 'ts', 'tsx'].

    See https://jestjs.io/docs/en/configuration#modulefileextensions-arraystring

      at tryRequireResolve (node_modules/@babel/core/lib/config/files/plugins.js:157:9)
      at resolveStandardizedNameForRequire (node_modules/@babel/core/lib/config/files/plugins.js:195:19)
      at sync (node_modules/@babel/core/lib/config/files/plugins.js:224:12)
      at sync (node_modules/gensync/index.js:182:19)
      at node_modules/gensync/index.js:210:24
      at resolvePreset (node_modules/@babel/core/lib/config/files/plugins.js:87:17)
          at resolvePreset.next (<anonymous>)

Test Suites: 2 failed, 2 total
Tests:       0 total
Snapshots:   0 total
Time:        2.196 s
Ran all test suites.

What were you expecting?

Expect that both 2 default tests would pass

What steps did you take, to get the error?

npm init quasar
quasar ext add @quasar/testing

Repo: https://github.com/HarisSpahija/quasar-testing-example-quasar-cli

HarisSpahija avatar Jul 25 '22 14:07 HarisSpahija