TestCafe v0.21.0 Release Notes

  • โœจ Enhancements

    โœ… :gear: Test Web Pages Served Over HTTPS (#1985)

    ๐Ÿ‘ท Some browser features (like Service Workers, Geolocation API, ApplePaySession, or SubtleCrypto) require a secure origin. This means that the website should use the HTTPS protocol.

    โœ… Starting with v0.21.0, TestCafe can serve proxied web pages over HTTPS. This allows you to test pages that require a secure origin.

    To enable HTTPS when you use TestCafe through the command line, specify the --ssl flag followed by the HTTPS server options. The most commonly used options are described in the TLS topic in the Node.js documentation.

    testcafe --ssl pfx=path/to/file.pfx;rejectUnauthorized=true;...
    

    ๐Ÿ“š When you use a programming API, pass the HTTPS server options to the createTestCafe method.

    'use strict';
    
    const createTestCafe        = require('testcafe');
    const selfSignedSertificate = require('openssl-self-signed-certificate');
    let runner                  = null;
    
    const sslOptions = {
        key:  selfSignedSertificate.key,
        cert: selfSignedSertificate.cert
    };
    
    createTestCafe('localhost', 1337, 1338, sslOptions)
        .then(testcafe => {
            runner = testcafe.createRunner();
        })
        .then(() => {
            return runner
                .src('test.js')
    
                // Browsers restrict self-signed certificate usage unless you
                // explicitly set a flag specific to each browser.
                // For Chrome, this is '--allow-insecure-localhost'.
                .browsers('chrome --allow-insecure-localhost')
                .run();
        });
    

    ๐Ÿ“š See Connect to TestCafe Server over HTTPS for more information.

    โœ… :gear: Construct Screenshot Paths with Patterns (#2152)

    ๐Ÿ“š You can include placeholders in the path, for example, ${DATE}, ${TIME}, ${USERAGENT}, etc. For a complete list, refer to Path Pattern Placeholders.

    โœ… You should specify a screenshot path pattern when you run tests. Each time TestCafe takes a screenshot, it substitutes the placeholders with actual values and saves the screenshot to the resulting path.

    ๐Ÿ’ป The following example shows how to specify a screenshot path pattern through the command line:

    testcafe all test.js -s path=screenshots,pathPattern=${DATE}_${TIME}/test-${TEST_INDEX}/${USERAGENT}/${FILE_INDEX}.png
    

    ๐Ÿ“š When you use a programming API, pass the screenshot path pattern to the runner.screenshots method.

    runner.screenshots({
        path: 'reports/screenshots/',
        takeOnFails: true,
        pathPattern: '${TEST_INDEX}/${OS}/${BROWSER}-v${BROWSER_VERSION}/${FILE_INDEX}.png'
    });
    

    โœ… :gear: Add Info About Screenshots and Quarantine Attempts to Custom Reports (#2216)

    โœ… Custom reporters can now access screenshots' data and the history of quarantine attempts (if the test run in the quarantine mode).

    The following information about screenshots is now available:

    • the path to the screenshot file,
    • the path to the thumbnail image,
    • ๐Ÿ’ป the browser's user agent,
    • the quarantine attempt number (if the screenshot was taken in the quarantine mode),
    • โœ… whether the screenshot was taken because the test failed.

    โœ… If the test was run in the quarantine mode, you can also determine which attempts failed and passed.

    ๐Ÿ“š Refer to the reportTestDone method description for details on how to access this information.

    ๐Ÿ› Bug Fixes

    • โœ… HTML5 drag events are no longer simulated if event.preventDefault is called for the mousedown event (#2529)
    • โœ… File upload no longer causes an exception when there are several file inputs on the page (#2642)
    • โœ… File upload now works with inputs that have the required attribute (#2509)
    • โœ… The load event listener is no longer triggered when added to an image (testcafe-hammerhead/#1688)