2020年12月20日星期日

How do i write a jest testcase for the following function

Am trying to write JEST testcase for the following function. Could you please someone help?

const fetch = require('node-fetch');    async function fetchFun(endPointurl, options) {    try {      const response = await fetch(endPointurl, options);      if (!response.ok) {        throw response.json();      }      const contentType = response.headers.get('Content-Type');      if (contentType.includes('text/html')) {        return await response.text();      }      return await response.json();    } catch (error) {      throw error;    }  }  export default fetchFun;  
https://stackoverflow.com/questions/65386717/how-do-i-write-a-jest-testcase-for-the-following-function December 21, 2020 at 10:06AM

没有评论:

发表评论