Created
May 31, 2017 08:18
-
-
Save rochejul/53036da04052bc1a41ccba254460a44f to your computer and use it in GitHub Desktop.
Karma custom configuration for PhantomJs (allowing screen size, screenshot, ...)
This file contains 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
'use strict'; | |
module.exports = function (config) { | |
config.set({ | |
// ... | |
'browsers': ['PhantomJSCustom'], | |
'customLaunchers': { | |
'PhantomJSCustom': { | |
'base': 'PhantomJS', | |
'options': { | |
'windowName': 'my-window', | |
'settings': { | |
'webSecurityEnabled': false | |
}, | |
'viewportSize': { | |
'width': 1920, | |
'height': 1080 | |
}, | |
'flags': ['--load-images=true'], | |
'debug': false, | |
'onCallback': function (data) { | |
// For screenshot: to use it into the tests: window.top.callPhantom({type: 'render'}); | |
if (data.type === 'render') { | |
// This function will not have the scope of karma.conf.js so we must define any global variable inside it | |
if (window.renderId === undefined) { | |
window.renderId = 0; | |
} | |
page.render('./target/screenshot_' + (window.renderId++) + '.png'); | |
} | |
} | |
} | |
} | |
} | |
// ... | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment