简体   繁体   中英

React Jest Unit Testing await in private function uncovered line

I call a async function in useEffect

 const [documents, setDocuments] = useState(Array());

  async function findDocuments() {
    const res = await findDocumentList([], {});
    setDocuments(res.data);
  }

  useEffect(() => {
    findDocuments();
  }, []);

I'm seeing state not covered issue in my coverage report.

在此处输入图像描述

How can I fix this issue?

Thanks in advance

The coverage report needs every async function to have an await on it: await findDocuments()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM