抑制:Jest 遇到来自 React Typescript 的意外标记
Suppress: Jest encountered an unexpected token from React Typescript
这可能是由于未考虑传播运算符或我仍然不确定的样式问题。
Babel配置如下:
{
"presets": ["@babel/preset-env", "@babel/preset-react"],
"plugins": [
["@babel/plugin-proposal-decorators", { "legacy": true }],
["@babel/plugin-proposal-class-properties", { "loose": true }],
["transform-object-rest-spread", { "useBuiltIns": true }]
]
}
开玩笑 配置:
"jest": {
"verbose": true,
"collectCoverage": true,
"runner": "@jest-runner/electron",
"testEnvironment": "@jest-runner/electron/environment",
"moduleNameMapper": {
"\.(jpg|jpeg|png|gif|svg|yaml)$": "<rootDir>/__mocks__/fileMock.js",
"\.(css|less|scss)$": "<rootDir>/__mocks__/styleMock.js"
},
"modulePaths": [
"<rootDir>/src/",
"node_modules"
]
},
依赖关系:
"@babel/core": "^7.1.6",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
"@babel/plugin-transform-object-assign": "^7.0.0",
"@babel/plugin-transform-react-jsx": "^7.1.6",
"babel-loader": "8.0.4",
"@ant-design/icons": "4.5.0",
"@babel/plugin-proposal-decorators": "7.13.5",
"@babel/preset-env": "7.13.12",
"@babel/preset-es2015": "^7.0.0-beta.53",
"@babel/preset-react": "7.12.13",
"@babel/preset-stage-0": "^7.8.3",
"@babel/preset-typescript": "7.13.0",
"@jest-runner/electron": "3.0.0",
"@testing-library/dom": "7.28.1",
"@testing-library/jest-dom": "5.11.6",
"@testing-library/react": "11.0.4",
"@types/jest": "26.0.15",
"@types/lodash": "4.14.108",
"@types/node": "12.0.0",
"@types/react": "16.9.35",
"@types/react-grid-layout": "1.1.1",
"@typescript-eslint/eslint-plugin": "4.0.1",
"@typescript-eslint/parser": "4.0.1",
"babel-plugin-const-enum": "1.0.1",
"babel-plugin-transform-class-properties": "6.24.1",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-es2015": "^6.24.1",
"css-loader": "5.0.1",
"dva": "2.4.1",
"dva-loading": "3.0.14",
"electron": "11.0.3",
"eslint": "7.22.0",
"eslint-config-prettier": "6.15.0",
"eslint-plugin-deprecation": "1.1.0",
"eslint-plugin-import": "2.22.1",
"eslint-plugin-prettier": "3.1.4",
"eslint-plugin-react": "7.22.0",
"eslint-plugin-react-hooks": "4.2.0",
Followed this thread, but still no luck:
https://github.com/facebook/jest/issues/7308
What is the actual fix for this?
应该是 {{...style}}
或更好 {style}
这可能是由于未考虑传播运算符或我仍然不确定的样式问题。
Babel配置如下:
{
"presets": ["@babel/preset-env", "@babel/preset-react"],
"plugins": [
["@babel/plugin-proposal-decorators", { "legacy": true }],
["@babel/plugin-proposal-class-properties", { "loose": true }],
["transform-object-rest-spread", { "useBuiltIns": true }]
]
}
开玩笑 配置:
"jest": {
"verbose": true,
"collectCoverage": true,
"runner": "@jest-runner/electron",
"testEnvironment": "@jest-runner/electron/environment",
"moduleNameMapper": {
"\.(jpg|jpeg|png|gif|svg|yaml)$": "<rootDir>/__mocks__/fileMock.js",
"\.(css|less|scss)$": "<rootDir>/__mocks__/styleMock.js"
},
"modulePaths": [
"<rootDir>/src/",
"node_modules"
]
},
依赖关系:
"@babel/core": "^7.1.6",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
"@babel/plugin-transform-object-assign": "^7.0.0",
"@babel/plugin-transform-react-jsx": "^7.1.6",
"babel-loader": "8.0.4",
"@ant-design/icons": "4.5.0",
"@babel/plugin-proposal-decorators": "7.13.5",
"@babel/preset-env": "7.13.12",
"@babel/preset-es2015": "^7.0.0-beta.53",
"@babel/preset-react": "7.12.13",
"@babel/preset-stage-0": "^7.8.3",
"@babel/preset-typescript": "7.13.0",
"@jest-runner/electron": "3.0.0",
"@testing-library/dom": "7.28.1",
"@testing-library/jest-dom": "5.11.6",
"@testing-library/react": "11.0.4",
"@types/jest": "26.0.15",
"@types/lodash": "4.14.108",
"@types/node": "12.0.0",
"@types/react": "16.9.35",
"@types/react-grid-layout": "1.1.1",
"@typescript-eslint/eslint-plugin": "4.0.1",
"@typescript-eslint/parser": "4.0.1",
"babel-plugin-const-enum": "1.0.1",
"babel-plugin-transform-class-properties": "6.24.1",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-es2015": "^6.24.1",
"css-loader": "5.0.1",
"dva": "2.4.1",
"dva-loading": "3.0.14",
"electron": "11.0.3",
"eslint": "7.22.0",
"eslint-config-prettier": "6.15.0",
"eslint-plugin-deprecation": "1.1.0",
"eslint-plugin-import": "2.22.1",
"eslint-plugin-prettier": "3.1.4",
"eslint-plugin-react": "7.22.0",
"eslint-plugin-react-hooks": "4.2.0",
Followed this thread, but still no luck: https://github.com/facebook/jest/issues/7308
What is the actual fix for this?
应该是 {{...style}}
或更好 {style}