TestCafe

A Node.js tool to automate end-to-end web testing.

README

2022 TestCafe Feedback Survey

testcafe

TestsTest DependenciesNPM Version

A Node.js tool to automate end-to-end web testing.
Write tests in JS or TypeScript, run them and view results.

Homepage   •   Documentation   •   FAQ   •   Support


Works on all popular environments: TestCafe runs on Windows, MacOS, and Linux. It supports desktop, mobile, remote and cloud browsers (UI or headless).
1 minute to set up: You do not need WebDriver or any other testing software. Install TestCafe with one command, and you are ready to test:npm install -g testcafe
Free and open source: TestCafe is free to use under the MIT license. Plugins provide custom reports, integration with other tools, launching tests from IDE, etc. You can use the plugins made by the GitHub community or make your own.

Install TestCafe and Run a Test

Running a sample test in Safari


Table of contents



Features


**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 test 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.

  1. ``` js
  2. const macOSInput = Selector('.column').find('label').withText('MacOS').child('input');
  3. ```

**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.)

TestCafe Studio: IDE for End-to-End Web Testing


TestCafe works great for JavaScript developers, but at some point you will need to delegate testing tasks to your Q&A department. If that's the case and you are looking for a codeless way to record and maintain tests compatible with your existing infrastructure, check out TestCafe Studio - a testing IDE built on top of the open-source TestCafe.

Read the following article to learn how TestCafe Studio could fit into your workflow: What's Better than TestCafe? TestCafe Studio.

Get Started with TestCafe Studio

Record and Run a Test in TestCafe Studio


Getting Started


Installation


Ensure that Node.js (Current or Active LTS is recommended, version 12 at minimum) and npm are installed on your computer before running it:

  1. ```sh
  2. npm install -g testcafe
  3. ```

Creating the Test


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:

  1. ``` js
  2. import { Selector } from 'testcafe'; // first import testcafe selectors

  3. fixture `Getting Started`// declare the fixture
  4.     .page `https://devexpress.github.io/testcafe/example`;  // specify the start page


  5. //then create a test and place your code there
  6. test('My first test', async t => {
  7.     await t
  8.         .typeText('#developer-name', 'John Smith')
  9.         .click('#submit-button')

  10.         // Use the assertion to check if the actual header text is equal to the expected one
  11.         .expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');
  12. });
  13. ```

Running the Test


Call the following command in a command shell.
Specify the target browser

  1. ```sh
  2. testcafe chrome test1.js
  3. ```

TestCafe opens the browser and starts executing the test.

Important! Make sure the browser tab that runs tests stays active.

Do not minimize the browser window. Inactive tabs and minimized browser windows switch

to a lower resource consumption mode where tests are not guaranteed to execute correctly.


Viewing the Results


TestCafe outputs the results into a command shell by default. See Reporters
for more information. You can also use plugins to customize the reports.

Test Report

Read the Getting Started page for a more detailed guide.

Documentation


Go to our website for full documentation on TestCafe.

Get Help


Join the TestCafe community on Stack Overflow to get help. Ask and answer questions with the TestCafe tag.

Issue Tracker


Use our GitHub issues page to report bugs and suggest improvements.

Stay in Touch


Follow us on Twitter. We post TestCafe news and updates, several times a week.

Contributing


Read our Contributing Guide to learn how to contribute to the project.

To create your own plugin for TestCafe, you can use these plugin generators:

  to set up tests on your on-premises server farm, to use a cloud testing platform, or to start your local browsers in a special way. Use this Yeoman generator to write only a few lines of code.
  with your formatting and style, check out this generator.

If you want your plugin to be listed below, send us a note in a Github issue.

Thank you to all the people who already contributed to TestCafe!

[aha-oretama](https://github.com/aha-oretama) |[ai](https://github.com/ai) |[aleks-pro](https://github.com/aleks-pro) |[Aleksey28](https://github.com/Aleksey28) |[AlexanderMoiseev](https://github.com/AlexanderMoiseev) |[AlexanderMoskovkin](https://github.com/AlexanderMoskovkin) |
:---: |:---: |:---: |:---: |:---: |:---: |

[alexey-lin](https://github.com/alexey-lin) |[AlexKamaev](https://github.com/AlexKamaev) |[alexphilin](https://github.com/alexphilin) |[AlexSkorkin](https://github.com/AlexSkorkin) |[alexwybraniec](https://github.com/alexwybraniec) |[AnastasiaIvanova8](https://github.com/AnastasiaIvanova8) |
:---: |:---: |:---: |:---: |:---: |:---: |

[andrewbranch](https://github.com/andrewbranch) |[AndreyBelym](https://github.com/AndreyBelym) |[AndyWendt](https://github.com/AndyWendt) |[AnnaKondratova](https://github.com/AnnaKondratova) |[anthophobiac](https://github.com/anthophobiac) |[Artem-Babich](https://github.com/Artem-Babich) |
:---: |:---: |:---: |:---: |:---: |:---: |

[Arthy000](https://github.com/Arthy000) |[augustomezencio-hotmart](https://github.com/augustomezencio-hotmart) |[bdwain](https://github.com/bdwain) |[benmonro](https://github.com/benmonro) |[beyondcompute](https://github.com/beyondcompute) |[bill-looby-i](https://github.com/bill-looby-i) |
:---: |:---: |:---: |:---: |:---: |:---: |

[bsmithb2](https://github.com/bsmithb2) |[caseyWebb](https://github.com/caseyWebb) |[cdrini](https://github.com/cdrini) |[cgfarmer4](https://github.com/cgfarmer4) |[Chris-Greaves](https://github.com/Chris-Greaves) |[churkin](https://github.com/churkin) |
:---: |:---: |:---: |:---: |:---: |:---: |

[dej611](https://github.com/dej611) |[DIRECTcut](https://github.com/DIRECTcut) |[Dmitry-Ostashev](https://github.com/Dmitry-Ostashev) |[eignatyev](https://github.com/eignatyev) |[ericyd](https://github.com/ericyd) |[Farfurix](https://github.com/Farfurix) |
:---: |:---: |:---: |:---: |:---: |:---: |

[flora8984461](https://github.com/flora8984461) |[GeoffreyBooth](https://github.com/GeoffreyBooth) |[helen-dikareva](https://github.com/helen-dikareva) |[honsq90](https://github.com/honsq90) |[infctr](https://github.com/infctr) |[inikulin](https://github.com/inikulin) |
:---: |:---: |:---: |:---: |:---: |:---: |

[Ivan-Katovich](https://github.com/Ivan-Katovich) |[jamesgeorge007](https://github.com/jamesgeorge007) |[jaypea](https://github.com/jaypea) |[josephmalam](https://github.com/josephmalam) |[kanhaiya15](https://github.com/kanhaiya15) |[karolnowinski](https://github.com/karolnowinski) |
:---: |:---: |:---: |:---: |:---: |:---: |

[kirovboris](https://github.com/kirovboris) |[kisrefod](https://github.com/kisrefod) |[LavrovArtem](https://github.com/LavrovArtem) |[link89](https://github.com/link89) |[lzxb](https://github.com/lzxb) |[macdonaldr93](https://github.com/macdonaldr93) |
:---: |:---: |:---: |:---: |:---: |:---: |

[MargaritaLoseva](https://github.com/MargaritaLoseva) |[Marketionist](https://github.com/Marketionist) |[MatthewNielsen27](https://github.com/MatthewNielsen27) |[mattkubej](https://github.com/mattkubej) |[mattmanske](https://github.com/mattmanske) |[mcjim](https://github.com/mcjim) |
:---: |:---: |:---: |:---: |:---: |:---: |

[miherlosev](https://github.com/miherlosev) |[morfey13](https://github.com/morfey13) |[mostlyfabulous](https://github.com/mostlyfabulous) |[murajun1978](https://github.com/murajun1978) |[NickCis](https://github.com/NickCis) |[Nuarat](https://github.com/Nuarat) |
:---: |:---: |:---: |:---: |:---: |:---: |

[Ogurecher](https://github.com/Ogurecher) |[PayBas](https://github.com/PayBas) |[pgorny](https://github.com/pgorny) |[pietrovich](https://github.com/pietrovich) |[radarhere](https://github.com/radarhere) |[raspo](https://github.com/raspo) |
:---: |:---: |:---: |:---: |:---: |:---: |

[rbardini](https://github.com/rbardini) |[renancouto](https://github.com/renancouto) |[rob4629](https://github.com/rob4629) |[rueyaa332266](https://github.com/rueyaa332266) |[sgrillon14](https://github.com/sgrillon14) |[smockle](https://github.com/smockle) |
:---: |:---: |:---: |:---: |:---: |:---: |

[stefanschenk](https://github.com/stefanschenk) |[superroma](https://github.com/superroma) |[sylbru](https://github.com/sylbru) |[taiki-fw](https://github.com/taiki-fw) |[testcafe-build-bot](https://github.com/testcafe-build-bot) |[theghostbel](https://github.com/theghostbel) |
:---: |:---: |:---: |:---: |:---: |:---: |

[titerman](https://github.com/titerman) |[tobiasbueschel](https://github.com/tobiasbueschel) |[varunkumar](https://github.com/varunkumar) |[VasilyStrelyaev](https://github.com/VasilyStrelyaev) |[vitalics](https://github.com/vitalics) |[Vla8islav](https://github.com/Vla8islav) |
:---: |:---: |:---: |:---: |:---: |:---: |

[wentwrong](https://github.com/wentwrong) |[b12031106](https://github.com/b12031106) |[danielroe](https://github.com/danielroe) |[danieltroger](https://github.com/danieltroger) |[DevSide](https://github.com/DevSide) |[intermike](https://github.com/intermike) |
:---: |:---: |:---: |:---: |:---: |:---: |

[kirillsalikhov](https://github.com/kirillsalikhov) |[michaelficarra](https://github.com/michaelficarra) |[rr13k](https://github.com/rr13k) |[tomashanacek](https://github.com/tomashanacek) |[TrevorKarjanis](https://github.com/TrevorKarjanis) |
:---: |:---: |:---: |:---: |:---: |

Plugins


TestCafe developers and community members made these plugins:

* **Browser Providers**
  Use TestCafe with cloud browser providers and emulators.

* **Framework-Specific Selectors**
  Work with page elements in a way that is native to your framework.
  Vue (by @miherlosev)

* **Plugins for Task Runners**
  Integrate TestCafe into your project's workflow.
  Grunt (by @crudo)
  Gulp (by @inikulin)

* **Custom Reporters**
  View test results in different formats.
  TeamCity (by @nirsky)
  Slack (by @Shafied)
  Tesults (by @Tesults)

* **GitHub Action**
  Run TestCafe tests in GitHub Actions workflows.

* **Test Accessibility**
  Find accessibility issues in your web app.

* **IDE Plugins**
  Run tests and view results from your favorite IDE.
  TestCafe Test Runner for Visual Studio Code (by @romanresh)
  TestLatte for Visual Studio Code (by @Selminha)

* **ESLint**
  Use ESLint when writing and editing TestCafe tests.

* **Cucumber Support**
  Create and run tests that use the Cucumber syntax.
  gherkin-testcafe (by @kiwigrid, now maintained by @Arthy000) - run your Cucumber tests with TestCafe as a backend. Requires CucumberJS.
  testcafe-cucumber-steps (by @Marketionist) - provides predefined Cucumber steps for gherkin-testcafe.

Different Versions of TestCafe


 [TestCafe](https://testcafe.io)[TestCafe
------|:-------------------------------------------------:|:-----------------------------------------------------------------------:|
No
Cross-platform
Write
Clear
Stable
Tests
Custom
Use
Integration ✓\*
Free 
[Visual 
[Interactive 
[Automatic 
[Run 
[IDE-like 

\* You can use open-source TestCafe to run TestCafe Studio tests in CI systems.

Badge


Show everyone you are using TestCafe: Tested with TestCafe

To display this badge, add the following code to your repository readme:

  1. ``` html
  2. <a href="https://github.com/DevExpress/testcafe">
  3.     <img alt="Tested with TestCafe" src="https://img.shields.io/badge/tested%20with-TestCafe-2fa4cf.svg">
  4. </a>
  5. ```

Thanks to BrowserStack


We are grateful to BrowserStack for providing the infrastructure that we use to test code in this repository.

BrowserStack Logo

License


Code released under the MIT license.

Creators


Developer Express Inc. (https://devexpress.com)