Skip to content

Commit 8e35d94

Browse files
committed
Added lerna-alias dep to automate creating jest aliases
1 parent f402067 commit 8e35d94

5 files changed

Lines changed: 27 additions & 49 deletions

File tree

jest.config.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const lernaAliases = require('lerna-alias')
2+
3+
module.exports = {
4+
transform: {
5+
'\\.css$': '<rootDir>/test/styleTransform.js',
6+
'^.+\\.js?$': 'babel-jest'
7+
},
8+
moduleNameMapper: lernaAliases(),
9+
setupTestFrameworkScriptFile: '<rootDir>/test/testSetup.js',
10+
coveragePathIgnorePatterns: ['<rootDir>/packages/emotion-utils/src/stylis.js']
11+
}

jest.dist.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const lernaAliases = require('lerna-alias')
2+
const baseConfig = require('./jest.config.js')
3+
4+
module.exports = Object.assign({}, baseConfig, {
5+
moduleNameMapper: lernaAliases({ sourceDirectory: false }),
6+
transformIgnorePatterns: ['dist', 'node_modules'],
7+
testPathIgnorePatterns: ['babel-plugin-emotion']
8+
})

jest.dist.json

Lines changed: 0 additions & 26 deletions
This file was deleted.

package.json

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"test": "npm-run-all -p lint:check coverage test:size test:typescript flow && npm run test:prod && npm run benchmark",
1010
"test:typescript": "lerna run test:typescript --parallel",
1111
"coverage": "jest --coverage --no-cache --ci --runInBand",
12-
"test:prod": "npm run build && jest -c jest.dist.json --no-cache --ci --runInBand",
12+
"test:prod": "npm run build && jest -c jest.dist.js --no-cache --ci --runInBand",
1313
"lint:check": "eslint .",
1414
"test:watch": "jest --watch --no-cache",
1515
"rollup": "lerna run rollup --parallel",
@@ -71,6 +71,7 @@
7171
"jest-serializer-html": "^4.0.1",
7272
"jsdom": "^11.3.0",
7373
"lerna": "^2.2.0",
74+
"lerna-alias": "^2.0.0",
7475
"module-alias": "^2.0.1",
7576
"npm-run-all": "^4.0.2",
7677
"polished": "^1.2.1",
@@ -145,28 +146,6 @@
145146
}
146147
]
147148
},
148-
"jest": {
149-
"transform": {
150-
"\\.css$": "<rootDir>/test/styleTransform.js",
151-
"^.+\\.js?$": "babel-jest"
152-
},
153-
"moduleNameMapper": {
154-
"^emotion$": "<rootDir>/packages/emotion/src",
155-
"^react-emotion$": "<rootDir>/packages/react-emotion/src",
156-
"^emotion-utils$": "<rootDir>/packages/emotion-utils/src",
157-
"^emotion-server$": "<rootDir>/packages/emotion-server/src",
158-
"^emotion-theming$": "<rootDir>/packages/emotion-theming/src",
159-
"^babel-plugin-emotion": "<rootDir>/packages/babel-plugin-emotion/src",
160-
"^create-emotion$": "<rootDir>/packages/create-emotion/src",
161-
"^jest-emotion$": "<rootDir>/packages/jest-emotion/src",
162-
"^create-emotion-styled$": "<rootDir>/packages/create-emotion-styled/src",
163-
"^create-emotion-server$": "<rootDir>/packages/create-emotion-server/src"
164-
},
165-
"setupTestFrameworkScriptFile": "<rootDir>/test/testSetup.js",
166-
"coveragePathIgnorePatterns": [
167-
"<rootDir>/packages/emotion-utils/src/stylis.js"
168-
]
169-
},
170149
"workspaces": [
171150
"packages/*"
172151
],

yarn.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6163,6 +6163,12 @@ lcid@^1.0.0:
61636163
dependencies:
61646164
invert-kv "^1.0.0"
61656165

6166+
lerna-alias@^2.0.0:
6167+
version "2.0.0"
6168+
resolved "https://registry.yarnpkg.com/lerna-alias/-/lerna-alias-2.0.0.tgz#3dda4aba3cb307fe91406bcb821a62c5537b74f4"
6169+
dependencies:
6170+
glob "^7.1.2"
6171+
61666172
lerna@^2.2.0:
61676173
version "2.4.0"
61686174
resolved "https://registry.yarnpkg.com/lerna/-/lerna-2.4.0.tgz#7b76446b154bafb9cba8996f3dc233f1cb6ca7c3"

0 commit comments

Comments
 (0)