我有测试用例,我没有通过,因为我甚至不知道如何显示一个简单的控制台日志的数据从应用程序.下面是测试文件:
// index.spec.js
//...
const DIR_PATH = path.resolve('./');
const dirs = ['/logs', "/" + uuid.v4(), "/tmp/logs"];
//...
it('should create a new directory', done => {
const dirPath = DIR_PATH + dirs[0];
app.createDirectoryIfNotExists(dirPath)
.then((res) => {
return utils.checkDir(dirPath)
})
.then(() => {
done()
})
});
下面是我的测试:
index.js
const createDirectoryIfNotExists = (path) => {
console.log("created dirrrr"+ path) //this not showing anything
if (!fs.existsSync(path)) {
fs.mkdirSync(path, {
recursive: true
});
}
};
下面是包json,它给予了所有依赖项的信息:
"scripts": {
"start": "node index.js",
"prestart": "npm install",
"pretest": "npm install",
"test": "./node_modules/.bin/mocha test"
},
"author": "",
"license": "ISC",
"devDependencies": {
"bluebird": "^3.7.2",
"chai": "^4.2.0",
"mocha": "^7.1.1",
"mocha-junit-reporter": "^1.23.3",
"mocha-multi-reporters": "^1.1.7",
"mock-fs": "^4.11.0",
"rimraf": "^3.0.2",
"uuid": "^7.0.1"
}
}
1条答案
按热度按时间avwztpqn1#
这是因为您没有调试测试。请尝试使用: