TestCafe v3.1.0 Released
TestCafe v3.1.0 introduces two enhancements:
- You can now respond to geolocation requests with the
t.setNativeDialogHandler
method. - Your tests and test reports can now reference a variable that stores the framework’s version number.
Respond to geolocation requests
Main article: t.setNativeDialogHandler
Use the t.setNativeDialogHandler
method to respond to geolocation
requests.
- Return an
Error
type object to Block geolocation requests. - Return an object with coordinates to trigger the
success
callback of the getCurrentPosition method.
// Test
test('Switch from "allow" to "block"', async t => {
await t
.setNativeDialogHandler((type) => {
if (type === 'geolocation')
return { timestamp: 12356, accuracy: 20, coords: {latitude: '34.15321262322903', longitude: '-118.25543996370723'}; // Passes this data to geolocation requests
return null;
});
.click('#buttonGeo')
.setNativeDialogHandler((type) => {
if (type !== 'geolocation')
return null;
const err = new Error('Some error');
err.code = 1;
return err; // Blocks geolocation requests
})
.click('#buttonGeo');
Reference the framework’s version in tests and test reports
Main article: Version Logger API
Earlier versions of TestCafe could output the framework’s version number to the console:
TestCafe 3.1.0 and up allows you to access the framework’s version number in test code:
import { version } from 'testcafe';
console.log(`TestCafe version: ${version}`);
To access the framework’s version number in your custom reporter, reference the first argument (version
) of the init
method:
init (version) {
this
.write(`Using TestCafe ${version}`)
.newline()
}
Bug fixes
- TestCafe incorrectly reports test duration in concurrency mode (#1816).
- TestCafe assigns a non-zero duration value to skipped tests, which leads to an unexpected increase in the total test run duration value (#7731).
- [Native Automation] The
setFileUpload
method does not work (#7832). - [Native Automation] Request hooks cause tests to crash (#7846).
- [Native Automation] TestCafe overrides page titles (#7833).
- [Native Automation] If a website redirects the user to a new page before basic HTTP authentication is complete, the authentication process fails (#7852).
- [Native Automation] The
t.click
action fails if the event handler accounts for pointer input pressure (#7867). - [Native Automation] TestCafe hangs when the browser yields a “Session with given ID not found” error (#7865,#7810).
- [Native Automation] TestCafe cannot set the
httpOnly
flag when you use thet.setCookies
method (#7793).