본문 바로가기
boostcamp-challenge

[jest] javascript es6+ npm test 와 node를 같이 쓰기

by blopz 2024. 8. 2.

jest 설치

 

> npm i -D jest 로 jest를 설치해주고

package.json
  "scripts": {
    "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
  },
  "type" : "module"

 

package.json에 해당 단락을 추가해 jest로 test하도록 한다.

 

여기서  "test": "jest" 를 사용하는 대신 "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js" 를 사용하면  "type" : "module" 을 사용면서 node 명령어와 npm test 명령어가 동시에 먹는다!

 

 

https://blopz.tistory.com/16

 

[7/23] JEST: Test 라이브러리는 이렇게 섹시하구나

라이브러리 정하기Jest 이전에는 자바스크립트 코드를 테스트하라면 여러가지 테스팅 라이브러리를 조합해서 사용하곤 했었다.예를 들어, Mocha나 Jasmin을 Test Runner로 사용하고, Chai나 Expect와 같은

blopz.tistory.com

https://stackoverflow.com/questions/58613492/how-to-resolve-cannot-use-import-statement-outside-a-module-from-jest-when-run

 

How to resolve "Cannot use import statement outside a module" from Jest when running tests?

I have a React application (not using Create React App) built using TypeScript, Jest, Webpack, and Babel. When trying to run yarn jest, I get the following error: I have tried removing all package...

stackoverflow.com

 

처럼 babel을 사용안해도 된다...

'boostcamp-challenge' 카테고리의 다른 글

[Boostcamp-challenge] 3주차 회고  (0) 2024.08.08
[8/7] http req/res  (0) 2024.08.08
[7/31] GIT  (0) 2024.07.31
[7/29] Javascript event 학습중...  (0) 2024.07.29
[Boostcamp-challenge] 2주차 회고  (0) 2024.07.26