Module doesn't load correctly when run through Karma in environments that aren't browsers. Window variable is not defined.
Astridax opened this issue · 1 comments
Astridax commented
The global window variable doesn't necessarily exist in all environments, for example Nativescript where Karma runs tests in a non-browser environment.
Offending code:
if (typeof module !== 'undefined' && module.exports) {
module.exports = setup;
} else if (window.sinon) {
setup(window.sinon);
}
Proposed change
if (typeof module !== 'undefined' && module.exports) {
module.exports = setup;
} else if (typeof window !== 'undefined') {
if(typeof window.sinon !== 'undefined') setup(window.sinon);
} else {
if(typeof this.sinon !== 'undefined') setup(this.sinon);
}
I have implemented a code fix that I will submit as a pull request soon.
a-b-r-o-w-n commented
Sounds good. Look forward to the PR.