이 오류를 찾을 위치를 모릅니다.Jest test fail : SyntaxError : 예기치 않은 토큰 <
React와 함께 Typescript를 사용하고 단위 테스트를 위해 Jest와 Enzyme을 사용합니다.
Package.json 샘플 :
FAIL src/components/Component.test.tsx
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){<?xml version="1.0" encoding="UTF-8"?>
^
SyntaxError: Unexpected token <
편집 :에
"scripts": {
"start": "node server.js",
"bundle": "cross-env NODE_ENV=production webpack -p",
"test": "jest"
},
"jest": {
"transform": {
"^.+\\.tsx?$": "<rootDir>/node_modules/ts-jest/preprocessor.js"
},
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"json"
]
}
실행 NPM 테스트 결과 나타나는 내가 정적 .svg
파일을로드 require
을 사용하여 1 위를 발생합니다. 왜 그걸 처리 할 수 없습니까? require를 사용할 때이 오류가 발생하는 것을 무시하는 방법이 있습니까?
는'제거 xml' 태그 시도 만 다음'svg' 태그를 포함 –