ElektraInitiative / PermaplanT

https://www.permaplant.net
BSD 3-Clause "New" or "Revised" License
16 stars 13 forks source link

ReferenceError: jest is not defined #1147

Closed markus2330 closed 10 months ago

markus2330 commented 10 months ago

Describe the Bug

https://build.libelektra.org/blue/organizations/jenkins/PermaplanT/detail/PR-1143/7/pipeline

Steps to Reproduce the Problem

cd frontend && npm install && npm run test

Expected Result

success

Actual Result

npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: 'vite@5.0.10',
npm WARN EBADENGINE   required: { node: '^18.0.0 || >=20.0.0' },
npm WARN EBADENGINE   current: { node: 'v19.9.0', npm: '9.6.3' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: 'vite-node@1.1.0',
npm WARN EBADENGINE   required: { node: '^18.0.0 || >=20.0.0' },
npm WARN EBADENGINE   current: { node: 'v19.9.0', npm: '9.6.3' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: 'vitest@1.1.0',
npm WARN EBADENGINE   required: { node: '^18.0.0 || >=20.0.0' },
npm WARN EBADENGINE   current: { node: 'v19.9.0', npm: '9.6.3' }
npm WARN EBADENGINE }

⎯⎯⎯⎯⎯⎯ Unhandled Errors ⎯⎯⎯⎯⎯⎯

Vitest caught 1 unhandled error during the test run.
This might cause false positive tests. Resolve unhandled errors to make sure your tests are not affected.

⎯⎯⎯⎯ Unhandled Rejection ⎯⎯⎯⎯⎯

ReferenceError: jest is not defined

 ❯ node_modules/jest-canvas-mock/lib/mock/createImageBitmap.js node_modules/jest-canvas-mock/lib/mock/createImageBitmap.js:9:16
 ❯ __require node_modules/.vitest/deps/window-47HM6YMB.js:3:50
 ❯ node_modules/jest-canvas-mock/lib/window.js node_modules/jest-canvas-mock/lib/window.js:16:49
 ❯ __require node_modules/.vitest/deps/window-47HM6YMB.js:3:50
 ❯ node_modules/.vitest/deps/window-47HM6YMB.js:3613:16
 ❯ ModuleJob.run node:internal/modules/esm/module_job:218:25
 ❯ ModuleLoader.import node:internal/modules/esm/loader:329:24
 ❯ importMockWindow node_modules/vitest-canvas-mock/dist/index.js:16:27

This error originated in "src/features/map_planning/layers/base/util.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running.

PermaplanT version

master

Operating System

Linux

Browser

tests

Versions of other relevant software/extensions

No response

Additional info/logs

When running again it succeeded.

Bushuo commented 10 months ago

Working on this. Was sick the last few days but I hope I can fix this today or tomorrow.

Bushuo commented 10 months ago

It is really strange because locally all the tests are running through.

Bushuo commented 10 months ago

@markus2330 Tests are now passing in #1141 It has to do with fake timers.

Bushuo commented 10 months ago

@markus2330 Sadly my solution in #1141 did not work. This is such a strange problem. I decided to see if I can get it to work without the 'vitest-canvas-mock' package. The result is in #1149. I stumbled upon another issue, which made me remove some failing tests.

markus2330 commented 10 months ago

Thx for working on it! I didn't really find which commits in #1149 you refer to, but as long all tests reliably run, I am fine with the solution. If tests make less sense now, of course, feel free to remove them. :+1:

1149 seems to get huge...

Bushuo commented 10 months ago

@markus2330

1149 seems to get huge...

This is because it is based on #1141.

I didn't really find which commits in https://github.com/ElektraInitiative/PermaplanT/pull/1149 you refer to

This one 122d26e74e02a95a66f87bafe596deccd0e2bd13

markus2330 commented 10 months ago

LGTM. I assume you didn't skip the test so that we avoid the dep to the otherwise unused lib?

Bushuo commented 10 months ago

Didn't think about using skip. I just commended it out. But I like skip better, so will change it to that.