N
N
Nikolai2020-05-26 15:51:49
JavaScript
Nikolai, 2020-05-26 15:51:49

How to test with JEST functions in react that don't return anything?

Good afternoon! I have a function in which other functions are called, tell me how can I test calling these functions?

Simplified example:

const onSend = (type) => {
   const docs = getDocs(type);
   const sortedDocs = sortDocs(docs);
   const options = getOptions(type, docs);

   if (sortedDocs) {
      send(sorted, options);
  } else {
   sendToServer();
}
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lynn "Coffee Man", 2020-05-26
@wiigusev

Mock functions https://jestjs.io/docs/en/mock-functions

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question