Skip to content

Commit

Permalink
chore(jest): add jest-css-modules-transform
Browse files Browse the repository at this point in the history
  • Loading branch information
belgattitude committed Jun 8, 2021
1 parent 697842e commit a9c0d5e
Show file tree
Hide file tree
Showing 14 changed files with 26 additions and 192 deletions.
7 changes: 7 additions & 0 deletions .changeset/chatty-kangaroos-know.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'blog-app': patch
'web-app': patch
'@your-org/core-lib': patch
---

Jest: use css transform from jest-css-modules-transform
15 changes: 0 additions & 15 deletions apps/blog-app/config/jest/css-transform.js

This file was deleted.

42 changes: 0 additions & 42 deletions apps/blog-app/config/jest/file-transform.js

This file was deleted.

6 changes: 1 addition & 5 deletions apps/blog-app/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,13 @@ const config = {
rootDir: './src',
transform: {
...tsPreset.transform,
'^.+\\.css$': '<rootDir>/../config/jest/css-transform.js',
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)':
'<rootDir>/../config/jest/file-transform.js',
},
setupFilesAfterEnv: ['@testing-library/jest-dom/extend-expect'],
transformIgnorePatterns: ['^.+\\.module\\.(css|sass|scss|less)$'],
testMatch: ['<rootDir>/**/*.{spec,test}.{js,jsx,ts,tsx}'],
moduleNameMapper: {
// For @testing-library/react
'^@/test-utils$': '<rootDir>/../config/jest/test-utils',
'^.+\\.module\\.(css|sass|scss)$': 'identity-obj-proxy',
'.+\\.(css|styl|less|sass|scss)$': 'jest-css-modules-transform',
...getTsConfigBasePaths(),
},
// false by default, overrides in cli, ie: yarn test:unit --collect-coverage=true
Expand Down
2 changes: 1 addition & 1 deletion apps/blog-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
"@typescript-eslint/eslint-plugin": "^4.26.0",
"@typescript-eslint/parser": "^4.26.0",
"autoprefixer": "^10.2.6",
"camelcase": "^6.2.0",
"cross-env": "^7.0.3",
"eslint": "^7.28.0",
"eslint-config-prettier": "^8.3.0",
Expand All @@ -60,6 +59,7 @@
"eslint-plugin-react-hooks": "^4.2.0",
"eslint-plugin-testing-library": "^4.6.0",
"jest": "^27.0.4",
"jest-css-modules-transform": "^4.2.1",
"next-transpile-modules": "^7.2.0",
"npm-run-all": "^4.1.5",
"postcss": "^8.3.0",
Expand Down
15 changes: 0 additions & 15 deletions apps/web-app/config/jest/css-transform.js

This file was deleted.

42 changes: 0 additions & 42 deletions apps/web-app/config/jest/file-transform.js

This file was deleted.

6 changes: 1 addition & 5 deletions apps/web-app/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,13 @@ const config = {
rootDir: './src',
transform: {
...tsPreset.transform,
'^.+\\.css$': '<rootDir>/../config/jest/css-transform.js',
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)':
'<rootDir>/../config/jest/file-transform.js',
},
setupFilesAfterEnv: ['@testing-library/jest-dom/extend-expect'],
transformIgnorePatterns: ['^.+\\.module\\.(css|sass|scss|less)$'],
testMatch: ['<rootDir>/**/*.{spec,test}.{js,jsx,ts,tsx}'],
moduleNameMapper: {
// For @testing-library/react
'^@/test-utils$': '<rootDir>/../config/jest/test-utils',
'^.+\\.module\\.(css|sass|scss)$': 'identity-obj-proxy',
'.+\\.(css|styl|less|sass|scss)$': 'jest-css-modules-transform',
...getTsConfigBasePaths(),
},
// false by default, overrides in cli, ie: yarn test:unit --collect-coverage=true
Expand Down
2 changes: 1 addition & 1 deletion apps/web-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
"@typescript-eslint/parser": "^4.26.0",
"@welldone-software/why-did-you-render": "^6.1.4",
"autoprefixer": "^10.2.6",
"camelcase": "^6.2.0",
"cross-env": "^7.0.3",
"dotenv-flow": "^3.2.0",
"dotenv-flow-cli": "^1.0.0",
Expand All @@ -67,6 +66,7 @@
"eslint-plugin-react-hooks": "^4.2.0",
"eslint-plugin-testing-library": "^4.6.0",
"jest": "^27.0.4",
"jest-css-modules-transform": "^4.2.1",
"npm-run-all": "^4.1.5",
"postcss": "^8.3.0",
"prettier": "^2.3.1",
Expand Down
15 changes: 0 additions & 15 deletions packages/core-lib/config/jest/css-transform.js

This file was deleted.

40 changes: 0 additions & 40 deletions packages/core-lib/config/jest/file-transform.js

This file was deleted.

