Skip to content

Instantly share code, notes, and snippets.

@just-boris
Last active April 21, 2016 14:31
Show Gist options
  • Save just-boris/a33e1453efcaf23c9724c7fdf2072ae2 to your computer and use it in GitHub Desktop.
Save just-boris/a33e1453efcaf23c9724c7fdf2072ae2 to your computer and use it in GitHub Desktop.
mocha-allure-16
{
"name": "mocha-allure-16",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"prepublish": "selenium-standalone install",
"pretest": "rm -rf allure-results",
"test": "multi='progress=- mocha-allure-reporter=-' mocha test.js --reporter mocha-multi --timeout 30000",
"report": "allure generate allure-results"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"allure-commandline": "^1.4.23",
"mocha": "^2.4.5",
"mocha-allure-reporter": "^1.2.2",
"mocha-multi": "^0.9.0",
"selenium-standalone": "^5.1.0",
"webdriverio": "^4.0.5"
}
}
var screenshot;
var client;
var stepCount = 0;
var webdriverio = require('webdriverio');
var useSelenium = require('./useSelenium');
describe('a suite', function() {
useSelenium();
// initialize allure reporting
beforeEach(function() {
if (typeof allure === 'undefined') { // should be global
return true;
}
allure.createStep("Dummy step", function () {
return ++stepCount;
});
screenshot = allure.createStep('save', function (name) {
return client.screenshot().then(function (res) {
allure.createAttachment(name, new Buffer(res.value, 'base64'));
});
});
badStep = allure.createStep('bad', function() {
return client.click('.nowhere');
});
allure.feature('test feature');
allure.story('test story');
});
afterEach(function () {
if (typeof allure === 'undefined') { // should be global
return true;
}
if (this.currentTest.state !== 'passed') {
return screenshot('screenshot on fail');
}
});
it('simple test', function() {
var webdriverio = require('webdriverio');
client = webdriverio.remote({ desiredCapabilities: { browserName: 'firefox' } });
return client.init()
.url('https://github.com/')
.then(function() { return screenshot('test'); })
.then(function() { return badStep(); })
});
afterEach(function() {
client.end();
});
});
var selenium = require('selenium-standalone');
var seleniumServer;
module.exports = function() {
before(function() {
selenium.start(function(err, process) {
if(err) {
throw new Error(err);
}
seleniumServer = process;
});
});
after(function() {
seleniumServer.kill();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment