Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error after upgrade #700

Closed
cajoy opened this issue Jan 18, 2021 · 8 comments · Fixed by newerton/gostack-template-fundamentos-node#15
Closed

Error after upgrade #700

cajoy opened this issue Jan 18, 2021 · 8 comments · Fixed by newerton/gostack-template-fundamentos-node#15

Comments

@cajoy
Copy link

cajoy commented Jan 18, 2021

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?

@efr-chriswilliams
Copy link

efr-chriswilliams commented Jan 18, 2021

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)

@niftylettuce
Copy link
Collaborator

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

@vorticalbox
Copy link

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.

@niftylettuce
Copy link
Collaborator

I think 6.1.2 fixes this

@janthoe
Copy link
Contributor

janthoe commented Jan 25, 2021

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) {
    ...
 }

@niftylettuce
Copy link
Collaborator

PR?

@janthoe
Copy link
Contributor

janthoe commented Jan 25, 2021

@niftylettuce on the way

niftylettuce added a commit that referenced this issue Jan 25, 2021
fix: Check error object before updating stack. (Fixes #700)
@niftylettuce
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants