Skip to content

Commit

Permalink
Add skip screenshot option
Browse files Browse the repository at this point in the history
  • Loading branch information
bokuweb committed Dec 26, 2016
1 parent d1dda1b commit e765486
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
6 changes: 4 additions & 2 deletions client/index.js
Expand Up @@ -10,7 +10,9 @@ module.exports = {
const nightmare = typeof window !== 'undefined' &&
window.__nightmare ||
parent.window.__nightmare;
if (!nightmare) return resolve();
if (!nightmare || nightmare.skipScreenshot) {
return resolve();
}
const fs = nightmare.fs;
const win = nightmare.remote.getCurrentWindow();
setTimeout(function() {
Expand All @@ -22,7 +24,7 @@ module.exports = {
fs.writeFile(path, data, 'base64', resolve);
});
});
}, 100);
}, 0);
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -16,7 +16,7 @@ var NightmareBrowser = function (baseBrowserDecorator, args, config) {
})

this._process.stdout.on('data', function (data) {
console.log('' + data);
// console.log('' + data);
})
}
}
Expand Down
1 change: 1 addition & 0 deletions karma.conf.js
Expand Up @@ -62,6 +62,7 @@ module.exports = function(config) {
concurrency: Infinity,

nightmareOptions: {
skipScreenshot: false,
width: 800,
height: 600,
show: false,
Expand Down
20 changes: 12 additions & 8 deletions lib/browser.js
Expand Up @@ -20,13 +20,17 @@ const nightmare = require('nightmare')(
);

nightmare
.goto(process.argv[2])
.wait('#browsers')
.evaluate(() => {
document.querySelector('#banner').style.display = 'none';
document.querySelector('#browsers').style.display = 'none';
})
.wait(() => null)
.end()
.goto(process.argv[2])
.wait('#browsers')
.evaluate((options) => {
const __nightmare = window.__nightmare || window.parent.__nightmare;
if (__nightmare) {
__nightmare.skipScreenshot = options.skipScreenshot;
}
document.querySelector('#banner').style.display = 'none';
document.querySelector('#browsers').style.display = 'none';
}, options)
.wait(() => null)
.end()
.catch((error) => console.error(error));

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -4,7 +4,7 @@
"description": "",
"main": "index.js",
"scripts": {
"test": "DEBUG=nightmare:*,electron:* karma start"
"test": "karma start"
},
"keywords": [
"karma-plugin",
Expand Down

0 comments on commit e765486

Please sign in to comment.