Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Issue upgrading watt from v2 to v3 #4307

Copy link
Copy link
@rozzilla

Description

@rozzilla
Issue body actions

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.