I'm new to a project where there is a JavaScript script a3.panel.js
written by someone else. It defines an module like this:
a3.panel = (function () {
let property1 = {},
property2 = $('.checkbox');
function someMethods () {
some logic
};
return ({
some value
});
})();
with Jasmine, how can I test the method inside this module? I tried
describe("panel test", () => {
it("should test", () => {
var panel = a3.panel;
expect(typeof a3.panel.property1).toBe("object");
});
});
and Jasmine returns:
ReferenceError: a3 is not defined
I guess the external library is not loaded for the test.
Can you try this in your Jasmine test (I haven't tried yet)-
document.write('<script src="http://.../a3library.js></script>')
You may provide local path too.
OR
Use jQuery GetScript
And
Check this too - include external Javascript as a source to Jasmine
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.