I'm writing JS scripts for a program called eSignal (trading platform). The scripts run inside eSignal and utilize the eSignal API.
I am wanting to write tests for my scripts however I am not sure how I can use Jasmine to mock global constants that eSignal provides.
For example:
function myFunction(){
//....
drawShape(Shape.SQUARE)
//....
}
For the drawShape
function, I create a spy for that with drawShapeRelative = jasmine.createSpy()
, however I cannot figure out a way to mock the global constant Shape.SQUARE
. Because eSignal knows about the constant I do not define it anywhere in my code, so Jasmine says that Shape is not defined.
Inside my script I can run code that will only be executed when the test runs, and only be executed when the scrip runs inside eSignal with
if ( typeof module !== 'undefined' && module.hasOwnProperty('exports') ){
// Run with test
}
else{
// Run with eSignal
}
I feel like I am going to have to do something with this.
Aucun commentaire:
Enregistrer un commentaire