quasarframework / quasar-testing

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

jest tests are failing after upgrade to 3.0.0-alpha.7 #200

Closed cbleek closed 2 years ago

cbleek commented 2 years ago

downgrade to 3.0.0-alpha.6 fixes the tests again.

Fixed by: yarn add @quasar/quasar-app-extension-testing-unit-jest@3.0.0-alpha.6 -D

Example Test: https://gitlab.com/yawik/applicationform/-/blob/master/src/components/PageFooter.jest.spec.js

Example Error Messages:

$ jest --ci src/components/PageFooter.jest.spec.js
 FAIL  src/components/PageFooter.jest.spec.js
  PageFooter
    ✕ mounts without errors (28 ms)
    ✕ check enviroment properties (2 ms)

  ● PageFooter › mounts without errors

    TypeError: Cannot convert undefined or null to object
        at Function.assign (<anonymous>)

      19 |   beforeEach(() =>
      20 |   {
    > 21 |     cmp = shallowMount(PageFooter);
         |           ^
      22 |   });
      23 |
      24 |   it('mounts without errors', () =>

      at installQuasar (node_modules/quasar/dist/quasar.cjs.prod.js:6:13695)
      at Object.install (node_modules/quasar/dist/quasar.cjs.prod.js:6:473767)
      at Object.use (node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:3101:28)
      at mount (node_modules/@vue/test-utils/dist/vue-test-utils.cjs.js:7803:25)
      at shallowMount (node_modules/@vue/test-utils/dist/vue-test-utils.cjs.js:7875:12)
      at Object.<anonymous> (src/components/PageFooter.jest.spec.js:21:11)

  ● PageFooter › mounts without errors

    expect(received).toBeTruthy()

    Received: undefined

      24 |   it('mounts without errors', () =>
      25 |   {
    > 26 |     expect(cmp).toBeTruthy();
         |                 ^
      27 |   });
      28 |
      29 |   it('check enviroment properties', () =>

      at Object.<anonymous> (src/components/PageFooter.jest.spec.js:26:17)

  ● PageFooter › check enviroment properties

    TypeError: Cannot convert undefined or null to object
        at Function.assign (<anonymous>)

      19 |   beforeEach(() =>
      20 |   {
    > 21 |     cmp = shallowMount(PageFooter);
         |           ^
      22 |   });
      23 |
      24 |   it('mounts without errors', () =>

      at installQuasar (node_modules/quasar/dist/quasar.cjs.prod.js:6:13695)
      at Object.install (node_modules/quasar/dist/quasar.cjs.prod.js:6:473767)
      at Object.use (node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:3101:28)
      at mount (node_modules/@vue/test-utils/dist/vue-test-utils.cjs.js:7803:25)
      at shallowMount (node_modules/@vue/test-utils/dist/vue-test-utils.cjs.js:7875:12)
      at Object.<anonymous> (src/components/PageFooter.jest.spec.js:21:11)

  ● PageFooter › check enviroment properties

    TypeError: Cannot read property 'vm' of undefined

      30 |   {
      31 |     process.env.YAWIK_URL_OPERATOR = 'test';
    > 32 |     expect(cmp.vm.urlOperator).toBe('test');
         |                ^
      33 |     process.env.YAWIK_URL_PRIVACY = 'test';
      34 |     expect(cmp.vm.urlPrivacy).toBe('test');
      35 |     process.env.YAWIK_URL_IMPRINT = 'test';

      at Object.<anonymous> (src/components/PageFooter.jest.spec.js:32:16)

Test Suites: 1 failed, 1 total
Tests:       2 failed, 2 total
Snapshots:   0 total
Time:        5.575 s
IlCallo commented 2 years ago

Have you read release notes? There are some manual tweaks you'll need to perform between beta6 and beta7 Go through the updated migration guide and check if you miss something

cbleek commented 2 years ago

I have read the notes. But we have a hard time figuring out what needs to be tweaked manually.

I would pay you $100, if you show me how to fix the simple test

https://gitlab.com/yawik/applicationform/-/blob/master/src/components/PageFooter.jest.spec.js

II would be willing to pay via Upwork or Github Sponsors.

IlCallo commented 2 years ago

Some update steps I see have not be applied, or have been applied only partially, taken from the README migration guide:

The last one is probably the cause of your issues Also consider that QFooter may require QLayout injections to work properly, as QPage, QDrawer, etc do Check this out in that regards: https://github.com/quasarframework/quasar-testing/tree/next/packages/unit-jest#testing-qpage-components

If this helped you, please donate those $100 to Quasar project directly: https://github.com/sponsors/rstoenescu

cbleek commented 2 years ago

yes. It helped. Thank you.

I've increased my sponsorship to the next level

https://gitlab.com/yawik/applicationform/-/commit/cb1484ac41cc7286f2b9569927d94ad9d427852b

IlCallo commented 2 years ago

Happy it worked :)