Skip to content

Commit

Permalink
Install "ESLint" import resolver for "Jest"
Browse files Browse the repository at this point in the history
To allow aliased imports in tests with Jest, ESLint must be aware of the
"modulePath" field of the "jest.config.js" file. The installed ESLint
plugin allows to define the path to the config file so ESLint can
resolve used paths in tests.
This is used for test util functions.

Associated epic: GH-38
GH-64
  • Loading branch information
arcticicestudio committed Dec 13, 2018
1 parent 1db3a8c commit db3fdd1
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ module.exports = {
},
settings: {
"import/resolver": {
jest: {
jestConfigFile: resolve(__dirname, "jest.config.js")
},
node: {
/* Resolve Webpack alias imports */
paths: [resolve(__dirname, "src"), resolve(__dirname, "src/components")]
Expand Down
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ module.exports = {
"^data(.*)$": "<rootDir>/src/data$1",
"^layouts(.*)$": "<rootDir>/src/components/layouts$1",
"^molecules(.*)$": "<rootDir>/src/components/molecules$1",
"^nord-docs-test-utils(.*)$": "<rootDir>/test/__utils__$1",
"^organisms(.*)$": "<rootDir>/src/components/organisms$1",
"^pages(.*)$": "<rootDir>/src/pages$1",
"^stores(.*)$": "<rootDir>/src/stores$1",
Expand Down
17 changes: 17 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"del-cli": "1.1.0",
"eslint": "5.9.0",
"eslint-config-arcticicestudio": ">=0.4.0 <1.0.0",
"eslint-import-resolver-jest": "2.1.1",
"eslint-plugin-babel": "5.3.0",
"eslint-plugin-import": "2.14.0",
"eslint-plugin-jsx-a11y": "6.1.2",
Expand Down

0 comments on commit db3fdd1

Please sign in to comment.