aboutsummaryrefslogtreecommitdiffstats
path: root/test/screens
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2018-03-31 05:39:43 +0800
committerkumavis <aaron@kumavis.me>2018-03-31 05:39:43 +0800
commitd05a2ca96895195e30c0987bf042c079b4caeadf (patch)
tree4ac7af4c862fac10b4b8166cb0c530a46892435a /test/screens
parent7dde948c451a24313ca1d98b804a761245cc61c1 (diff)
downloadtangerine-wallet-browser-d05a2ca96895195e30c0987bf042c079b4caeadf.tar
tangerine-wallet-browser-d05a2ca96895195e30c0987bf042c079b4caeadf.tar.gz
tangerine-wallet-browser-d05a2ca96895195e30c0987bf042c079b4caeadf.tar.bz2
tangerine-wallet-browser-d05a2ca96895195e30c0987bf042c079b4caeadf.tar.lz
tangerine-wallet-browser-d05a2ca96895195e30c0987bf042c079b4caeadf.tar.xz
tangerine-wallet-browser-d05a2ca96895195e30c0987bf042c079b4caeadf.tar.zst
tangerine-wallet-browser-d05a2ca96895195e30c0987bf042c079b4caeadf.zip
development - screens - screenshot on failure
Diffstat (limited to 'test/screens')
-rw-r--r--test/screens/new.spec.js29
1 files changed, 25 insertions, 4 deletions
diff --git a/test/screens/new.spec.js b/test/screens/new.spec.js
index 2af891060..71b3c53ac 100644
--- a/test/screens/new.spec.js
+++ b/test/screens/new.spec.js
@@ -12,7 +12,17 @@ const By = webdriver.By
const { delay, buildWebDriver } = require('./func')
const localesIndex = require('../../app/_locales/index.json')
-captureAllScreens().catch(console.error)
+let driver
+
+captureAllScreens().catch((err) => {
+ try {
+ verboseReportOnFailure()
+ console.error(err)
+ driver.quit()
+ } finally {
+ process.exit(1)
+ }
+})
async function captureAllScreens() {
let screenshotCount = 0
@@ -26,7 +36,7 @@ async function captureAllScreens() {
// setup selenium and install extension
const extPath = path.resolve('dist/chrome')
- const driver = buildWebDriver(extPath)
+ driver = buildWebDriver(extPath)
await driver.get('chrome://extensions-frame')
const elems = await driver.findElements(By.css('.extension-list-item-wrapper'))
const extensionId = await elems[1].getAttribute('id')
@@ -34,7 +44,7 @@ async function captureAllScreens() {
await delay(500)
tabs = await driver.getAllWindowHandles()
await driver.switchTo().window(tabs[0])
- await delay(300)
+ await delay(500)
await setProviderType('localhost')
// click try new ui
@@ -43,7 +53,6 @@ async function captureAllScreens() {
// close metamask homepage and extra home.html
tabs = await driver.getAllWindowHandles()
- console.log(tabs)
// metamask homepage is opened on prod, not dev
if (tabs.length > 2) {
await driver.switchTo().window(tabs[2])
@@ -204,4 +213,16 @@ async function captureAllScreens() {
await pify(endOfStream)(stream)
}
+ 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)
+ }
+
}