Changelog
v3.0.0 (2023-06-21)
This major update includes two breaking changes:
Other changes include:
print
dialog with the native dialog handler.TestCafe v2.5.0 introduced an experimental mode that allows users to automate Chromium-based browsers, such as Google Chrome and Microsoft Edge, with the native CDP protocol. TestCafe v3.0.0 and up enables this capability out of the box.
Native automation increases test quality, stability, and speed.
You can now access the following data in fixture hooks (fixture.before
, fixture.after
) :
Test hooks (fixture.beforeEach
, fixture.afterEach
, test.before
, test.after
) can access fixture data and the following test data:
fixture `Example Fixture`
.page `http://example.com`
.meta({ fixtureMeta: 'v' })
.before( async (ctx, info) => {
const fixtureName = info.name; /* Example Fixture */
const fixtureMeta = info.meta; /* { fixtureMeta: 'v' } */
const fixturePath = info.path /* /Users/dan/testcafe/fixture.js */
});
.beforeEach( async t => {
const fixtureName = t.fixture.name; /* Example Fixture */
const fixtureMeta = t.fixture.meta; /* { fixtureMeta: 'v' } */
const fixturePath = t.fixture.path /* /Users/dan/testcafe/fixture.js */
const testName = t.test.name; /* MyTest */
const testMeta = t.test.meta; /* { 'key': 'value' } */
})
Read the Hooks guide for more information.
You can now use the t.setNativeDialogHandler method to dismiss the print dialog.
TestCafe v3.0.0 removes support for Internet Explorer 11, six months after the browser's official retirement. The browser came out more than 9 years ago, and has a worldwide market of less than 0.5%. It is survived by Edge, a popular Chromium-based browser that ships with modern versions of Windows.
Changelog
v2.6.1 (2023-05-29)
TestCafe v2.6.1 retires Experimental Debug mode, and introduces a number of important bug fixes.
TestCafe v1.18.0 introduced Experimental Debug mode --- a way to debug Selectors and Client Functions in the text editor. TestCafe v2.4.0 shipped with the Visual Selector Debugger, which allows users to troubleshoot Selector queries directly in the browser.
The two capabilities serve the same purpose, but the Visual Selector Debugger is more user-friendly. As such, beginning with TestCafe v2.6.1, the framework no longer includes Experimental Debug mode. Thank you to all the TestCafe users who tried out the capability.
Changelog
v2.6.0 (2023-05-11)
TestCafe v2.6.0 introduces two enhancements: a new hook that allows users to modify reporter output, and support for JavaScript configuration files with the .cjs
extension.
The onBeforeWrite hook allows you to modify the output of a reporter.
If you want your test reports to include custom content, you can create a custom reporter from scratch. However, this approach takes time and effort. Use the onBeforeWrite
hook if you want to make minor changes to the output of an existing reporter.
Define an onBeforeWrite
hook in a JavaScript configuration file. The following hook adds the duration in milliseconds to every test entry in the report:
//.testcaferc.js or .testcaferc.cjs
function onBeforeWriteHook(writeInfo) { // This function will fire every time the reporter calls the "write" method.
if (writeInfo.initiator === 'reportTestDone') { // The "initiator" property contains the name of the reporter event that triggered the hook.
const {
name,
testRunInfo,
meta
} = writeInfo.data || {}; // If you attached this hook to a compatible reporter (such as "spec" or "list"), the hook can process data related to the event.
const testDuration = testRunInfo.durationMs; // Save the duration of the test.
writeInfo.formattedText = writeInfo.formattedText + ' (' + testDuration + 'ms)'; // Add test duration to the reporter output.
};
}
module.exports = { // Attach the hook
hooks: {
reporter: {
onBeforeWrite: {
'spec': onBeforeWriteHook, // This hook will fire when you use the default "spec" reporter.
},
},
},
};
If you run TestCafe v2.6.0 and higher, you can now use a configuration file with the .cjs
file extension. TestCafe detects the .testcaferc.cjs
file on startup, alongside its .js
and .json
counterparts.
TestCafe configuration files only support CommonJS syntax. Meanwhile, modern JavaScript tools often default to ESM syntax. If a JavaScript project is of type module
, Node.js expects the project's .js
files to contain ESM syntax.
Use the .cjs
configuration file extension to let Node.js know that the file contains CommonJS syntax.
Many thanks to the TestCafe contributor Damien Guérin (@gigaga) for the implementation of this capability.
t.skipJsErrors
method without arguments, TestCafe passes a false
value to the method. This behavior is inconsistent with similar methods of a greater scope --- test.skipJsErrors
and fixture.skipJsErrors
(#7648).Error
(#7627).t.pressKey
action in Mozilla Firefox. Attempts to press the "backspace" key and the "tab" key, among others, may fail. (#7623)t.request
method. (#7609)