-
Notifications
You must be signed in to change notification settings - Fork 185
Closed
Description
Hi team! 👋🏼
I upgraded a project from watt 2 to 3: platformatic/watt-admin#107
There is a problem related to the tests. As you can see, if you try to run, for instance, node --test 'web/backend/test/plugins/metrics.test.ts', you will notice this error:
✖ metrics without runtime (128.455459ms)
✖ metrics with runtime (1425.3515ms)
ℹ tests 2
ℹ suites 0
ℹ pass 0
ℹ fail 2
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 1886.422333
✖ failing tests:
test at web/backend/test/plugins/metrics.test.ts:6:1
✖ metrics without runtime (128.455459ms)
TypeError [Error]: Cannot use 'in' operator to search for '_idleTimeout' in undefined
at TestContext.<anonymous> (watt-admin/web/backend/test/plugins/metrics.test.ts:8:28)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async Test.run (node:internal/test_runner/test:1054:7)
at async startSubtestAfterBootstrap (node:internal/test_runner/harness:296:3)
test at web/backend/test/plugins/metrics.test.ts:13:1
✖ metrics with runtime (1425.3515ms)
TypeError [Error]: Cannot read properties of undefined (reading 'metrics')
at check (watt-admin/web/backend/test/helper.ts:19:37)
at watt-admin/web/backend/test/helper.ts:33:5
at new Promise (<anonymous>)
at loadMetrics (watt-admin/web/backend/test/helper.ts:14:10)
at TestContext.<anonymous> (watt-admin/web/backend/test/plugins/metrics.test.ts:18:9)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async Test.run (node:internal/test_runner/test:1054:7)
at async Test.processPendingSubtests (node:internal/test_runner/test:744:7)It seems that the Fastify plugins aren't loading. In this case, the metrics decorator is instantiated in web/backend/plugins/metrics.ts, but as you can see, the server in the test does not have it. I updated the code to use create instead of buildServer, as in web/backend/utils/client.openapi.ts. In this last file, everything works, but in the tests, it appears that Fastify isn't loading the plugins. Do you know what might have changed in v3 that's causing this problem?
Metadata
Metadata
Assignees
Labels
No labels