Search code examples
javascriptreactjsjestjsreact-testing-libraryistanbul

Istanbul ignore next not working inside JSX and nested arrays


I'm trying to use instanbul ignore next to ignore some lines in my test coverage but it dont work inside a JSX or nested array. Anyone have an idea of what I can do?

          <Text
            as="span" /* istanbul ignore next */ - IT WONT WORK HERE
            variant={isMobile ? 'medParagraph' : 'smParagraph'} //im trying to ignore this line
            sx={{
              fontWeight: selected ? 'bold' : undefined,
            }}>
            {page}
          </Text>

  const itemList = [
    ...(siblingsEnd < count - boundaryCount - 1
      ? ['end-ellipsis']
      : count - boundaryCount > boundaryCount
      ? [count - boundaryCount]
      : []),
    /* istanbul ignore next */ - WONT WORK HERE AS WELL
    ...endPages, //im trying to ignore this line
    ...(hideNextButton ? [] : ['next']),
    ...(showLastButton ? ['last'] : []),
  ];

Solution

  • I was able to ignore the nested array placing the istanbul above the const definition.

    Same with the JSX, I just placed the istanbul above the return.