vlucas / frisby

Frisby is a REST API testing framework built on Jest that makes testing API endpoints easy, fast, and fun.

Home Page:http://frisbyjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Latest joi version does not work

flogr opened this issue · comments

If i set up the Joi assertions like in the readme with

require('joi');

type assertion does not work.

If i use the the one coming with frisby

frisby.Joi

it work.

There seems to be a problem with the latest one?

commented

Can confirm. The last working major version seems to be @hapi/joi@15. Later versions of @hapi/joi and (from 17 on) joi fail with this error:

   Message:
      Invalid schema content: (someArray.$_root.alternatives)

      at Object.<anonymous>.exports.schema (node_modules/frisby/node_modules/joi/lib/cast.js:55:10)
      at Object.<anonymous>.internals.Object.keys (node_modules/frisby/node_modules/joi/lib/types/object/index.js:359:35)
      at Object.<anonymous>.exports.schema (node_modules/frisby/node_modules/joi/lib/cast.js:36:29)
      at Object.<anonymous>.internals.Object.keys (node_modules/frisby/node_modules/joi/lib/types/object/index.js:359:35)
      at Object.<anonymous>.exports.schema (node_modules/frisby/node_modules/joi/lib/cast.js:36:29)
      at Object.<anonymous>.internals.Object.keys (node_modules/frisby/node_modules/joi/lib/types/object/index.js:359:35)
      at Object.<anonymous>.exports.schema (node_modules/frisby/node_modules/joi/lib/cast.js:36:29)
      at Object.<anonymous>.module.exports.internals.Any.root.compile (node_modules/frisby/node_modules/joi/lib/index.js:158:25)
      at Object.<anonymous>.module.exports.internals.Any.root.validate (node_modules/frisby/node_modules/joi/lib/index.js:144:29)
      at jsonTypesAssertion (node_modules/frisby/src/frisby/expects.js:122:24)
      at node_modules/frisby/src/frisby/utils.js:67:7
      at arrayEach (node_modules/lodash/lodash.js:530:11)
      at Function.forEach (node_modules/lodash/lodash.js:9410:14)
      at Object.withPath (node_modules/frisby/src/frisby/utils.js:66:7)
      at FrisbySpec.jsonTypes (node_modules/frisby/src/frisby/expects.js:121:11)
      at node_modules/frisby/src/frisby/spec.js:421:23
      at node_modules/frisby/src/frisby/spec.js:250:34

when the expectation is this:

      .expect('jsonTypes', '*', {
        someArray Joi.array()
      })
❯ npm ls frisby
<my project name>@ /<my project path>
└── frisby@2.1.3

❯ node -v
v19.5.0
commented

Actually it is not released yet. Try npm i -D github:vlucas/frisby instead.

commented

Time to release 3.0.0 then, I guess? :)