Adding aliases modules import for working with JEST

This commit is contained in:
Adolfo Panizo 2018-03-08 10:04:12 +01:00
parent 31f74421e4
commit 63cbd51599
7 changed files with 19 additions and 9 deletions

View File

@ -38,7 +38,7 @@ module.exports = {
appIndexJs: resolveApp('src/index.js'), appIndexJs: resolveApp('src/index.js'),
appPackageJson: resolveApp('package.json'), appPackageJson: resolveApp('package.json'),
appSrc: resolveApp('src'), appSrc: resolveApp('src'),
appContracts: resolveApp('gnosis-safe-contracts/build'), appContracts: resolveApp('gnosis-safe-contracts/build/contracts'),
yarnLockFile: resolveApp('yarn.lock'), yarnLockFile: resolveApp('yarn.lock'),
testsSetup: resolveApp('src/setupTests.js'), testsSetup: resolveApp('src/setupTests.js'),
appNodeModules: resolveApp('node_modules'), appNodeModules: resolveApp('node_modules'),

View File

@ -69,6 +69,10 @@ module.exports = {
// some tools, although we do not recommend using it, see: // some tools, although we do not recommend using it, see:
// https://github.com/facebookincubator/create-react-app/issues/290 // https://github.com/facebookincubator/create-react-app/issues/290
extensions: ['.js', '.json', '.jsx'], extensions: ['.js', '.json', '.jsx'],
alias: {
'~': paths.appSrc,
'#': paths.appContracts,
}
}, },
output: { output: {
// Next line is not used in dev but WebpackDevServer crashes without it: // Next line is not used in dev but WebpackDevServer crashes without it:

View File

@ -111,6 +111,10 @@ module.exports = {
// some tools, although we do not recommend using it, see: // some tools, although we do not recommend using it, see:
// https://github.com/facebookincubator/create-react-app/issues/290 // https://github.com/facebookincubator/create-react-app/issues/290
extensions: ['.js', '.json', '.jsx'], extensions: ['.js', '.json', '.jsx'],
alias: {
'~': paths.appSrc,
'#': paths.appContracts,
}
}, },
module: { module: {

View File

@ -88,6 +88,8 @@
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$" "[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$"
], ],
"moduleNameMapper": { "moduleNameMapper": {
"~(.*)$": "<rootDir>/src/$1",
"#(.*)$": "<rootDir>/gnosis-safe-contracts/build/contracts/$1",
"^react-native$": "react-native-web" "^react-native$": "react-native-web"
}, },
"moduleFileExtensions": [ "moduleFileExtensions": [

View File

@ -1,6 +1,6 @@
import React from 'react' import React from 'react'
import { BrowserRouter, Switch, Redirect, Route } from 'react-router-dom' import { BrowserRouter, Switch, Redirect, Route } from 'react-router-dom'
import Welcome from 'routes/welcome/components/Layout' import Welcome from '~/routes/welcome/components/Layout'
const AppRoutes = () => ( const AppRoutes = () => (
<Switch> <Switch>

View File

@ -1,8 +1,8 @@
import { MuiThemeProvider } from 'material-ui/styles'
import React from 'react' import React from 'react'
import ReactDOM from 'react-dom' import ReactDOM from 'react-dom'
import theme from '~/theme/mui'
import App from './App' import App from './App'
import { MuiThemeProvider } from 'material-ui/styles';
import theme from './theme/mui'
const Root = () => ( const Root = () => (
<MuiThemeProvider theme={theme}> <MuiThemeProvider theme={theme}>

View File

@ -1,12 +1,12 @@
import Button from 'material-ui/Button'; import Button from 'material-ui/Button';
import React, { Component } from 'react' import React, { Component } from 'react'
import { Form, Field } from 'react-final-form' import { Form, Field } from 'react-final-form'
import Safe from 'contracts/GnosisSafe.json'
import getWeb3, { promisify } from 'utils/getWeb3'
import contract from 'truffle-contract' import contract from 'truffle-contract'
import TextField from 'components/forms/TextField' import TextField from '~/components/forms/TextField'
import Page from 'components/layout/Page' import Page from '~/components/layout/Page'
import PageFrame from 'components/layout/PageFrame' import PageFrame from '~/components/layout/PageFrame'
import getWeb3, { promisify } from '~/utils/getWeb3'
import Safe from '#/GnosisSafe.json'
import './App.scss' import './App.scss'
class App extends Component { class App extends Component {