Skip to content

Commit

Permalink
fix(react-native): fix svg-mock path in generated jest config (#7248)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaysoo committed Oct 5, 2021
1 parent 711e80e commit 6caba47
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 6 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import 'react-native';
import React from 'react';
import * as React from 'react';
import { render } from '@testing-library/react-native';

import App from './App';

it('renders correctly', () => {
test('renders correctly', () => {
const { getByTestId } = render(<App />);
expect(getByTestId('heading')).toHaveTextContent('Welcome');
});
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('Add react-native-svg to dev dependencies', () => {

const jestConfig = tree.read('apps/products/jest.config.js', 'utf-8');
expect(jestConfig).toContain(
`moduleNameMapper: {'\\.svg': require.resolve('@nrwl/react-native/src/utils/svg-mock.js')},`
`moduleNameMapper: {'\\.svg': '@nrwl/react-native/plugins/jest/svg-mock'},`
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function mockSvgInJestConfig(host: Tree, project: ProjectConfiguration) {
jestConfigPath,
contents.replace(
/,([^,]*)$/,
`, moduleNameMapper: {'\\.svg': require.resolve('@nrwl/react-native/src/utils/svg-mock.js')}, $1`
`, moduleNameMapper: {'\\.svg': '@nrwl/react-native/plugins/jest/svg-mock'}, $1`
)
);
} catch {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/src/utils/add-jest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export async function addJest(
moduleFileExtensions: ['ts', 'js', 'html', 'tsx', 'jsx'],
setupFilesAfterEnv: ['<rootDir>/test-setup.ts'],
moduleNameMapper: {
'\\.svg': require.resolve('@nrwl/react-native/src/svg-mock.js'),
'\\.svg': '@nrwl/react-native/plugins/jest/svg-mock'
},
transform: {
'\\\\.(js|ts|tsx)$': require.resolve('react-native/jest/preprocessor.js'),
Expand Down

0 comments on commit 6caba47

Please sign in to comment.