I am struggling to mock rxjs
functions using sinon
. Usually I import a library as an object and mock the function I need;
// example.test.ts
import * as Rxjs from "rxjs";
import { stub } from "sinon";
import { equal } from "assert";
import { example } from "./example";
const throwErrorStub = stub(Rxjs, "throwError");
example();
equal(throwErrorStub.called, true); // fails
// example.ts
import { throwError } from "rxjs";
const export example = () => {
throwError(() => new Error("Test"));
}
All other object / library mocks work within the test – just none of the rxjs
functions.