import '@testing-library/jest-dom' ; import '@testing-library/jest-dom/extend-expect' ; import { configure } from 'enzyme' ; import Adapter from 'enzyme-adapter-react-16' ; import * as fs from 'fs' ; import * as path from 'path' ; import 'raf/polyfill' ; configure ( { adapter : new Adapter ( ) } ) ; global . fetch = require ( 'jest-fetch-mock' ) ; const walkDir = ( dir , callback ) => { fs . readdirSync ( dir ) . forEach ( f => { const filePath = path . join ( dir , f ) ; const isDirectory = fs . statSync ( filePath ) . isDirectory ( ) ; if ( isDirectory ) { walkDir ( filePath , callback ) ; } else { callback ( filePath ) ; } } ) ; } ; const mocksPath = 'src/__mocks__/' ; const mockPathEndings = [ '.ts' , '.tsx' ] ; walkDir ( mocksPath , name => { mockPathEndings . forEach ( ending => { if ( name . endsWith ( ending ) ) { jest . unmock ( name . substring ( mocksPath . length , name . length - ending . length ) ) ; } } ) ; } ) ;