Skip to content
This repository has been archived by the owner on Dec 18, 2018. It is now read-only.

Duplicate screenshots #110

Open
chris-dura opened this issue Mar 30, 2015 · 2 comments
Open

Duplicate screenshots #110

chris-dura opened this issue Mar 30, 2015 · 2 comments
Labels

Comments

@chris-dura
Copy link
Contributor

I'm trying to organize screenshots into separate sub-directories to make managing them easier. So, I have three simple test files that just open a URL and take a screenshot. The only code differences in the tests is the url being opened and the screenshotRoot and failedComparisonsRoot because I'm trying to organize the screenshots into sub-directories.

tests/
├── test1.js
├── test2.js
└── test3.js
// test1.js

var fs = require('fs'),
    phantomcss = require(fs.absolute(fs.workingDirectory + '/node_modules/phantomcss/phantomcss.js'));

casper.test.begin("Test Suite Numero Uno", 1, function suite(test) {

    phantomcss.init({
        casper:                     casper,
        libraryRoot:                fs.absolute(fs.workingDirectory + '/node_modules/phantomcss'),
        screenshotRoot:             fs.absolute(fs.workingDirectory + '/screenshots/test1'),
        failedComparisonsRoot:      fs.absolute(fs.workingDirectory + '/failures/test1'),
        addLabelToFailedImage:      false,
        mismatchTolerance:          0.01,
        rebase:                     casper.cli.get('rebase')
    });

    casper.start('http://www.google.com');

    casper.viewport(1280, 800, function () {
        phantomcss.screenshot('body', 2000);
    });    

    casper.then(function checkScreenshots() {
        phantomcss.compareAll();
    });

    casper.run(function () {
        console.log('\nTHE END.');
        // phantomcss.getExitStatus(); // pass or fail?
        test.done();
    });

});
// test2.js
...
        screenshotRoot:             fs.absolute(fs.workingDirectory + '/screenshots/test2'),
        failedComparisonsRoot:      fs.absolute(fs.workingDirectory + '/failures/test2'),
...
    casper.start('http://www.huddle.com');
// test3.js
...
        screenshotRoot:             fs.absolute(fs.workingDirectory + '/screenshots/test3'),
        failedComparisonsRoot:      fs.absolute(fs.workingDirectory + '/failures/test3'),
...
    casper.start('http://www.casperjs.org');

I would expect running
casperjs test tests
to end up with this screenshots organization...

screenshots/
├── test1/
|   ├── screenshot_0.png
├── test2/
|   └── screenshot_1.png
└── test3/
    └── screenshot_2.png

However, I end up with the screenshots taken in the second and third suites duplicated into the test1 directory.

screenshots/
├── test1/
|   ├── screenshot_0.png
|   ├── screenshot_1.png
|   └── screenshot_2.png
├── test2/
|   └── screenshot_1.png
└── test3/
    └── screenshot_2.png
@jamescryer
Copy link

This could be a bug.

Could you try setting comparisonResultRoot as well.

  screenshotRoot: fs.absolute(fs.workingDirectory + '/screenshots/test3'),
  comparisonResultRoot: fs.absolute(fs.workingDirectory + '/screenshots/test3'),
  failedComparisonsRoot: fs.absolute(fs.workingDirectory + '/failures/test3'),

@chris-dura
Copy link
Contributor Author

Could you try setting comparisonResultRoot as well.

That did it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants