Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
prodperfect-testcafe
Advanced tools
Changelog
v1.0.0 (2019-2-7)
Previous versions performed test syntax validation within input script files before executing them. Only files that contained the fixture and test directives were executed.
Starting with v1.0.0, input script files are never validated. This means that TestCafe executes all the scripts you specify as test sources. If you use Glob patterns to specify input test files, please recheck these patterns to avoid unintended file matches.
The --disable-test-syntax-validation
command line flag and the disableTestSyntaxValidation
option for the runner.run API method that disabled test syntax validation were removed in v1.0.0.
You can now load tests dynamically without additional customization. The following example illustrates how tests can be imported from an external library.
external-lib.js
export default function runFixture(name, url) {
fixture(name)
.page(url);
test(`${url} test`, async t => {
// ...
});
}
test.js
import runFixture from './external-lib';
const fixtureName = 'My fixture';
const url = 'https://testPage';
runFixture(fixtureName, url);
Previous versions allowed you to call the runner.src, runner.browsers and runner.reporter methods several times to specify multiple test files, browsers or reporters.
const stream = fs.createWriteStream('report.json');
runner
.src('/home/user/tests/fixture1.js')
.src('fixture5.js')
.browsers('chrome')
.browsers('firefox:headless')
.reporter('minimal')
.reporter('json', stream);
Starting with v1.0.0, pass arrays to these methods to specify multiple values.
To use a reporter that writes to a file, add a { name, output }
object to an array (see the runner.reporter description for details).
runner
.src(['/home/user/tests/fixture1.js', 'fixture5.js'])
.browsers(['chrome', 'firefox:headless'])
.reporter(['minimal', { name: 'json', output: 'report.json' }]);
This change was necessary to implement the configuration file in a way that is consistent with the API and command line interface.
Request hook methods became asynchronous in TestCafe v1.0.0.
If the onRequest or onResponse method in your custom hook returns a Promise, TestCafe now waits for this Promise to resolve.
This does not necessarily leads to unexpected behavior, but still be aware of possible side effects.
Since the onRequest and onResponse methods are now asynchronous, add the async
keyword to their declarations.
import { RequestHook } from 'testcafe';
class MyRequestHook extends RequestHook {
constructor (requestFilterRules, responseEventConfigureOpts) {
super(requestFilterRules, responseEventConfigureOpts);
// ...
}
async onRequest (event) {
// ...
}
async onResponse (event) {
// ...
}
}
You can call asynchronous fs functions, invoke a child_process, or perform asynchronous network requests (to a database or any other server) from inside the hooks.
TestCafe v1.0.0 also introduces asynchronous API for reporter plugins.
Similarly to request hooks, if any of the custom reporter's methods (reportTaskStart, reportFixtureStart, reportTestDone or reportTaskDone) returns a Promise, this Promise is now awaited.
Side effects may show up in certain cases.
Since the reporter methods are now asynchronous, add the async
keyword to their declarations.
async reportTaskStart (startTime, userAgents, testCount) {
// ...
},
async reportFixtureStart (name, path, meta) {
// ...
},
async reportTestDone (name, testRunInfo, meta) {
// ...
},
async reportTaskDone (endTime, passed, warnings, result) {
// ...
}
Reporters can call asynchronous fs functions, invoke a child_process, or perform asynchronous network requests (to send an email, use REST API, connect to a database, etc).
Readme
A Node.js tool to automate end-to-end web testing.
Write tests in JS or TypeScript, run them and view results.
https://devexpress.github.io/testcafe
npm install -g testcafe
Running a sample test in Safari
Stable tests and no manual timeouts
TestCafe automatically waits for page loads and XHRs before the test starts and after each action.
It also features smart test actions and assertions that wait for page elements to appear.
You can change the maximum wait time.
If elements load faster, tests skip the timeout and continue.
Rapid test development tool
Changes in test code immediately restart the test, and you see the results instantly.
See how it works in the TestCafe Live repository.
Latest JS and TypeScript support
TestCafe supports the latest JavaScript features, including ES2017 (for example, async/await).
You can also use TypeScript
if you prefer a strongly typed language.
Detects JS errors in your code
TestCafe reports JS errors that it finds on the webpage.
Tests automatically fail because of that.
However, you can disable this.
Concurrent tests launch
TestCafe can open multiple instances of the same browser to run parallel
tests which decreases test execution time.
PageObject pattern support
The TestCafe's Test API
includes a high-level selector library, assertions, etc.
You can combine them to implement readable tests with the PageObject pattern.
const macOSInput = Selector('.column').find('label').withText('MacOS').child('input');
Easy to include in a continuous integration system
You can run TestCafe from a console, and its reports can be viewed in a CI system's interface
(TeamCity, Jenkins, Travis & etc.)
Ensure that Node.js (version 4 or newer) and npm are installed on your computer before running it:
npm install -g testcafe
As an example, we are going to test the https://devexpress.github.io/testcafe/example page.
Create a .js
or .ts
file on your computer.
Note that it needs to have a specific structure: tests must be organized into fixtures.
You can paste the following code to see the test in action:
import { Selector } from 'testcafe'; // first import testcafe selectors
fixture `Getting Started`// declare the fixture
.page `https://devexpress.github.io/testcafe/example`; // specify the start page
//then create a test and place your code there
test('My first test', async t => {
await t
.typeText('#developer-name', 'John Smith')
.click('#submit-button')
// Use the assertion to check if the actual header text is equal to the expected one
.expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');
});
Call the following command in a command shell. Specify the target browser and file path.
testcafe chrome test1.js
TestCafe opens the browser and starts executing the test.
Important! Make sure to stay in the browser tab that is running tests. Do not minimize the browser window. Tests are not guaranteed to execute correctly in inactive tabs and minimized browser windows because they switch to a lower resource consumption mode.
TestCafe outputs the results into a command shell by default. See Reporters for more information. You can also use plugins to customize the reports.
Read the Getting Started page for a more detailed guide.
Go to our website for full documentation on TestCafe.
Follow us on Twitter. We post TestCafe news and updates, several times a week.
Show everyone you are using TestCafe:
To display this badge, add the following code to your repository readme:
<a href="https://github.com/DevExpress/testcafe">
<img alt="Tested with TestCafe" src="https://img.shields.io/badge/tested%20with-TestCafe-2fa4cf.svg">
</a>
Report bugs and request features on our issues page.
Ask and answer questions on StackOverflow. We review and answer questions with the TestCafe tag.
For more information on how to help us improve TestCafe, see the CONTRIBUTING.md.
You can use these plugin generators to create your own plugins:
If you want your plugin to be listed below, send us a note in a Github issue.
TestCafe developers and community members made these plugins:
Rapid test development tool
Changes in test code immediately restart the test, and you see the results instantly.
Browser Providers
Allow you to use TestCafe with cloud browser providers and emulators.
Framework-Specific Selectors
Work with page elements in a way that is native to your framework.
Plugins for Task Runners
Integrate TestCafe into your project's workflow.
Custom Reporters
View test results in different formats.
Test Accessibility
Find accessibility issues in your web app.
IDE Plugins
Run tests and view results from your favorite IDE.
ESLint
Use ESLint when writing and editing TestCafe tests.
We are grateful to BrowserStack for providing the infrastructure that we use to test code in this repository.
Code released under the MIT license.
Developer Express Inc. (https://devexpress.com)
FAQs
A fork of TestCafe that adds in screenshot recording after every action
The npm package prodperfect-testcafe receives a total of 8 weekly downloads. As such, prodperfect-testcafe popularity was classified as not popular.
We found that prodperfect-testcafe demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.