Skip to content

[fix] "Object prototype may only be an Object or null: undefined" from supertest in browser contexts #1840

Description

@codders

Describe the bug

Node.js version: 20.10.0

OS version: debian trixie/sid

Description: Including supertest in a cypress project results in the error Object prototype may only be an Object or null: undefined when supertest tries to include superagent.

Actual behavior

Creating a blank cypress project and including supertest as a requirement in any spec file generates the error

Object prototype may only be an Object or null: undefined

With the backtrace:

      at Function.setPrototypeOf (<anonymous>)
      at ./node_modules/supertest/lib/agent.js (webpack://cypress-supertest-issue-minimal/./node_modules/supertest/lib/agent.js:36:0)
      at __webpack_require__ (webpack://cypress-supertest-issue-minimal/webpack/bootstrap:19:0)
      at ./node_modules/supertest/index.js (webpack://cypress-supertest-issue-minimal/./node_modules/supertest/index.js:9:14)
      at __webpack_require__ (webpack://cypress-supertest-issue-minimal/webpack/bootstrap:19:0)
      at eval (webpack://cypress-supertest-issue-minimal/./cypress/e2e/spec.cy.js:1:18)

Expected behavior

It should be possible to require (and use) the library without issue, as was the case until version 6.2.4.

Code to reproduce

I created an example project with a minimal reproduction here: https://github.com/codders/cypress-supertest-issue-minimal

Checklist

  • I have searched through GitHub issues for similar issues.
  • I have completely read through the README and documentation.
  • I have tested my code with the latest version of Node.js and this package and confirmed it is still not working.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions