Last active
October 14, 2016 22:41
-
-
Save emilong/ec805d403f328b7b6f90f99c0850d9f7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sanitize = require('sanitize-filename'); | |
// Declared outside any describe() or context() block so that it's called after every test. | |
// this is bound by Mocha to let us have access to the current test state, so we make sure | |
// to avoid a fat-arrow function declaration here. | |
afterEach(function(){ | |
const filename = `${sanitize(this.currentTest.title.replace(/\s+/g, '-'))}-${+new Date()}`; | |
if (this.currentTest.state === 'failed') { | |
return captureLogs(`${filename}.log`) | |
.then(() => takeScreenshot(`${filename}.png`)); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment