Skip to content

Commit

Permalink
fix(jest.config.js): change Regex for '@' on 'moduleNameMapper' property
Browse files Browse the repository at this point in the history
  • Loading branch information
aneurysmjs committed May 12, 2019
1 parent 82d0485 commit d6d6b7c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
7 changes: 6 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ module.exports = {
testURL: 'http://localhost',
modulePaths: ['src'],
moduleNameMapper: {
'/^@/(.*)$/': '<rootDir>/src/app$1',
// '/^@/(.*)$/': '<rootDir>/src/app$1',
/**
* @link https://github.com/vuejs-templates/webpack/issues/807
*/
'^@[/](.+)': '<rootDir>/src/app/$1',

},
transform: {
'^.+\\.(js|jsx|mjs)$': '<rootDir>/node_modules/babel-jest',
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/shared/ImgLoader/ImgLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ type PropsType = {
};

function ImgLoader({ src }: PropsType) {
const image = new Image();
const [imgObj, setImg] = useState({ img: null, isLoading: true });
const image = new Image();

image.onload = () => setImg({ img: image.src, isLoading: false });
image.src = src;
Expand Down
8 changes: 4 additions & 4 deletions src/app/components/shared/ImgLoader/ImgLoader.test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// @flow strict

import React from 'react';
import { shallow } from 'enzyme';

import ImgLoader from './ImgLoader';

describe('ImgLoader', () => {
const defaultProps = {};

it('tests something', () => {
shallow(<ImgLoader {...defaultProps} />);
const src = 'https://static.street-beat.ru/upload/resize_cache/iblock/d69/450_450_1/d699afc7b3428f2f51c2f2de6665b506.jpg';
shallow(<ImgLoader src={src} />);
});
});
});

0 comments on commit d6d6b7c

Please sign in to comment.