javascriptnode.jsjestjses6-modulessupertest

Can you import Supertest as a ES6 module?


I am trying to use Jest with Supertest package to test my API. I tried using import { request } from "supertest"; to be able to use request in my file but got a SyntaxError saying that the module supertest does not provide an export called 'request'.
Any idea on how to use it this way?


Solution

  • supertest provides the function through a default export, so you will do

    import request from "supertest"
    

    instead