5 changes: 0 additions & 5 deletions packages/core-lib/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,12 @@ const config = {
rootDir: './src',
transform: {
...tsjPreset.transform,
'^.+\\.css$': '<rootDir>/../config/jest/css-transform.js',
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)':
'<rootDir>/../config/jest/file-transform.js',
},
setupFilesAfterEnv: ['@testing-library/jest-dom/extend-expect'],
transformIgnorePatterns: ['^.+\\.module\\.(css|sass|scss|less)$'],
testMatch: ['<rootDir>/**/*.{spec,test}.{js,jsx,ts,tsx}'],
moduleNameMapper: {
// For @testing-library/react
'^@/test-utils$': '<rootDir>/../config/jest/test-utils',
'^.+\\.module\\.(css|sass|scss)$': 'identity-obj-proxy',
...getTsConfigBasePaths(),
},
// false by default, overrides in cli, ie: yarn test:unit --collect-coverage=true
Expand Down
1 change: 0 additions & 1 deletion packages/core-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"@types/react-dom": "^17.0.6",
"@typescript-eslint/eslint-plugin": "^4.26.0",
"@typescript-eslint/parser": "^4.26.0",
"camelcase": "^6.2.0",
"eslint": "^7.28.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "2.23.4",
Expand Down
20 changes: 15 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3327,7 +3327,6 @@ __metadata:
"@types/react-dom": ^17.0.6
"@typescript-eslint/eslint-plugin": ^4.26.0
"@typescript-eslint/parser": ^4.26.0
camelcase: ^6.2.0
eslint: ^7.28.0
eslint-config-prettier: ^8.3.0
eslint-plugin-import: 2.23.4
Expand Down Expand Up @@ -4205,7 +4204,6 @@ __metadata:
"@your-org/core-lib": "workspace:*"
"@your-org/ui-lib": "workspace:*"
autoprefixer: ^10.2.6
camelcase: ^6.2.0
cross-env: ^7.0.3
eslint: ^7.28.0
eslint-config-prettier: ^8.3.0
Expand All @@ -4218,6 +4216,7 @@ __metadata:
eslint-plugin-react-hooks: ^4.2.0
eslint-plugin-testing-library: ^4.6.0
jest: ^27.0.4
jest-css-modules-transform: ^4.2.1
next: ^10.2.3
next-secure-headers: ^2.2.0
next-seo: ^4.24.0
Expand Down Expand Up @@ -8593,6 +8592,17 @@ __metadata:
languageName: node
linkType: hard

"jest-css-modules-transform@npm:^4.2.1":
version: 4.2.1
resolution: "jest-css-modules-transform@npm:4.2.1"
dependencies:
camelcase: ^6.2.0
postcss: ^7.0.30 || ^8.0.0
postcss-nested: ^4.2.1 || ^5.0.0
checksum: fb07618326faa9c5d312068ec802f0c534d04369a8e325a90e7f1cb53000d038e65268e8f46e79b9427387e78306b82903a8fc0fe7983d650c5eef4ceb922a25
languageName: node
linkType: hard

"jest-diff@npm:^26.0.0":
version: 26.6.2
resolution: "jest-diff@npm:26.6.2"
Expand Down Expand Up @@ -11811,7 +11821,7 @@ __metadata:
languageName: node
linkType: hard

"postcss-nested@npm:5.0.5":
"postcss-nested@npm:5.0.5, postcss-nested@npm:^4.2.1 || ^5.0.0":
version: 5.0.5
resolution: "postcss-nested@npm:5.0.5"
dependencies:
Expand Down Expand Up @@ -12046,7 +12056,7 @@ __metadata:
languageName: node
linkType: hard

"postcss@npm:^8.1.6, postcss@npm:^8.2.1, postcss@npm:^8.3.0":
"postcss@npm:^7.0.30 || ^8.0.0, postcss@npm:^8.1.6, postcss@npm:^8.2.1, postcss@npm:^8.3.0":
version: 8.3.0
resolution: "postcss@npm:8.3.0"
dependencies:
Expand Down Expand Up @@ -15161,7 +15171,6 @@ resolve@^2.0.0-next.3:
"@your-org/db-main-prisma": "workspace:*"
"@your-org/ui-lib": "workspace:*"
autoprefixer: ^10.2.6
camelcase: ^6.2.0
cors: ^2.8.5
cross-env: ^7.0.3
dotenv-flow: ^3.2.0
Expand All @@ -15177,6 +15186,7 @@ resolve@^2.0.0-next.3:
eslint-plugin-react-hooks: ^4.2.0
eslint-plugin-testing-library: ^4.6.0
jest: ^27.0.4
jest-css-modules-transform: ^4.2.1
next: ^10.2.3
next-auth: ^3.25.0
next-connect: ^0.10.1
Expand Down

0 comments on commit a9c0d5e

Please sign in to comment.