HuddleEng / PhantomCSS

Visual/CSS regression testing with PhantomJS
MIT License
4.72k stars 259 forks source link

Says test failed, but failure folder is not created. #180

Closed nimishseraphim closed 7 years ago

nimishseraphim commented 7 years ago

I have problem with very basic test. Below is my test. When I run first time, it creates baseline screenshot under "screenshots" folder. When I run the test second time, it creates the diff screenshot under "screenshots" folder, but I see message that test failed and "PhantomCSS has created some images that try to show the difference (in the directory /Users/i849020/PhantomCSS/demo/failures).......".

But actually there is no "failures" screenshot created and even the baseline screenshot and diff screenshots are exactly same.

Test is below. I have casperjs version 1.1.3 using phantomjs version 2.0.0.

/ Require and initialise PhantomCSS module Paths are relative to CasperJs directory /

var fs = require( 'fs' ); var path = fs.absolute( fs.workingDirectory + '/phantomcss.js' ); var phantomcss = require( path ); var server = require('webserver').create(); var html = fs.read( fs.absolute( fs.workingDirectory + '/demo/coffeemachine.html' ));

casper.test.begin( 'Twitter visual tests', function ( test ) {

phantomcss.init( {
    rebase: casper.cli.get( "rebase" ),
    // SlimerJS needs explicit knowledge of this Casper, and lots of absolute paths
    casper: casper,
    libraryRoot: fs.absolute( fs.workingDirectory + '' ),
    screenshotRoot: fs.absolute( fs.workingDirectory + '/screenshots' ),
    failedComparisonsRoot: fs.absolute( fs.workingDirectory + '/demo/failures' ),
    addLabelToFailedImage: false,

} );

casper.on( 'remote.message', function ( msg ) {
    this.echo( msg );
} );

casper.on( 'error', function ( err ) {
    this.die( "PhantomJS has errored: " + err );
} );

casper.on( 'resource.error', function ( err ) {
    casper.log( 'Resource load error: ' + err, 'warning' );
} );
/*
    The test scenario
*/

casper.start('https://twitter.com/#!/n1k0');

casper.viewport( 1024, 768 );

casper.then( function () {

    // wait for modal to fade-in
    casper.waitForSelector( '.ProfileAvatar-image',
        function success() {
             phantomcss.screenshot('html', 'twitter image' );
        },
        function timeout() {
            casper.test.fail( 'Should see twitter screen' );
        }
    );
} );

casper.then( function now_check_the_screenshots() {
    // compare screenshots
    phantomcss.compareAll();
} );

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

} );

nimishseraphim commented 7 years ago

found that it has problem with phantomjs 2.0 Closing.