我正试图将打字稿引入我的react应用程序中,并努力使ts-jest正常工作。由于某种原因,当我使用ts-jest设置运行测试时,快照中的所有组件名称都消失了。我只将一个文件转换为打字稿,并且所有测试仍在javascript中。
这是我目前的笑话设置:
"jest": {
"moduleDirectories": [
"node_modules",
"<rootDir>/app/javascript"
],
"setupTestFrameworkScriptFile": "<rootDir>/config/jest/setupTest.js",
"setupFiles": [
"<rootDir>/config/jest/testShim.js",
"<rootDir>/config/jest/testSetup.js",
"jest-localstorage-mock"
],
"snapshotSerializers": [
"enzyme-to-json/serializer"
],
"roots": [
"<rootDir>/app/javascript"
],
"transform": {
"^.+\\.(js|jsx)?$": "babel-jest",
"^.+\\.(ts|tsx)?$": "ts-jest"
},
"moduleFileExtensions": [
"js",
"jsx",
"ts",
"tsx",
"json"
],
"testRegex": "((\\.|/)test)\\.(js|jsx|ts|tsx)$"
}