-
-
Notifications
You must be signed in to change notification settings - Fork 22
Closed
Description
I tried to use didNotReceive. Below are tests I ran in the repo. In the output, I get Error: Test finished without running any assertions for all these tests. I would like to know whether it simply does not work or I miss something.
import test from "ava";
import { Substitute, Arg } from "../../src/index";
interface Calculator {
add(a: number, b: number): number;
subtract(a: number, b: number): number;
divide(a: number, b: number): number;
isEnabled: boolean;
}
test("check didNotReceive after not mocking and not calling a method", () => {
const calculator = Substitute.for<Calculator>();
// Do not mock and do not call
calculator.didNotReceive().add(Arg.any(), Arg.any());
calculator.didNotReceive().add(1, Arg.any());
calculator.didNotReceive().add(1, 2);
});
test("check didNotReceive after not mocking but calling a method", () => {
const calculator = Substitute.for<Calculator>();
// Do not mock, but call
calculator.add(1, 2);
calculator.didNotReceive().add(Arg.any(), Arg.any());
calculator.didNotReceive().add(1, Arg.any());
calculator.didNotReceive().add(1, 2);
});
test("check didNotReceive after mocking but not calling a method", () => {
const calculator = Substitute.for<Calculator>();
// Mock but do not call
calculator.add(1, 2).returns(3);
calculator.didNotReceive().add(Arg.any(), Arg.any());
calculator.didNotReceive().add(1, Arg.any());
calculator.didNotReceive().add(1, 2);
});
test("check didNotReceive after mocking and calling a method", () => {
const calculator = Substitute.for<Calculator>();
// Mock and call
calculator.add(1, 2).returns(3);
calculator.add(1, 2);
calculator.didNotReceive().add(Arg.any(), Arg.any());
calculator.didNotReceive().add(1, Arg.any());
calculator.didNotReceive().add(1, 2);
});Output:
npm test spec/issues/didNotReceive.test.ts
> @fluffy-spoon/substitute@1.0.0 test /Users/shvgn/dev/FluffySpoon.JavaScript.Testing.Faking
> tsc && ava "spec/issues/didNotReceive.test.ts"
4 tests failed
check didNotReceive after not mocking and not calling a method
Error: Test finished without running any assertions
check didNotReceive after not mocking but calling a method
Error: Test finished without running any assertions
check didNotReceive after mocking but not calling a method
Error: Test finished without running any assertions
check didNotReceive after mocking and calling a method
Error: Test finished without running any assertions
npm ERR! Test failed. See above for more details.
Metadata
Metadata
Assignees
Labels
No labels