@ornikar/jest-config-react-native 3.2.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,28 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [3.3.0](https://github.com/ornikar/shared-configs/compare/@ornikar/jest-config-react-native@3.2.1...@ornikar/jest-config-react-native@3.3.0) (2022-01-31)
7
+
8
+
9
+ ### Features
10
+
11
+ * **jest-config-react-native:** support svg with svgr named loader CME-229 ([#638](https://github.com/ornikar/shared-configs/issues/638)) ([09c70f7](https://github.com/ornikar/shared-configs/commit/09c70f753217c8dfee467c79c240d36eaa041f28))
12
+
13
+
14
+
15
+
16
+
17
+ ## [3.2.1](https://github.com/ornikar/shared-configs/compare/@ornikar/jest-config-react-native@3.2.0...@ornikar/jest-config-react-native@3.2.1) (2022-01-18)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * **jest-config-react-native:** fix typo [no issue] ([#631](https://github.com/ornikar/shared-configs/issues/631)) ([41905a1](https://github.com/ornikar/shared-configs/commit/41905a1a940f31aaa700c8a7c8ddc86c1dd3ec66))
23
+
24
+
25
+
26
+
27
+
6
28
  # [3.2.0](https://github.com/ornikar/shared-configs/compare/@ornikar/jest-config-react-native@3.1.4...@ornikar/jest-config-react-native@3.2.0) (2022-01-18)
7
29
 
8
30
 
package/jest-preset.js CHANGED
@@ -26,11 +26,13 @@ module.exports = {
26
26
  transform: {
27
27
  // remove svg asset transformer from expo config, as we configure svg with custom metro transformer
28
28
  ...Object.fromEntries(
29
- Object.entries(basePreset.transform).map((key, value) => {
29
+ Object.entries(basePreset.transform).map(([key, value]) => {
30
30
  if (key.includes('|svg|')) return [key.replace('|svg|', '|'), value];
31
31
  return [key, value];
32
32
  }),
33
33
  ),
34
+ // legacy support, use { ReactComponent } from .svg instead.
35
+ '\\.inline\\.svg$': '@ornikar/jest-config-react-native/svg-transformer-inline',
34
36
  '\\.svg$': '@ornikar/jest-config-react-native/svg-transformer',
35
37
  },
36
38
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ornikar/jest-config-react-native",
3
- "version": "3.2.0",
3
+ "version": "3.3.0",
4
4
  "description": "jest config",
5
5
  "repository": "ornikar/shared-configs",
6
6
  "main": "jest-preset.js",
@@ -29,5 +29,5 @@
29
29
  "jest-expo": "44.0.1",
30
30
  "react": "17.0.2"
31
31
  },
32
- "gitHead": "d27b3d1e2257b5a31923277c60ef26858bd4b59d"
32
+ "gitHead": "1b78cd573c1e3685bb58fa590fe998f7871eb2d2"
33
33
  }
@@ -0,0 +1,3 @@
1
+ 'use strict';
2
+
3
+ module.exports = require('jest-svg-transformer');
@@ -1,3 +1,24 @@
1
1
  'use strict';
2
2
 
3
- module.exports = require('jest-svg-transformer');
3
+ const { process } = require('jest-svg-transformer');
4
+
5
+ exports.process = (src, filepath) => {
6
+ const content = process(src, filepath);
7
+ return content.replace(
8
+ /module.exports = (.*);/,
9
+ `module.exports = new Proxy({}, {
10
+ get: function getter(target, key) {
11
+ if (key === '__esModule') {
12
+ return true;
13
+ }
14
+ if (key === 'default') {
15
+ return $1.name;
16
+ }
17
+ if (key === 'ReactComponent') {
18
+ return $1;
19
+ }
20
+ throw new Error('Invalid key for svg-transformer jest mock: ' + key);
21
+ }
22
+ });`,
23
+ );
24
+ };