Commit 19d0a58 1 parent a237781 commit 19d0a58 Copy full SHA for 19d0a58
File tree 5 files changed +157
-2383
lines changed
packages/jest-config-accurapp
5 files changed +157
-2383
lines changed Original file line number Diff line number Diff line change
1
+ module . exports = {
2
+ process ( ) {
3
+ // Return empty object
4
+ return 'module.exports = {}'
5
+ } ,
6
+ getCacheKey ( ) {
7
+ // The output is always the same.
8
+ return 'cssTransform'
9
+ } ,
10
+ }
Original file line number Diff line number Diff line change
1
+ const path = require ( 'path' )
2
+ const camelcase = require ( 'camelcase' )
3
+
4
+ // Based on https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/config/jest/fileTransform.js
5
+
6
+ module . exports = {
7
+ process ( src , filename ) {
8
+ const assetFilename = JSON . stringify ( path . basename ( filename ) )
9
+
10
+ if ( filename . match ( / \. s v g $ / ) ) {
11
+ // Based on how SVGR generates a component name:
12
+ // https://github.com/smooth-code/svgr/blob/01b194cf967347d43d4cbe6b434404731b87cf27/packages/core/src/state.js#L6
13
+ const pascalCaseFilename = camelcase ( path . parse ( filename ) . name , {
14
+ pascalCase : true ,
15
+ } )
16
+ const componentName = `Svg${ pascalCaseFilename } `
17
+ return `const React = require('react')
18
+ module.exports = {
19
+ __esModule: true,
20
+ default: ${ assetFilename } ,
21
+ ReactComponent: React.forwardRef(function ${ componentName } (props, ref) {
22
+ return {
23
+ $$typeof: Symbol.for('react.element'),
24
+ type: 'svg',
25
+ ref: ref,
26
+ key: null,
27
+ props: Object.assign({}, props, {
28
+ children: ${ assetFilename }
29
+ })
30
+ }
31
+ }),
32
+ }`
33
+ }
34
+
35
+ return `module.exports = ${ assetFilename } `
36
+ } ,
37
+ }
Original file line number Diff line number Diff line change @@ -14,16 +14,14 @@ module.exports = {
14
14
15
15
// Transform simple css files in an empty object
16
16
// https://jestjs.io/docs/en/webpack.html
17
- '\\.css$' : 'react-scripts/ config/jest /cssTransform' ,
17
+ '\\.css$' : 'jest- config-accurapp /cssTransform' ,
18
18
19
19
// Transform all other files into just the filename string
20
- '^(?!.*\\.(js|jsx|ts|tsx|css|json)$)' : 'react-scripts/ config/jest /fileTransform' ,
20
+ '^(?!.*\\.(js|jsx|ts|tsx|css|json)$)' : 'jest- config-accurapp /fileTransform' ,
21
21
} ,
22
22
23
23
// Don't transform css modules into an empty object
24
- transformIgnorePatterns : [
25
- '\\.module\\.(css)$' ,
26
- ] ,
24
+ transformIgnorePatterns : [ '\\.module\\.(css)$' ] ,
27
25
28
26
// Instead use identity-obj-proxy which outputs the classnames
29
27
moduleNameMapper : {
Original file line number Diff line number Diff line change 17
17
"dependencies" : {
18
18
"@babel/core" : " 7.9.0" ,
19
19
"babel-jest" : " 25.4.0" ,
20
+ "camelcase" : " 6.0.0" ,
20
21
"identity-obj-proxy" : " 3.0.0" ,
21
22
"jest" : " 25.4.0" ,
22
23
"jest-environment-jsdom-sixteen" : " 1.0.3" ,
23
24
"jest-watch-typeahead" : " 0.5.0" ,
24
- "react-app-polyfill" : " 1.0.6" ,
25
- "react-scripts" : " 3.4.1"
25
+ "react-app-polyfill" : " 1.0.6"
26
26
}
27
- }
27
+ }
You can’t perform that action at this time.
0 commit comments