@ornikar/jest-config-react-native 3.3.0 → 3.4.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,38 @@
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.4.0](https://github.com/ornikar/shared-configs/compare/@ornikar/jest-config-react-native@3.3.2...@ornikar/jest-config-react-native@3.4.0) (2022-03-08)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **jest-config-react-native:** fix to make it work with jest 27 ([cf25dcd](https://github.com/ornikar/shared-configs/commit/cf25dcdd784617c91563bf14057845f75b4e20ca))
12
+
13
+
14
+ ### Features
15
+
16
+ * faster jest [no issue] ([#660](https://github.com/ornikar/shared-configs/issues/660)) ([866764e](https://github.com/ornikar/shared-configs/commit/866764e4e12d27fa5b6a12f9452b99808035c2d6))
17
+
18
+
19
+
20
+
21
+
22
+ ## [3.3.2](https://github.com/ornikar/shared-configs/compare/@ornikar/jest-config-react-native@3.3.1...@ornikar/jest-config-react-native@3.3.2) (2022-02-04)
23
+
24
+ **Note:** Version bump only for package @ornikar/jest-config-react-native
25
+
26
+
27
+
28
+
29
+
30
+ ## [3.3.1](https://github.com/ornikar/shared-configs/compare/@ornikar/jest-config-react-native@3.3.0...@ornikar/jest-config-react-native@3.3.1) (2022-02-01)
31
+
32
+ **Note:** Version bump only for package @ornikar/jest-config-react-native
33
+
34
+
35
+
36
+
37
+
6
38
  # [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
39
 
8
40
 
package/jest-preset.js CHANGED
@@ -1,38 +1,34 @@
1
1
  'use strict';
2
2
 
3
- const jestPreset = require('@ornikar/jest-config/jest-preset');
3
+ const baseOrnikarPreset = require('@ornikar/jest-config-react/jest-preset');
4
4
  const expoPreset = require('jest-expo/jest-preset');
5
- const mergeWith = require('lodash.mergewith');
6
-
7
- function customizer(objValue, srcValue) {
8
- if (Array.isArray(objValue)) {
9
- // eslint-disable-next-line unicorn/prefer-spread
10
- return objValue.concat(srcValue);
11
- }
12
- return undefined;
13
- }
14
-
15
- const basePreset = mergeWith(expoPreset, jestPreset, customizer);
16
5
 
17
6
  module.exports = {
18
- ...basePreset,
19
- testMatch: [...basePreset.testMatch, '<rootDir>/src/**/stories.{ts,tsx}', '<rootDir>/src/**/*.stories.{ts,tsx}'],
7
+ ...baseOrnikarPreset,
8
+ ...expoPreset,
9
+ setupFiles: [...expoPreset.setupFiles, ...baseOrnikarPreset.setupFiles],
10
+ testMatch: baseOrnikarPreset.testMatch,
20
11
  moduleNameMapper: {
21
- ...basePreset.moduleNameMapper,
12
+ ...expoPreset.moduleNameMapper,
22
13
  '^@storybook/addon-actions$': require.resolve('./__mocks__/@storybook/addon-actions.js'),
23
14
  '@storybook/react-native$': require.resolve('./__mocks__/@storybook/react-native.jsx'),
24
15
  '^@storybook/react-native$': require.resolve('./__mocks__/@storybook/react-native.jsx'),
16
+ '@storybook/react$': require.resolve('./__mocks__/@storybook/react-native.jsx'),
17
+ '^@storybook/react$': require.resolve('./__mocks__/@storybook/react-native.jsx'),
25
18
  },
26
19
  transform: {
20
+ // compilation of problematic node_modules has a simplier config
21
+ 'node_modules.*\\.(js|jsx|ts|tsx)$': require.resolve('./transformers/babel-transformer-node-modules.js'),
22
+
27
23
  // remove svg asset transformer from expo config, as we configure svg with custom metro transformer
28
24
  ...Object.fromEntries(
29
- Object.entries(basePreset.transform).map(([key, value]) => {
25
+ Object.entries(expoPreset.transform).map(([key, value]) => {
30
26
  if (key.includes('|svg|')) return [key.replace('|svg|', '|'), value];
31
27
  return [key, value];
32
28
  }),
33
29
  ),
34
30
  // legacy support, use { ReactComponent } from .svg instead.
35
- '\\.inline\\.svg$': '@ornikar/jest-config-react-native/svg-transformer-inline',
36
- '\\.svg$': '@ornikar/jest-config-react-native/svg-transformer',
31
+ '\\.inline\\.svg$': require.resolve('./transformers/svg-transformer-inline.js'),
32
+ '\\.svg$': require.resolve('./transformers/svg-transformer.js'),
37
33
  },
38
34
  };
@@ -4,15 +4,11 @@ const path = require('path');
4
4
 
5
5
  module.exports = {
6
6
  resolveSnapshotPath: (testPath, snapshotExtension) => {
7
- const snapshotPath = `${path.dirname(testPath)}/__native_snapshots__/${path.basename(
8
- testPath,
9
- )}${snapshotExtension}`;
10
- return snapshotPath;
7
+ return `${path.dirname(testPath)}/__native_snapshots__/${path.basename(testPath)}${snapshotExtension}`;
11
8
  },
12
9
 
13
10
  resolveTestPath: (snapshotFilePath, snapshotExtension) => {
14
- const testPath = snapshotFilePath.replace('/__native_snapshots__', '').slice(0, -snapshotExtension.length);
15
- return testPath;
11
+ return snapshotFilePath.replace('/__native_snapshots__', '').slice(0, -snapshotExtension.length);
16
12
  },
17
13
 
18
14
  testPathForConsistencyCheck: 'src/shared/components/Button/Button.test.tsx',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ornikar/jest-config-react-native",
3
- "version": "3.3.0",
4
- "description": "jest config",
3
+ "version": "3.4.0",
4
+ "description": "✅⚛️📱 jest config for react-native",
5
5
  "repository": "ornikar/shared-configs",
6
6
  "main": "jest-preset.js",
7
7
  "license": "ISC",
@@ -19,9 +19,8 @@
19
19
  "react-dom": "^17.0.0"
20
20
  },
21
21
  "dependencies": {
22
- "@ornikar/jest-config": "^7.1.3",
23
- "jest-svg-transformer": "^1.0.0",
24
- "lodash.mergewith": "4.6.2"
22
+ "@ornikar/jest-config-react": "^9.4.0",
23
+ "jest-svg-transformer": "^1.0.0"
25
24
  },
26
25
  "devDependencies": {
27
26
  "@testing-library/react-hooks": "7.0.2",
@@ -29,5 +28,5 @@
29
28
  "jest-expo": "44.0.1",
30
29
  "react": "17.0.2"
31
30
  },
32
- "gitHead": "1b78cd573c1e3685bb58fa590fe998f7871eb2d2"
31
+ "gitHead": "d436e7c9e103d89eba6c89c881659f501f9b08be"
33
32
  }
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ // eslint-disable-next-line import/no-extraneous-dependencies
4
+ const babelJest = require('babel-jest');
5
+
6
+ module.exports = babelJest.createTransformer({
7
+ // should be identical to the config in @ornikar/webpack-configs/reactNativeWeb.js
8
+ presets: [['babel-preset-expo', { jsxRuntime: 'automatic' }]],
9
+ babelrc: false,
10
+ configFile: false,
11
+ });
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ const { process } = require('jest-svg-transformer');
4
+
5
+ exports.process = process;
@@ -0,0 +1,29 @@
1
+ 'use strict';
2
+
3
+ const baseOrnikarPreset = require('@ornikar/jest-config-react/jest-preset');
4
+ const expoPreset = require('jest-expo/web/jest-preset');
5
+
6
+ module.exports = {
7
+ ...baseOrnikarPreset,
8
+ ...expoPreset,
9
+ setupFiles: [...expoPreset.setupFiles, ...baseOrnikarPreset.setupFiles],
10
+ testMatch: [
11
+ ...baseOrnikarPreset.testMatch,
12
+ baseOrnikarPreset.testMatch[0].replace('**/__tests__/**/*.', '**/stories.'),
13
+ baseOrnikarPreset.testMatch[0].replace('**/__tests__/**/*.', '**/*.stories.'),
14
+ ],
15
+ moduleNameMapper: {
16
+ ...baseOrnikarPreset.moduleNameMapper,
17
+ ...expoPreset.moduleNameMapper,
18
+ },
19
+ transform: {
20
+ // compilation of problematic node_modules has a simplier config
21
+ 'node_modules.*\\.(js|jsx|ts|tsx)$': require.resolve('../transformers/babel-transformer-node-modules.js'),
22
+
23
+ // legacy support, use { ReactComponent } from .svg instead.
24
+ '\\.inline\\.svg$': require.resolve('../transformers/svg-transformer-inline.js'),
25
+ '\\.svg$': require.resolve('../transformers/svg-transformer.js'),
26
+
27
+ ...baseOrnikarPreset.transform,
28
+ },
29
+ };
@@ -1,3 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = require('jest-svg-transformer');