Today, I was attempting to debug an issue where some of our functional tests were not running with the new React powered parts of WordPress.com.

As part of the debugging process, I decided to see if the tests would pass when run from my local machine instead of our test server. But, any time I ran a test, the test would fail.

madComputer

An Example Test

Here is part of the test that we use to test the log-in/log-out functionality on WordPress.com

casper.test.begin( 'Can log in to WordPress', function suite( test ) {
    casper.start( 'https://wordpress.com/', function() {
        test.assertExists( '.click-wpcom-login', 'Login link exists on front page when logged out' );
    } );

    casper.run ( function() {
        test.done();
    } );
} );

But, when I run this test, this is the output that I get:

# Can log in to WordPress
FAIL Login link exists on front page when logged out
#    type: assertExists
#    file: logging-in-out.js:3
#    code: test.assertExists( '.click-wpcom-login', 'Login link exists on front page when logged out' );
#    subject: false
#    selector: ".click-wpcom-login"

To debug this test, I dumped the HTML to my terminal and got this: <html><head></head><body></body></html>

The Fix?

After searching a bit, I found this answer.

It seems that there was a mismatch between the version of TLS that WordPress.com uses and the version that PhantomJS uses.

I was able to get my test to work by changing the command to: casperjs test --ssl-protocol=any logging-in-out.js

Leave a Reply