运行测试e2e时,我收到此消息
Test suite failed to run TypeError: mongoose.Schema is not a constructor at Object.<anonymous> (../src/dbschema/test.schema.ts:2:43) Where test.schema file is: import * as mongoose from 'mongoose'; export const TestSchema = new mongoose.Schema({ id: { type: Number, required: true, }, }); Can somebody help me?
我带来了更多细节:我将使用nestjs执行e2e测试 框架,这是代码: 从“ supertest”导入请求; 从'@ nestjs / testing'导入{测试}; 从'@ nestjs / common'导入{INestApplication}; 从'../src/game/game.module'导入{GameModule};
describe('Games', () => { let app: INestApplication; beforeAll(async () => { const module = await Test.createTestingModule({ imports: [GameModule], }) .compile(); app = await module.createNestApplication(); await app.init(); }); The TestSchema is used in an other schema which is GameSchema import * as mongoose from 'mongoose'; import { TestSchema } from './test.schema'; export const GameSchema = new mongoose.Schema({ price: { type: PriceSchema, required: true, }, });