In the following scenario, I would like my test to fail. If I write a test, and the test passes, then someone adds a function call to the code, without updating the test:
//todo.js
function todo(){
createTodo();
}
//todo.spec.js
describe("should create todo", ()=>{
jest.mock("createTodo", ()=> {});
todo();
expect(createTodo.toHaveBeenCalledTimes(1));
});
Now if someone comes along and adds deleteTodo(), I'd like the test to fail:
//todo.js
function todo(){
createTodo();
deleteTodo();
}
// no change to todo.spec.js
How could this be accomplished?
Aucun commentaire:
Enregistrer un commentaire