Skip to content

strict mode: use allowUnionTypes to allow union type keyword at "#/properties/image" (strictTypes) during Jest tests #3984

@112RG

Description

@112RG

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the issue has not already been raised

Issue

npx jest __tests__/get.test.js -t "GET Index"
  console.warn
    strict mode: use allowUnionTypes to allow union type keyword at "#/properties/image" (strictTypes)

      at checkStrictMode (node_modules/@fastify/ajv-compiler/node_modules/ajv/lib/compile/util.ts:212:18)
      at strictTypesError (node_modules/@fastify/ajv-compiler/node_modules/ajv/lib/compile/validate/index.ts:322:18)
      at checkMultipleTypes (node_modules/@fastify/ajv-compiler/node_modules/ajv/lib/compile/validate/index.ts:294:5)
      at checkStrictTypes (node_modules/@fastify/ajv-compiler/node_modules/ajv/lib/compile/validate/index.ts:274:33)
      at schemaKeywords (node_modules/@fastify/ajv-compiler/node_modules/ajv/lib/compile/validate/index.ts:231:18)
      at typeAndKeywords (node_modules/@fastify/ajv-compiler/node_modules/ajv/lib/compile/validate/index.ts:161:3)
      at subSchemaObjCode (node_modules/@fastify/ajv-compiler/node_modules/ajv/lib/compile/validate/index.ts:147:3)

 PASS  __tests__/get.test.js
  GET Pages
    ✓ GET index (84 ms)

route
After upgrading to Fastify@V4 I have started to encounter this warning during the running of my Jest test. Now I know I should be using tap, I just haven't had to to migrate over to it yet. To my knowledge this warning only shows during test and I am guessing this is happening because of the upgrade to Ajv v8 but I am unsure reading there migration guide how to fix this.

This is the route that is being hit

  fastify.get('/', async (req, reply) => {
    return reply.view('login', { captcha: process.env.CAPTCHA_LOGIN, sitekey: process.env.CAPTCHA_SITE_KEY, token: await reply.generateCsrf() })
  })

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationgood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions