From 2328b120da60e97ec5a636fd3a743a12a3309b96 Mon Sep 17 00:00:00 2001 From: kumavis Date: Thu, 29 Mar 2018 13:49:54 -0700 Subject: [PATCH 1/3] test - e2e - generate artifacts on test failure --- .gitignore | 2 ++ test/e2e/metamask.spec.js | 30 ++++++++++++++++++++++++------ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index f2a678777..dee5ec220 100644 --- a/.gitignore +++ b/.gitignore @@ -28,6 +28,8 @@ test/background.js test/bundle.js test/test-bundle.js +test-artifacts + #ignore css output and sourcemaps ui/app/css/output/ diff --git a/test/e2e/metamask.spec.js b/test/e2e/metamask.spec.js index a7d0a0efd..88a695adf 100644 --- a/test/e2e/metamask.spec.js +++ b/test/e2e/metamask.spec.js @@ -1,5 +1,8 @@ +const fs = require('fs') +const mkdirp = require('mkdirp') const path = require('path') const assert = require('assert') +const pify = require('pify') const webdriver = require('selenium-webdriver') const By = webdriver.By const { delay, buildWebDriver } = require('./func') @@ -20,6 +23,12 @@ describe('Metamask popup page', function () { await delay(500) }) + afterEach(async function () { + if (this.currentTest.state === 'failed') { + await verboseReportOnFailure(this.currentTest) + } + }) + after(async function () { await driver.quit() }) @@ -39,9 +48,7 @@ describe('Metamask popup page', function () { it('should show privacy notice', async () => { const privacy = await driver.findElement(By.css('.terms-header')).getText() assert.equal(privacy, 'PRIVACY NOTICE', 'shows privacy notice') - driver.findElement(By.css( - 'button' - )).click() + driver.findElement(By.css('button')).click() }) it('should show terms of use', async () => { @@ -51,9 +58,7 @@ describe('Metamask popup page', function () { }) it('should be unable to continue without scolling throught the terms of use', async () => { - const button = await driver.findElement(By.css( - 'button' - )).isEnabled() + const button = await driver.findElement(By.css('button')).isEnabled() assert.equal(button, false, 'disabled continue button') const element = driver.findElement(By.linkText( 'Attributions' @@ -115,4 +120,17 @@ describe('Metamask popup page', function () { await delay(500) }) }) + + async function verboseReportOnFailure(test) { + const artifactDir = `./test-artifacts/${test.title}` + const filepathBase = `${artifactDir}/test-failure` + await pify(mkdirp)(artifactDir) + // capture screenshot + const screenshot = await driver.takeScreenshot() + await pify(fs.writeFile)(`${filepathBase}-screenshot.png`, screenshot, { encoding: 'base64' }) + // capture dom source + const htmlSource = await driver.getPageSource() + await pify(fs.writeFile)(`${filepathBase}-dom.html`, htmlSource) + } + }) From 552fb1fabecd2f2de0c500aeee2fe633e69e7f5a Mon Sep 17 00:00:00 2001 From: kumavis Date: Thu, 29 Mar 2018 13:54:01 -0700 Subject: [PATCH 2/3] test - e2e - fix selector with extra div (?) --- test/e2e/metamask.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/metamask.spec.js b/test/e2e/metamask.spec.js index 88a695adf..1ea8ffdf3 100644 --- a/test/e2e/metamask.spec.js +++ b/test/e2e/metamask.spec.js @@ -97,7 +97,7 @@ describe('Metamask popup page', function () { await delay(300) await driver.findElement(By.css('.sandwich-expando')).click() await delay(500) - await driver.findElement(By.css('#app-content > div > div > div:nth-child(3) > span > div > li:nth-child(3)')).click() + await driver.findElement(By.css('#app-content > div > div:nth-child(3) > span > div > li:nth-child(3)')).click() }) it('should accept account password after lock', async () => { From f6f8cab5dc9ecf750f6e567d0effe0bacc2495d8 Mon Sep 17 00:00:00 2001 From: kumavis Date: Thu, 29 Mar 2018 13:59:39 -0700 Subject: [PATCH 3/3] ci - upload e2e test artifacts --- .circleci/config.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 75819fc6e..ae6f44c8a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -141,6 +141,9 @@ jobs: - run: name: Test command: npm run test:e2e + - store_artifacts: + path: test-artifacts + destination: test-artifacts test-unit: docker: