При запуске npm test
появляется следующая ошибка js, как только мой тест попадает на ферментный метод:
Auto Suggest Component › encountered a declaration exception
Использование React started kit
в качестве шаблона.Вот мои настройки:
setupTests.js
import Enzyme from 'enzyme';
import EnzymeAdapter from 'enzyme-adapter-react-15.4';
// This sets up the adapter to be used by Enzyme
Enzyme.configure({ adapter: new EnzymeAdapter() });
jest.config.js
module.exports = {
automock: false, // [boolean]
browser: false, // [boolean]
bail: false, // [boolean]
collectCoverageFrom: [
'src/**/*.{js,jsx}',
'!**/node_modules/**',
'!**/vendor/**',
],
coverageDirectory: '<rootDir>/coverage', // [string]
globals: {
__DEV__: true,
},
moduleFileExtensions: ['js', 'json', 'jsx', 'node'],
moduleNameMapper: {
'\\.(css|less|styl|scss|sass|sss)$': 'identity-obj-proxy',
},
setupTestFrameworkScriptFile: '<rootDir>/src/setupTests.js',
transform: {
'\\.(js|jsx|mjs)$': '<rootDir>/node_modules/babel-jest',
'^(?!.*\\.(js|jsx|json|css|less|styl|scss|sass|sss)$)':
'<rootDir>/tools/lib/fileTransformer.js',
},
verbose: true, // [boolean]
};
package.json
{
"private": true,
"engines": {
"node": ">=6.13.1",
"npm": ">=3.10.10"
},
"dependencies": {
"@babel/polyfill": "7.0.0",
"@rematch/core": "0.6.0",
"@rematch/select": "0.3.0",
"ajv": "5.0.3-beta.0",
"bluebird": "3.4.6",
"body-parser": "1.18.3",
"classnames": "2.2.6",
"cookie-parser": "1.4.3",
"core-js": "2.4.1",
"del": "2.2.2",
"enumify": "1.0.4",
"enzyme-adapter-react-15.4": "^1.3.0",
"express": "4.16.3",
"foundation-sites": "6.2.3",
"google-maps-react": "1.0.19",
"history": "3.0.0",
"immutable": "3.8.1",
"io-ts": "^1.8.2",
"isomorphic-style-loader": "4.0.0",
"jsrsasign": "6.2.0",
"lodash": "4.17.11",
"material-ui": "0.19.3",
"moment": "2.17.1",
"moment-timezone": "0.5.13",
"ncp": "2.0.0",
"node-fetch": "2.2.0",
"node-localstorage": "1.3.0",
"normalize.css": "8.0.0",
"numeral": "2.0.4",
"pretty-error": "2.1.1",
"prop-types": "15.6.1",
"query-string": "6.1.0",
"rc-slider": "7.0.8",
"react": "15.3.1",
"react-autosuggest": "9.4.2",
"react-content-loader": "3.1.2",
"react-date-picker": "6.6.1",
"react-dom": "15.3.1",
"react-ga": "2.2.0",
"react-modal": "1.9.4",
"react-onclickoutside": "6.7.1",
"react-redux": "4.4.5",
"react-split-pane": "0.1.65",
"react-toastify": "1.7.0",
"reactable": "0.14.1",
"recursive-json-key-transform": "0.2.0",
"redux": "3.6.0",
"redux-auth-wrapper": "0.8.0",
"redux-thunk": "2.1.0",
"serialize-javascript": "1.5.0",
"source-map-loader": "0.1.5",
"source-map-support": "0.5.9",
"universal-router": "6.0.0",
"uuid": "3.2.1",
"whatwg-fetch": "3.0.0",
"write-file-atomic": "1.2.0",
"xmlhttprequest-ssl": "1.5.5"
},
"devDependencies": {
"@babel/core": "^7.0.0",
"@babel/node": "^7.0.0",
"@babel/plugin-proposal-class-properties": "^7.3.4",
"@babel/plugin-proposal-decorators": "^7.2.0",
"@babel/plugin-proposal-export-default-from": "^7.2.0",
"@babel/plugin-proposal-export-namespace-from": "^7.2.0",
"@babel/plugin-proposal-object-rest-spread": "^7.3.4",
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
"@babel/plugin-transform-react-constant-elements": "^7.0.0",
"@babel/plugin-transform-react-inline-elements": "^7.0.0",
"@babel/preset-env": "^7.3.4",
"@babel/preset-react": "^7.0.0",
"@babel/preset-stage-2": "^7.0.0-beta.51",
"@babel/preset-typescript": "^7.3.3",
"@types/react": "^16.8.6",
"autoprefixer": "^9.1.5",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^9.0.0",
"babel-jest": "^23.6.0",
"babel-loader": "^8.0.0",
"babel-plugin-transform-decorators": "^7.0.0-beta.3",
"babel-plugin-transform-decorators-legacy": "^1.3.5",
"babel-plugin-transform-react-remove-prop-types": "^0.4.18",
"babel-preset-react": "^6.24.1",
"browser-sync": "^2.24.7",
"chai": "^3.5.0",
"chokidar": "^2.0.4",
"css-loader": "^0.28.11",
"del": "^2.2.2",
"enzyme": "^3.9.0",
"eslint": "^5.6.0",
"eslint-config-airbnb": "^17.1.0",
"eslint-config-prettier": "^3.0.1",
"eslint-import-resolver-node": "^0.3.2",
"eslint-loader": "^2.1.1",
"eslint-plugin-css-modules": "^2.9.1",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jsx-a11y": "^6.1.1",
"eslint-plugin-prettier": "^2.6.2",
"eslint-plugin-react": "^7.11.1",
"extend": "^3.0.0",
"faker": "^4.1.0",
"file-loader": "^2.0.0",
"front-matter": "^2.3.0",
"gaze": "^1.1.1",
"git-repository": "^0.1.4",
"glob": "^7.1.3",
"identity-obj-proxy": "^3.0.0",
"isomorphic-style-loader": "4.0.0",
"jest": "^23.6.0",
"jest-enzyme": "^7.0.2",
"json-loader": "^0.5.4",
"lint-staged": "^7.3.0",
"markdown-it": "^8.4.2",
"mkdirp": "^0.5.1",
"mocha": "^3.0.2",
"node-sass": "^4.10.0",
"null-loader": "^0.1.1",
"opn-cli": "^3.1.0",
"pixrem": "^4.0.1",
"pleeease-filters": "^4.0.0",
"postcss": "^7.0.2",
"postcss-calc": "^6.0.1",
"postcss-color-function": "^4.0.1",
"postcss-custom-media": "^7.0.3",
"postcss-custom-properties": "^8.0.5",
"postcss-custom-selectors": "^5.1.2",
"postcss-flexbugs-fixes": "^4.1.0",
"postcss-import": "^12.0.0",
"postcss-loader": "^3.0.0",
"postcss-media-minmax": "^4.0.0",
"postcss-nested": "^4.1.0",
"postcss-nesting": "^7.0.0",
"postcss-pseudoelements": "^5.0.0",
"postcss-selector-matches": "^4.0.0",
"postcss-selector-not": "^4.0.0",
"prettier": "^1.14.3",
"raw-loader": "^0.5.1",
"react-addons-test-utils": "15.3.1",
"react-deep-force-update": "^2.1.3",
"react-dev-utils": "^5.0.2",
"react-error-overlay": "^4.0.1",
"react-test-renderer": "^15.6.2",
"redbox-react": "^1.3.0",
"rimraf": "^2.6.2",
"sass-loader": "^7.1.0",
"sinon": "^2.0.0-pre.2",
"stylelint": "^9.5.0",
"stylelint-config-standard": "^18.2.0",
"stylelint-order": "^1.0.0",
"svg-url-loader": "^2.3.2",
"url-loader": "^1.1.1",
"webpack": "4.25.1",
"webpack-assets-manifest": "^3.0.2",
"webpack-bundle-analyzer": "^3.0.2",
"webpack-dev-middleware": "^3.3.0",
"webpack-hot-middleware": "^2.24.2",
"webpack-node-externals": "^1.7.2"
},
"scripts": {
"lint-js": "eslint --ignore-path .gitignore --ignore-pattern \"!**/.*\" .",
"lint-css": "stylelint \"src/**/*.{css,less,styl,scss,sass,sss}\"",
"lint": "yarn run lint-js && yarn run lint-css",
"fix-js": "yarn run lint-js --fix",
"fix-css": "yarn run lint-css --fix",
"fix": "yarn run fix-js && yarn run fix-css",
"test": "jest",
"test-watch": "yarn run test --watch --notify",
"test-cover": "yarn run test --coverage",
"coverage": "yarn run test-cover && opn coverage/lcov-report/index.html",
"clean": "babel-node tools/run clean",
"copy": "babel-node tools/run copy",
"bundle": "babel-node tools/run bundle",
"build": "babel-node tools/run build",
"build-stats": "yarn run build --release --analyse",
"deploy": "babel-node tools/run deploy",
"render": "babel-node tools/run render",
"serve": "babel-node tools/run runServer",
"start": "babel-node tools/run start"
}
}
AutoSuggest.test.js
import React from 'react';
import { shallow, mount, render } from 'enzyme';
import AutoSuggest from './AutoSuggest';
describe('Auto Suggest Component', () => {
const component = shallow(<AutoSuggest />);
it('should render without throwing an error', () => {
console.log(component);
});
});
Заранее спасибо