我想测试我在 Travis CI 上使用 Express 框架和 MongoDb 创建的其余 api 服务。该测试在我的机器上本地运行,但在 Travis CI 上失败。我猜问题出在我的 .travis.yml 和 package.json 上。
这是我在本地运行测试的方式:
// opens mongodb database on port 27017
mongod
// reads the db and returns documents depending on the request
node express.js
// test CRUD operations on the app
mocha express.test.js
我怎样才能在 travis CI 上做同样的事情?这是我的应用程序https://github.com/mujuni88/Express-RestApi-Tutorial。
travis.yml:
language: node_js
node_js:
- "0.10"
- "0.9"
services: mongodb
script:
- "./node_modules/mocha/bin/mocha *.test.js"
包.json:
{
"name":"express-restapi",
"author":"Joe Buza",
"description":"Express RestApi",
"version": "0.0.1",
"private": true,
"keywords":["angular", "mocha", "mongodb", "express"],
"license":"BSD",
"dependencies": {
"express":"3.4.4",
"mongoskin":"0.6.0"
},
"devDependencies":{
"mocha":"1.13.0",
"expect.js":"0.2.0",
"superagent":"0.15.7"
},
"scripts":{
"start":"node express.js"
}
}