grunt-testcafe
v0.23.0
Published
Grunt testcafe plugin
Downloads
45
Readme
grunt-testcafe
Tests runner
Getting Started
This plugin requires Grunt 0.4 - 1
.
npm install grunt-testcafe --save-dev
One the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks("grunt-testcafe")
The "testcafe" task
Overview
In your project's Gruntfile, add a section named testcafe
to the data object passed into grunt.initConfig()
.
grunt.initConfig({
testcafe: {
test: {
options: {
files: ["tests/*.test.js"],
browsers: ["chrome"]
}
}
}
})
Advanced example:
grunt.initConfig({
testcafe: {
test: {
options: {
files: ["tests/*.test.js"],
browsers: ["firefox", "chrome"],
takeScreenshotsOnFail: true,
screenshotsPath: "tests/screenshots",
filter: (testName, fixtureName, fixturePath) => {
const testNameFilter = testName.match(
new RegExp(grunt.option("testName"))
)
const fixtureNameFilter = fixtureName.match(
new RegExp(grunt.option("fixtureName"))
)
const fixturePathFilter = fixturePath.match(
new RegExp(grunt.option("fixturePath"))
)
return (
testNameFilter && fixtureNameFilter && fixturePathFilter
)
}
}
}
}
})
Options
files
Type: Array
Default: []
Details: Configures the test runner to run tests from the specified files.
browsers
Type: Array
Default: []
Details: Specifying Browsers for Test Task
Configures the test runner to run tests in the specified browsers.
Required
concurrency
Type: Number
Default: 1
Details: Specifies that tests should run concurrently.
reporters
Type: Array
Default: ['spec']
Details: Reporters
Specifies the reporter. Output file can be passed along with reporter name by colon (:) separator. Examplereporters: ['json:report.json', 'xunit:report.xml']
filter
Type: function(testName, fixtureName, fixturePath)
Default: null
Details: runner.filter
Allows you to manually select which tests should be run.
screenshotsPath
Type: String
Default: null
Details: Screenshots path
The path to which the screenshots will be saved. Enables the test runner to take screenshots of the tested webpages.
screenshotsPathPattern
Type: String
Default: null
Details: Screenshots path pattern
Specifies a custom pattern to compose screenshot files' relative path and name. This pattern overrides the default path pattern.
takeScreenshotsOnFail
Type: Boolean
Default: false
Details: Take screenshots on fail
Specifies if screenshots should be taken automatically whenever a test fails. Requires that the screenshotsPath is set.
skipJsErrors
Type: Boolean
Default: false
Details: Skip JS errors
Defines whether to continue running a test after a JavaScript error occurs on a page (true
), or consider such a test failed (false
).
quarantineMode
Type: Boolean
Default: false
Defines whether to enable the quarantine mode.
selectorTimeout
Type: Number
Default: 10000
Details: Selector timeout
Specifies the amount of time, in milliseconds, within which selectors make attempts to obtain a node to be returned.
assertionTimeout
Type: Number
Default: 3000
Details: Assertion options
Specifies the amount of time, in milliseconds, within which TestCafe makes attempts to successfully execute an assertion if a selector property or a client function was passed as an actual value.
speed
Type: Number
Default: 1
Details : Speed factor
Specifies the speed of test execution. Should be a number between 1
(the fastest) and 0.01
(the slowest).
startApp
Type: Object { command, initDelay }
Default: { initDelay: 1000 }
Details : startApp
Specifies a shell command that will be executed before running tests. Use it to launch or deploy the application that will be tested.
proxyHost
Type: String
Default: null
Details : proxy
Specifies the proxy server used in your local network to access the Internet. You can also specify authentication credentials with the proxy host.