Move ganache server from test setup to individual test file. (#9703)

feature/default_network_editable
Thomas Huang 4 years ago committed by GitHub
parent 2d777c9178
commit 418662c365
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      test/helper.js
  2. 12
      test/unit/app/controllers/metamask-controller-test.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;

@ -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';

Loading…
Cancel
Save