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

Duplicate screenshots #110

@chris-dura

Description

@chris-dura

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions