Supertest: Error after upgrade

Created on 18 Jan 2021  路  8Comments  路  Source: visionmedia/supertest

I am getting following error after upgrading supertest to 6.1.1

Error: Invalid Chai property: stack. Did you mean "same"?
    at Object.proxyGetter [as get] (node_modules/chai/lib/chai/utils/proxify.js:75:17)
    at /home/circleci/project/node_modules/supertest/lib/test.js:81:20

What I can do about it?

Most helpful comment

PR?

All 8 comments

Agreed, just had to downgrade to get around this

Error: Invalid Chai property: stack. Did you mean "same"?
      at Object.proxyGetter [as get] (node_modules/chai/lib/chai/utils/proxify.js:75:17)
      at /app/node_modules/supertest/lib/test.js:81:20
      at Test._assertFunction (node_modules/supertest/lib/test.js:307:11)
      at Test.assert (node_modules/supertest/lib/test.js:197:21)
      at Server.localAssert (node_modules/supertest/lib/test.js:155:12)
      at Server.EventEmitter.emit (domain.js:483:12)
      at emitCloseNT (net.js:1657:8)
      at processTicksAndRejections (internal/process/task_queues.js:83:21)

Just deprecated it on npm - if someone wants to PR the fix and ping me I will accept / merge / release to npm

does anyone have an example of a test that causes this issue?

I have ran supertest 6.1.1 with jest 26.6.3 over multiple projects and not seen these error.

I think 6.1.2 fixes this

Given the following example:

await request.get(`/api/v1/myResource`)
      .send()
      .expect(200)
      .expect(res => res.body.should.have.property('id'))

The error described above happens when the chai assertion succeeds. The reason is that the result of the arrow function is the chai assertion proxy.
At supertest/lib/test.js#L80:

var err = assertFn(res);
if (err && err.stack) {
    ...
 }

Then using err.stack causes chai to throw the error Invalid Chai property: stack.
Since err is expected to be an Error object, from SuperTest assertions or Chai assertions, the check should use instanceof instead:

var err = assertFn(res);
if (err instanceof Error && err.stack) {
    ...
 }

PR?

@niftylettuce on the way

v6.1.3 released to npm, any further issues please open another issue or submit a PR

thanks @janthoe https://github.com/visionmedia/supertest/releases/tag/v6.1.3

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lovelydreamer picture lovelydreamer  路  4Comments

ghost picture ghost  路  5Comments

EverettQuebral picture EverettQuebral  路  3Comments

nitrocode picture nitrocode  路  4Comments

DeaconDesperado picture DeaconDesperado  路  6Comments