So I'm working on a Nodejs project with expressjs and I'm trying to use Jest to test my apis. I've read about configuring Jest in the documentation, but I'm new to jest and it's a bit confusing. The error I'm getting :
SyntaxError: Cannot use import statement outside a module at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1796:14)
My test file:
const userController = require("../controllers/user.controller");
const router = require("../routes/user.routes");
//Testing login route
describe("POST /api/user/login", () => {
describe("given a username and password", () => {
test("should respond with a 200 status code", async () => {
const response = await request(router).post("/login").send({
username: "username",
password: "password"
})
expect(response.statusCode).toBe(200)
})
})
})