Is there a way to mock a constant used in a function for unit testing without updating the test result every time the constant is updated? I'm hoping to avoid creating a new function that returns the constant.
utils.js
const data = [1, 2, 3]
const functionToTest = () => {
if (data.includes(2)) {
return true
}
return false
}
test.js
describe('testing functionToTest', () => {
const dataReplacement = [3, 4, 5]
tellFunctionToTest('hey, use dataReplacement instead of data')
})
If possible, I'd like to avoid passing data as a parameter. Thanks for any assistance!