일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 러스트기초
- 티스토리챌린지
- vue기초
- ethers websocket
- ethers v6
- git rebase
- 계정추상화
- 머신러닝기초
- ethers typescript
- 스마트컨트렉트 예약어 함수이름 중복
- 러스트 기초
- 컨트렉트 동일한 함수이름 호출
- ethers type
- ambiguous function description
- redux toolkit 설명
- Vue
- erc4337 contract
- SBT표준
- rust 기초
- 오블완
- 스마트 컨트렉트 함수이름 중복
- 러스트 기초 학습
- 체인의정석
- Vue.js
- cloud hsm
- 스마트컨트렉트 함수이름 중복 호출
- redux 기초
- cloud hsm 서명
- cloud hsm 사용하기
- erc4337
Archives
- Today
- Total
체인의정석
Jest + TypeScript 절대 경로 설정 하는 법 본문
728x90
TypeScript 모듈을 만든 후
jest로 테스트 코드를 작성할때 계속해서 에러가 발생.
module의 위치를 알 수 없는 에러가 발생.
https://kulshekhar.github.io/ts-jest/docs/getting-started/paths-mapping/
Paths mapping | ts-jest
If you use "baseUrl" and "paths" options in your tsconfig file, you should make sure the "moduleNameMapper" option in your Jest config is setup accordingly.
kulshekhar.github.io
다음과 같이 jest.confi.js에서 moudule name Mapper를 사용해여야지만 절대 경로를 jest에서 읽어와서 테스트 할 수 있다.
또한 jest 와 ts-jest의 버전이 맞지 않을 경우에도 에러가 났었다. 에러가 있는 버전에서 업데이트를 통해 해결하고 config에서 설정을 해주어서 해결을 할 수 있었다.
jest.config.js
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
moduleNameMapper: {
'^@lib/(.*)$': '<rootDir>/lib/$1',
},
};
tsconfig.ts
{
"compilerOptions": {
"resolveJsonModule": true,
"esModuleInterop": true,
"module": "commonjs",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es2017",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./",
"incremental": true,
"paths" : {
"@lib/*": ["./lib/*"],
"@test/*": ["./test/*"]
}
},
"include": ["lib", "test", "test/**/**.ts"],
"exclude": ["node_modules", "dist"]
}
728x90
반응형
'개발' 카테고리의 다른 글
타입스크립트 정규 표현식 검사 (삭제된 코드 백업) (0) | 2021.07.09 |
---|---|
Regular Expression(RegExp)사용하기 Typescript (0) | 2021.07.07 |
자바스크립트와 전략패턴 (0) | 2021.06.28 |
node.js, json 형태로 요청하기 (0) | 2021.03.17 |
fetch 사용 (0) | 2021.02.22 |
Comments