I have a function that has inner functions, for my unit test, I only want to test the functionality of the inner function, but when I export the function and call the inner function, npm tests returns an error.
In my main.js
mainFunction = () => {
functionToBeTested = () => {
///some code
}
}
module.exports = {mainFunction: mainFunction}
In my test.js
const chai = require("chai");
const assert = require("chai").assert;
const mainFunction = require("./main");
describe ("test", () => {
it("returns results", () => {
let result = mainfunction.functionToBeTested(args);
//equal code
})
})
But when I run Npm Test, it says mainfunction.functionToBeTested is not a function. What am I doing wrong?
Aucun commentaire:
Enregistrer un commentaire