jeudi 1 juin 2017

module.exports multiple functions in Jest testing

After reading the Jest documentation, when it's mentioned that to export a single function from a tested file they show the following example:

function sum(a, b) {
  return a + b;
}
module.exports = sum;

Now, if I have multiple specific functions I want to export on my tested file, like this:

function sum(a, b) {
  return a + b;
}
function multiply(a, b) {
  return a * b;
}
function subtract(a, b) {
  return a - b;
}
module.exports = sum;
module.exports = multiply;

The multiply function is the only one being exported. How can I make these function be exported? Or only part of my file?

Aucun commentaire:

Enregistrer un commentaire