How could you test a function with Mocha/Chain which is defined as String.prototype.testFunction? For example
Function:
String.prototype.testFunction = (x, y) => {
return this.z + x + y
}
module.export = String.prototype.testFunction
Use of Function:
"Text".testFunction(1, 2)
From previous experience from testing functions it should be as follows:
const app = require("../index.js")
it('description', function(){
var variable = "Test".app.testFunction(" ", "text")
variable.should.equal("Test text")
})
Will this work? Is there a better way to do this?
Thanks
Solved. Added function in separate js file and import the function as a constant in the test file
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.