ladjs / supertest

🕷 Super-agent driven library for testing node.js HTTP servers using a fluent API. Maintained for @forwardemail, @ladjs, @spamscanner, @breejs, @cabinjs, and @lassjs.
MIT License
13.81k stars 759 forks source link

Class extends value undefined #801

Open Athoh opened 1 year ago

Athoh commented 1 year ago

Hello,

I am getting error

TypeError: Class extends value undefined is not a constructor or null

      at Object.<anonymous> (../node_modules/supertest/lib/test.js:15:20)
      at Object.<anonymous> (../node_modules/supertest/index.js:14:14)

When trying to run supertest on my app. through jest --silent supertest version -> 6.3.1

Test code

import supertest from 'supertest';
import app from './app';

describe('App', () => {
  it('should reach /', () =>
    supertest(app)
      .get('/')
      .expect('Content-Type', /json/)
      .expect(200));
});

jest config:

"jest": {
    "setupFilesAfterEnv": [
      "<rootDir>/../jest.setup.ts"
    ],
    "moduleNameMapper": {
      "^@airbus/lib-transfo-utils/(.+)$": "@airbus/lib-transfo-utils/dist/$1/index.js"
    },
    "moduleFileExtensions": [
      "js",
      "json",
      "ts"
    ],
    "rootDir": "src",
    "testRegex": ".spec.ts$",
    "transform": {
      "^.+\\.(t|j)s$": "ts-jest"
    },
    "testEnvironment": "node",
    "coverageDirectory": "../coverage",
    "coveragePathIgnorePatterns": [
      "/node_modules/"
    ],
    "collectCoverage": true,
    "coverageThreshold": {
      "global": {
        "branches": 90,
        "lines": 90,
        "statements": 90,
        "functions": 90
      },
      "**/*.ts": {
        "branches": 50,
        "lines": 50,
        "statements": 50,
        "functions": 80
      }
    }
  }

Do anyone as any idea on root cause and how to fix ?