From feb989c12ba23104b22c719b9a2c2f0cea7ecde2 Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Tue, 15 Jun 2021 14:16:09 -0230 Subject: [PATCH] Start dapp directly from `metamask-ui.spec.js` (#11299) The dapp is now started directly from the `metamask-ui.spec.js` test module. This makes it easier to run independently, and brings it in- line with our other E2E tests. The `--no-timeouts` flag is now used as well, rather than setting the timeout to `0` within the test. This also brings it in-line with our other tests. Mainly this was done to facilitate further refactors which will come in later PRs. --- test/e2e/metamask-ui.spec.js | 28 +++++++++++++++++++++++++++- test/e2e/run-all.sh | 8 +------- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/test/e2e/metamask-ui.spec.js b/test/e2e/metamask-ui.spec.js index b813a597d..e6dadd200 100644 --- a/test/e2e/metamask-ui.spec.js +++ b/test/e2e/metamask-ui.spec.js @@ -1,24 +1,42 @@ const { strict: assert } = require('assert'); +const path = require('path'); const enLocaleMessages = require('../../app/_locales/en/messages.json'); +const createStaticServer = require('../../development/create-static-server'); const { tinyDelayMs, regularDelayMs, largeDelayMs } = require('./helpers'); const { buildWebDriver } = require('./webdriver'); const Ganache = require('./ganache'); const ganacheServer = new Ganache(); +const dappPort = 8080; describe('MetaMask', function () { let driver; + let dappServer; let tokenAddress; const testSeedPhrase = 'phrase upgrade clock rough situate wedding elder clever doctor stamp excess tent'; - this.timeout(0); this.bail(true); before(async function () { await ganacheServer.start(); + const dappDirectory = path.resolve( + __dirname, + '..', + '..', + 'node_modules', + '@metamask', + 'test-dapp', + 'dist', + ); + dappServer = createStaticServer(dappDirectory); + dappServer.listen(dappPort); + await new Promise((resolve, reject) => { + dappServer.on('listening', resolve); + dappServer.on('error', reject); + }); const result = await buildWebDriver(); driver = result.driver; await driver.navigate(); @@ -43,6 +61,14 @@ describe('MetaMask', function () { after(async function () { await ganacheServer.quit(); await driver.quit(); + await new Promise((resolve, reject) => { + dappServer.close((error) => { + if (error) { + return reject(error); + } + return resolve(); + }); + }); }); describe('Going through the first time flow', function () { diff --git a/test/e2e/run-all.sh b/test/e2e/run-all.sh index 18c3443c9..d038bedaa 100755 --- a/test/e2e/run-all.sh +++ b/test/e2e/run-all.sh @@ -28,10 +28,4 @@ do retry mocha --no-timeouts "${spec}" done -retry concurrently --kill-others \ - --names 'dapp,e2e' \ - --prefix '[{time}][{name}]' \ - --success first \ - 'yarn dapp' \ - 'mocha test/e2e/metamask-ui.spec' - +retry mocha --no-timeouts test/e2e/metamask-ui.spec