diff --git a/test/helper.js b/test/helper.js index 5731a905e..749577c40 100644 --- a/test/helper.js +++ b/test/helper.js @@ -1,4 +1,3 @@ -import Ganache from 'ganache-core'; import nock from 'nock'; import Enzyme from 'enzyme'; import Adapter from 'enzyme-adapter-react-16'; @@ -31,13 +30,6 @@ process.on('exit', () => { Enzyme.configure({ adapter: new Adapter() }); -// ganache server -const server = Ganache.server(); -server.listen(8545); - -server.on('error', console.error); -server.on('clientError', console.error); - log.setDefaultLevel(5); global.log = log; diff --git a/test/unit/app/controllers/metamask-controller-test.js b/test/unit/app/controllers/metamask-controller-test.js index ab7d9d85f..d92da4ed4 100644 --- a/test/unit/app/controllers/metamask-controller-test.js +++ b/test/unit/app/controllers/metamask-controller-test.js @@ -11,6 +11,10 @@ import createTxMeta from '../../../lib/createTxMeta'; import { addHexPrefix } from '../../../../app/scripts/lib/util'; import { TRANSACTION_STATUSES } from '../../../../shared/constants/transaction'; +const Ganache = require('../../../e2e/ganache'); + +const ganacheServer = new Ganache(); + const threeBoxSpies = { init: sinon.stub(), getThreeBoxSyncingState: sinon.stub().returns(true), @@ -90,6 +94,10 @@ describe('MetaMaskController', function () { const sandbox = sinon.createSandbox(); const noop = () => undefined; + before(async function () { + await ganacheServer.start(); + }); + beforeEach(function () { nock('https://min-api.cryptocompare.com') .persist() @@ -133,6 +141,10 @@ describe('MetaMaskController', function () { sandbox.restore(); }); + after(async function () { + await ganacheServer.quit(); + }); + describe('#getAccounts', function () { it('returns first address when dapp calls web3.eth.getAccounts', async function () { const password = 'a-fake-password';