In my main app, I am bringing in the node package "ibm_db" using: import * as ibmdb from "ibm_db";
In my unit tests I want to be able to override this, then I: import * as ibmdb from "ibm_db";
in my unit test and then:
beforeEach(() => {
ibmdb.open = jasmine.createSpy("open");
});
I get error:
Cannot assign to 'open' because it is a readOnly property.
I need to know with typescript (being compiled into js using tsc, then tested using jasmine command), the right way to mock these functions so I can tell if there being called, I don't want the calls to actually fire.
For ES6 imports use:
import * as name from "library_name"
and in the unit tests use:
const name = require("library_name");
Requires will let you overwrite parts of the library where imports will not
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.