このエラーをどこで探すか不明です。Jest test fail:SyntaxError:予期しないトークン<
ReactでTypescriptを使用し、ユニットテストにJestとEnzymeを使用する。
Package.jsonサンプル:
でNPMのテスト結果を実行"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"
]
}
:
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 <
編集:私は、静的.svg
ファイルをロードするためにrequire
を使用する最初の場所に起こっているように見えます。なぜそれを処理できないのですか? requireを使用しているときにこのエラーをスローすることを無視する方法はありますか?
は 'xml'タグを削除してくださいとだけsvg'タグ'次のものが含ま –