반응형
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 |
Tags
- 백준 #적록색약
- react fragment
- axios
- 코드스테이츠 #알고리즘 #그리디
- 버블링 #갭쳐링 #이벤트 #JS
- 다익스트라 #파티 #백준
- rate limit
- react #useCallback #react Hook
- html entities
- 이친수
- RateLimit
- react
- JWT #토큰 #refreshToken #accessToken #Token #token #localStorage #sessionStorage
- 플로이드 #c++
- DP #c++
- npm #not being able to find a file #npm install Error
- React-Query
- useState #Hooks
- interceptors
- #useRef #언제 쓰는데?
- 빡킹독
- React #controlled component #비제어 컴포넌트 #제어 컴포넌트
- 백준 #직각삼각형
- raect typescript #react #typescript #styled-component
- React #Hook rules #Hook 규칙
- React #리액트 이벤트 주기 #리액트 이벤트
- 노마드 코더 #타입스크립트 #typescript #class
- donwstream #upstream #origin
- 얕은 복사 #깊은 복사 #shallow copy #deep copy
- React #effect hook #useEffect
Archives
- Today
- Total
꿈꾸는 개발자
우테코-5기 2주차 과제-사전 학습 내용 정리! 본문
- Jest:
- 페이스북에서 만든 테스팅 라이브러리이다
- Jest의 용법과 관련된 추가적인 자료
Jest로 기본적인 테스트 작성하기
Engineering Blog by Dale Seo
www.daleseo.com
- 위 블로그에 따르면, npm을 통해 jest를 설치한 이후 밑과 같이 test 스크립트를 수정해줘야 한다!
"scripts": {
"test": "jest"
},
- 그 후 test.js(파일명은 자유롭게)을 생성하고 밑과 같은 방식으로 코드를 작성한 후 터미널에 npm test를 실행하면 테스트 실행 및 퉁과 문구가 나올 것이다!
test("1 is 1", () => {
expect(1).toBe(1);
});
- 기본적인 테스트 작성법:
test("테스트 설명", () => {
expect("검증 대상").toXxx("기대 결과");
});
- toXxx는 Test match라고 불리며, toBe 외에도 여러 종류가 존재하니 추가적 검색을 통해 필요에 따라 사용하면 된다!
- npm test를 실행하면 기본적으로 __test__디렉토리 내부에 있는 모든 파일들을 다 테스트 파일로 인식하여 실행하게 된다. 특정 파일만을 실행할 경우 npm test <파일명이나 경로>로 지정하면 된다
- 과제에서 제공한 학습용 StringTest.js:
describe("문자열 테스트", () => {
test("split 메서드로 주어진 값을 구분", () => {
const input = "1,2";
const result = input.split(",");
expect(result).toContain("2", "1");
expect(result).toContainEqual("1", "2");
});
test("split 메서드로 구분자가 포함되지 않은 경우 값을 그대로 반환", () => {
const input = "1";
const result = input.split(",");
expect(result).toContain("1");
});
test("substring 메서드로 특정 구간 값을 반환", () => {
const input = "(1,2)";
const result = input.substring(1, 4);
expect(result).toEqual("1,2");
});
test("repeat 메서드로 문자열을 여러번 반복", () => {
const input = "abc";
const result = input.repeat(3);
expect(result).toEqual("abcabcabc");
});
test("repeat 메서드에 음수 값을 넣었을 때 예외 발생", () => {
const input = "abc";
const result = () => input.repeat(-1);
expect(result).toThrow(RangeError);
});
});
- JS 코딩 컨벤션 Airbnb의 한국어 버전 (가장 유명하고 많이들 참고하고 있는 컨벤션으로 알고 있다!) 코드를 작성하기 전 참고하며, 기존의 안 좋은 습관들을 개선해 나가면 좋을 것!
https://github.com/ParkSB/javascript-style-guide
GitHub - parksb/javascript-style-guide: Airbnb JavaScript 스타일 가이드
Airbnb JavaScript 스타일 가이드. Contribute to parksb/javascript-style-guide development by creating an account on GitHub.
github.com
- MissionUtils library의 활용
- 이번 과제는 해당 라이브러리에서 제공하는 random 및 console API를 사용해야 한다는 조건이 추가돼 있다!
- Random값의 추출은Random.pickNumberInRange() 을 활용해야 한다!
- 사용자의 값을 입력 받고 출력하기 위해서는 Console.readLine, Console.print를 활용한다.
- 해당 라이브러리를 다운 받을 수 있는 방법은 총 2가지로 나뉜다!
- CDN
-
- 스크립트 삽입하기
-
- CDN
<script src="https://cdn.jsdelivr.net/npm/@woowacourse/mission-utils@1.0.1/dist/mission-utils.min.js"></script>
<script type="module" src="index.js"></script>
- CDN의 장점:
- Files may be pre-cached
- Reduce the bandwidth
- NPM의 장점:
- module bundler의 dependencies를 관리하는 데 중요한 역할을 담당한다!
- 코드의 간결함을 유지해준다(script형식으로 index.html에 link할 필요가 없기 때문에!
참고사항: https://stackoverflow.com/questions/43605215/using-cdn-vs-installing-library-by-npm
Using CDN vs Installing library by NPM
I recently started using NPM, but I don't understand how the files in node_modules are added to my index.html. Case 1: CDN For example, if I want to use jQuery via CDN, it is so simple! I add the CDN
stackoverflow.com
- 적용: 해당 과제의 경우 가독성이 우려될 만큼, 복잡한 코드를 작성하는 것이 아니기 때문에 npm방식이 아닌, CDN방식으로 라이브러리를 index.html에 link해 사용할 예정이다!
- commit message convention: