I'm currently working on unit testing my code, but I've encountered an issue with a library that my code relies on. The library, named setup
, is not directly accessible during compile time. However, it will be available when the code is executed. It's important to note that I am not using webpack or any similar tool, only TS node.
Production code:
declare let setup: any;
setup.rest = (): void => { // this signature cannot be altered
}
Test code:
import "jasmine";
describe("App", () => {
beforeEach(() => {
setup = {};
})
it("should have a rest function", () => {
setup.rest();
});
});
My test environment is powered by Jasmine as a test runner. However, upon running the tests, I encounter the following error:
ReferenceError: setup is not defined
I need assistance in finding a way to initialize the setup
variable and make it accessible to both my test and production code. How can I achieve this?