我尝试为我的简单 NestJS 后端服务引入 e2e 测试。我提供一个自定义 userService 和一个用 sinon 模拟的自定义 UserRepository。
这是我的user.e2e-spec.ts文件:
import * as request from 'supertest';
import * as sinon from 'sinon';
import { Test } from '@nestjs/testing';
import { INestApplication } from '@nestjs/common';
import { UserService } from '../../src/user/user.service';
import { getRepositoryToken } from '@nestjs/typeorm';
import { User } from '../../src/user/user.entity';
import { TestUtil } from '../../src/utils/TestUtil';
import { createFakeUser } from '../../src/user/test/userTestUtil';
let sandbox: sinon.SinonSandbox;
let testUtil;
describe('User', () => {
let app: INestApplication;
const …Run Code Online (Sandbox Code Playgroud)