this error
Uncaught exception: Error: listen EADDRINUSE: address already in use :::3000
import supertest from "supertest"
import axios from "axios"
import app from ".."
const request = supertest(app)
describe("Test endpoint responses", () => {
it("gets the api endpoint", async () => {
const response = await request.get("/api/images")
expect(response.ok).toBe(false)
})
})
CodePudding user response:
This means that the port 3000 of the machine that is executing the test is already used. As a general rule, a port cannot be used by multiple application at the same time.
In your case, you probably already have another test running, or a local development server running on this port.
You can either stop it, or configure your test runner to use a different port.
EDIT 1 :
As mentioned by chovy in comment, you can prepend your command with PORT=3001