CI +测试:对DB运行单元测试

时间:2017-06-17 21:25:55

标签: node.js mongodb continuous-integration circleci

对CI(circleCI)上的mongo DB执行测试失败,即使它们在本地传递。

安装mongo db并将应用程序连接到db,这是我的circle.yml文件

machine:
  node:
    version: 7.2.1 
dependencies:
  override:
    - sudo apt-get purge mongodb-org*
    - sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
    - echo "deb http://repo.mongodb.org/apt/ubuntu precise/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
    - sudo apt-get update
    - sudo apt-get install -y mongodb-org
    - sudo service mongod restart
    - npm install
test:
  override:
    - npm run test

数据库网址:mongodb://mongodb:27017/db-name

1 个答案:

答案 0 :(得分:0)

CircleCI默认提供了MongoDB 3.0.7

为此编辑你的circle.yml:

machine:
  node:
    version: 7.2.1 
dependencies:
  override:
    - npm install
test:
  override:
    - npm run test

More information