小编vec*_*vec的帖子

如何在 beforeAll() 中调用 DB 连接并在 afterAll() 中关闭 DB 连接

我是 Jest 和 TypeORM 的新手,想使用 typeorm 和 Jest 开发数据库验证框架。如何在 beforeAll() 中调用三个数据库连接实例。

这是一个使用 TypeORM 和 Jest 进行数据库验证的新框架,Ormconfig.json 包含三个数据库的详细信息,并有一个用于数据库连接的 .ts 类和一个测试类。

ormconfig.json

[{
  "name": "default",
  "type": "mysql",
  "host": "127.0.01",
  "port": 3306,
  "username": "sdf",
  "password": "uuehfldjskh",
  "database": "ifsdjh",
  "synchronize": true,
  "logging": false,
  "entities": [
    "src/entity/**/*.ts"
  ],
  "migrations": [
    "src/migration/**/*.ts"
  ],
  "subscribers": [
    "src/subscriber/**/*.ts"
  ],
  "cli": {
    "entitiesDir": "src/entity",
    "migrationsDir": "src/migration",
    "subscribersDir": "src/subscriber"
  }
},
  {
    "name": "hello",
    "type": "mysql",
    "host": "127.0.01",
    "port": 3306,
    "username": "weqwe",
    "password": "das",
    "database": "dsfds",
    "synchronize": true,
    "logging": false, …
Run Code Online (Sandbox Code Playgroud)

jestjs typeorm

6
推荐指数
1
解决办法
1779
查看次数

标签 统计

jestjs ×1

typeorm ×1