我是SinonJs的初学者,当我尝试编写一些演示代码时,它无法工作,我不知道为什么。
app.js const db = require('./db');
module.exports.signUpUser = (user) => {
db.saveUser(user.email, user.password);
}
Run Code Online (Sandbox Code Playgroud)
app.test.js
const sinon = require('sinon');
// without any other codes, it will throw Error: Cannot find module '@sinonjs/referee-sinon'
Run Code Online (Sandbox Code Playgroud)
我使用 mocha 来运行测试。
包.json
{
"name": "sinon-test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "mocha **/*.test.js"
},
"author": "",
"license": "ISC",
"devDependencies": {
"mocha": "^5.2.0",
"sinon": "^7.2.3"
}
}
Run Code Online (Sandbox Code Playgroud) sinon ×1