1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

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

This commit is contained in:
Thomas Huang 2021-02-04 10:50:58 -08:00 committed by GitHub
parent 2d777c9178
commit 418662c365
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 8 deletions

View File

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

View File

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