-
Notifications
You must be signed in to change notification settings - Fork 259
Question: How to not duplicate phantom.init()
settings for every test suite?
#107
Comments
That should work, It's not obvious to me what you might be doing wrong. Another way to get reuse is simply to create a function
|
Thanks, wrapping it in my own function is more elegant than where I was headed... I got tunnel vision on trying to use CasperJS cli hooks or using a global |
What I did is I run var require = patchRequire(require);
var phantomcss = require('../../vendor/components/phantomcss/phantomcss');
phantomcss.init({
libraryRoot: 'vendor/components/phantomcss',
screenshotRoot: 'test/visual/screenshots/baselines',
comparisonResultRoot: 'test/visual/screenshots/results',
failedComparisonRoot: 'test/visual/screenshots/failures',
rebase: casper.cli.get('rebase')
});
exports.phantomcss = phantomcss; My test files then do a Works great. |
@asymmetric - Can you explain more you code, How to use it further ?. I created the util file and copied the phantom.init function but when I use it in the main.js file but require('util.js). It does not work. e.g Configs.js
Main.js
It does not work |
@PramodDutta phantomcss is not a node module - use full path in require function. You can read about your solution here https://asymmetric.github.io/2015/04/14/phantomcss/ |
Forgive me if this is completely obvious, but I'm more designer than developer right now...
Anyway, so, I've created a few test suites using PhantomCSS to generate some image diffs. They're pretty much structured exactly like your demos. However, I noticed that I end up copy+pasting the exact same
phantomcss.init()
configuration over and over into eachtest.js
. I would much rather have a sharedphantomcss.init()
in a single location so if we decide to change the configuration, I don't have to edit every test suite.The one caveat is that, instead of storing all screenshots in a single directory, I want to store each test's screenshots in its own directory to organize them a little better.
Anyway, I tried using
init()
andupdate()
like illustrated below, but it didn't seem to work for me. I would appreciate any guidance on how best to accomplish this.The text was updated successfully, but these errors were encountered: