Unit Test Error - JavaScript
I am using the Teams for Classroom, and am excited to implement unit tests to dramatically cut down on time spent grading. The unit tests work fine for Java and Python, but I am getting errors saying my functions aren't defined when unit testing in JS. Here is a link to an example Repl: https://replit.com/join/byanefur-dcalmeyer. Any help would be greatly appreciated.
Voters
Coder100 (16898)
Make sure you export the functions, like this:
function add(a, b) {
return a+b;
}
module.exports = { add };
and here is a working test script:
const { add } = require(".");
expect(add(1, 2)).toBe(3);
Perfect, thanks!!