Hello! I'm new in tests on nestjs.
I'm trying to execute simple e2e test:
import {INestApplication} from "@nestjs/common";
import {Test} from "@nestjs/testing";
import {UserModule} from "./user.module";
import {UserService} from "./user.service";
import * as request from 'supertest'
describe('Users', () => {
let app: INestApplication;
let userService = {
getUsers: () => [{
email: "[email protected]",
username: "dima",
photo_avatar: "http://a.png",
password: "$2b$07$5iqO5mo5W7jvFbHDXAAJherp20ZUrt0T2qC7SKCYkXovjBnwJmLGS",
activationLink: "",
isActivated: false,
_id: "642c55a6ec9860d9b25e2080"
}]
}
beforeAll(async () => {
const moduleRef = await Test.createTestingModule({
imports: [UserModule],
})
.overrideProvider(UserService)
.useValue(userService)
.compile();
app = moduleRef.createNestApplication();
await app.init();
});
it('/GET getUsers', () => {
return request(app.getHttpServer())
.get('/client/getUsers')
.expect(201)
.expect({
data: userService.getUsers()
});
});
afterAll(async () => {
await app.close();
});
});
But i have this error:
Provided path to resolve: ./test/jest-e2e.json