#reactjs #typescript #ecmascript-6 #jestjs #electron
Вопрос:
Это, вероятно, связано с тем, что оператор распространения не рассматривается или проблема стиля, в которой я все еще не уверен.
Конфигурация Вавилона выглядит следующим образом:
{
"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 config:
"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",
Проследил за этой нитью, но все равно не повезло:
https://github.com/facebook/jest/issues/7308Каково фактическое решение этой проблемы?
Ответ №1:
Должно быть {{...style}}
или еще лучше {style}