quasarframework / quasar-testing

Testing Harness App Extensions for the Quasar Framework 2.0+
https://testing.quasar.dev
MIT License
180 stars 65 forks source link

Default Jest implementation is not working out of the box #273

Closed HarisSpahija closed 1 year ago

HarisSpahija commented 2 years ago

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.

> quasar-project@0.0.1 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

squareloop1 commented 1 year ago

Happening for me too when initializing a new vite project with quasar cli:

Test suite failed to run

    Cannot find module '@quasar/babel-preset-app'
IlCallo commented 1 year ago

I hoped to be able to work on this in the past few months, but had a really hard time doing so due to other projects, Cypress AE support and vacations

I hope I'll be able to work on it in the next few months, but I'd gladly accept help from the community I can provide guidance about what we need to do, here you can find the roadmap for the AE: https://github.com/quasarframework/quasar-testing/projects/5

IlCallo commented 1 year ago

Tried this out now, you're using Jest with Vite, which won't work and is a know problem

Check out Vitest AE instead