250x250
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 과제 진행하기
- 테이블 해시 함수
- 통신망분석
- mock date
- 리액트네이티브
- JavaScript
- 구름톤 챌린지
- 프로그래머스
- nextjs
- 중첩 점
- 연결 요소 제거하기
- 리액트네이티브 엔진
- 귤 고르기
- Hermes Engine
- jest
- 호텔 대실
- Jest uuid syntax
- ResizeObserver
- Google 애널리틱스
- 구름톤
- 헤르메스 엔진
- 최솟갑 구하기
- 날짜 테스트
- 자바스크립트
- create-next-app
- 구름톤챌린지
- nextjs-performance
- Leetcode #javascript #알고리즘 #Algorithms #js
- mutationobserver
- 테스트 Date
Archives
- Today
- Total
나만보는개발공부블로그
[Cypress] window.__coverage__ is undefined 본문
Cypress 공식 홈페이지의 test coverage 가이드 라인을 참고하며 따라해도 window.__coverage__가 undefined로 뜨는 현상이 있었다.
그리고 Cypress e2e 테스트를 실행하고 맨 아래에 아래와 같은 경고가 떳다.
⚠️ file xxx/.nyc_output/out.json has no coverage information
Did you forget to instrument your web application? Read https://github.com/cypress-io/code-coverage#instrument-your-application
위의 url을 찾아 들어가보면 instanbul의 babel plugin에 들어가야 한다고 한다.
//.babelrc
{
"plugins": ["istanbul"]
}
그래서 babel-plugin-istanbul을 설치해서 위의 내용과 같이 작성하였는데도 여전히 뜨지 않았다.
//babel.config.js
const shouldInstrumentCode = "INSTRUMENT_CODE" in process.env;
console.log("shouldInstrumentCode", shouldInstrumentCode);
module.exports = {
presets: ["next/babel"],
plugins: shouldInstrumentCode
? ["istanbul"]
: [],
};
console.dir(module.exports, { depth: null });
그래서 정말로 istanbul이 작동하는지 console로 확인하였다.
여러가지의 검색 결과를 통해서 문제를 해결할 수 있엇는데 다음과 같이 해결하였다.
해결방안
istanbul babel plugin option으로 include가 존재하는데 이부분에 필요한 테스트 커버리지 소스들을 포함시키니 window.__coverage__에 내용이 나타났다.
["istanbul",
{
include: ["src/**/*.{ts,tsx,js}", "pages/**/*.{ts,tsx,js}"]
}
],
'Web Development > Front' 카테고리의 다른 글
Multiple children layout in Nextjs (0) | 2022.09.17 |
---|---|
Scroll restoration in Nextjs (0) | 2022.09.17 |
[NextJS] SEO for SVG image file (0) | 2022.06.07 |
[NextJS] nextjs Error: Plugin name should be specified (0) | 2022.06.07 |
[NextJS] create-react-app migration to NextJS (0) | 2022.06.07 |