Giter VIP home page Giter VIP logo

devexpress / testcafe Goto Github PK

View Code? Open in Web Editor NEW
9.7K 168.0 661.0 129.81 MB

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

Home Page: https://testcafe.io

License: MIT License

JavaScript 73.85% HTML 5.93% Shell 0.01% TypeScript 19.47% Dockerfile 0.02% CoffeeScript 0.06% Less 0.46% Mustache 0.20%
testcafe end-to-end-testing test-automation test-framework functional-testing e2e testing-tools test browser typescript

testcafe's Introduction

Try TestCafe Studio IDE

testcafe

Tests Test Dependencies NPM Version

Automate end-to-end web testing with TestCafe, a Node.js-based testing framework.

TestCafe is free and as easy to use as 1-2-3:
1. Write your tests in JS or TypeScript.
2. Execute your tests.
3. View test 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 create 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
When you enable live mode, changes to test code immediately restart the test, and you instantly see the results.

Latest JS and TypeScript support
TestCafe supports the most recent JavaScript-related features, including ES2017 (async/await). You can also use TypeScript if you prefer a strongly typed language instead.

Detects JS errors in your code
TestCafe reports JS errors that it locates on a given webpage. Tests automatically fail if TestCafe encounters such errors.
You can, however, disable this option.

Concurrent test launch
TestCafe can open multiple instances of the same browser and run parallel tests (to help decrease 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 within CI systems (TeamCity, Jenkins, Travis & etc.)

Love TestCafe Open-source Edition? Want to Record Tests without Writing JavaScript or TypeScript Code?

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

TestCafe is the perfect choice for JavaScript developers and experienced Q&A teams. If you’d like to delegate testing to QA engineers and are looking for a code-free way to record and maintain tests compatible with your existing infrastructure, check out TestCafe Studio - a testing IDE built atop the open-source version of TestCafe.

Review the following article to learn how TestCafe Studio can fit into any 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 you run Node.js version 16 or higher, and run the following command:

npm install -g testcafe

Creating the Test

For this simple example, we will test the following page: https://devexpress.github.io/testcafe/example

Create a .js or .ts file on your computer. Remember that a .js or .ts file must maintain 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 within it
test('My first test', async t => {
    await t
        .typeText('#developer-name', 'John Smith')
        .click('#submit-button')

        // Use the assertion to check if actual header text equals expected text
        .expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');
});

Running the Test

Call the following command in a command shell. Specify the target browser and file path.

testcafe chrome test1.js

TestCafe opens the browser and begins test execution.

Important: Make certain the browser tab that runs tests stays active. Do not minimize the browser window. Inactive tabs and minimized browser windows switch to lower resource consumption mode. In low consumption mode, tests may not execute correctly.

Viewing the Results

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

Test Report

Read the Getting Started page for additional assistance.

Documentation

Visit the following webpage to review our online help system: Documentation.

Get Help

Join the TestCafe community on Stack Overflow. Ask and answer questions using the TestCafe tag.

Issue Tracker

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

Stay in Touch

Follow us on Twitter. We post TestCafe news and updates.

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:

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

Thanks to all of our contributors – We appreciate your commitment to the TestCafe community.

aha-oretama ai aleks-pro Aleksey28 AlexanderMoiseev AlexanderMoskovkin
aha-oretama ai aleks-pro Aleksey28 AlexanderMoiseev AlexanderMoskovkin
alexey-lin AlexKamaev alexphilin AlexSkorkin alexwybraniec AnastasiaIvanova8
alexey-lin AlexKamaev alexphilin AlexSkorkin alexwybraniec AnastasiaIvanova8
andrewbranch AndreyBelym AndyWendt AnnaKondratova anthophobiac Artem-Babich
andrewbranch AndreyBelym AndyWendt AnnaKondratova anthophobiac Artem-Babich
Arthy000 augustomezencio-hotmart bdwain benmonro beyondcompute bill-looby-i
Arthy000 augustomezencio-hotmart bdwain benmonro beyondcompute bill-looby-i
bsmithb2 caseyWebb cdrini cgfarmer4 Chris-Greaves churkin
bsmithb2 caseyWebb cdrini cgfarmer4 Chris-Greaves churkin
dej611 DIRECTcut Dmitry-Ostashev eignatyev ericyd Farfurix
dej611 DIRECTcut Dmitry-Ostashev eignatyev ericyd Farfurix
flora8984461 GeoffreyBooth helen-dikareva honsq90 infctr inikulin
flora8984461 GeoffreyBooth helen-dikareva honsq90 infctr inikulin
Ivan-Katovich jamesgeorge007 jaypea josephmalam kanhaiya15 karolnowinski
Ivan-Katovich jamesgeorge007 jaypea josephmalam kanhaiya15 karolnowinski
kirovboris kisrefod LavrovArtem link89 lzxb macdonaldr93
kirovboris kisrefod LavrovArtem link89 lzxb macdonaldr93
MargaritaLoseva Marketionist MatthewNielsen27 mattkubej mattmanske mcjim
MargaritaLoseva Marketionist MatthewNielsen27 mattkubej mattmanske mcjim
miherlosev morfey13 mostlyfabulous murajun1978 NickCis Nuarat
miherlosev morfey13 mostlyfabulous murajun1978 NickCis Nuarat
Ogurecher PayBas pgorny pietrovich radarhere raspo
Ogurecher PayBas pgorny pietrovich radarhere raspo
rbardini renancouto rob4629 rueyaa332266 sgrillon14 smockle
rbardini renancouto rob4629 rueyaa332266 sgrillon14 smockle
stefanschenk superroma sylbru taiki-fw testcafe-build-bot theghostbel
stefanschenk superroma sylbru taiki-fw testcafe-build-bot theghostbel
titerman tobiasbueschel varunkumar VasilyStrelyaev vitalics Vla8islav
titerman tobiasbueschel varunkumar VasilyStrelyaev vitalics Vla8islav
wentwrong b12031106 danielroe danieltroger DevSide intermike
wentwrong b12031106 danielroe danieltroger DevSide intermike
kirillsalikhov michaelficarra rr13k tomashanacek TrevorKarjanis
kirillsalikhov michaelficarra rr13k tomashanacek TrevorKarjanis

Plugins

TestCafe developers and community members made these plugins:

Different Versions of TestCafe

  TestCafe TestCafe Studio
No need for WebDriver, browser plugins or other tools
Cross-platform and cross-browser out of the box
Write tests in the latest JavaScript or TypeScript
Clear and flexible API supports ES6 and PageModel pattern
Stable tests due to the Smart Assertion Query Mechanism
Tests run fast due to intelligent Automatic Waiting Mechanism and Concurrent Test Execution
Custom reporter plugins
Use third-party Node.js modules in test scripts
Integration with popular CI systems  ✓*
Free and open-source  
Visual Test Recorder  
Interactive Test Editor  
Automatic Selector Generation  
Run Configuration Manager  
IDE-like GUI  

* 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:

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

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)

testcafe's People

Contributors

aleks-pro avatar aleksey28 avatar alexandermoskovkin avatar alexkamaev avatar alexskorkin avatar andreybelym avatar annakondratova avatar artem-babich avatar bayheck avatar benmonro avatar churkin avatar dependabot[bot] avatar directcut avatar dmitry-ostashev avatar farfurix avatar felis2803 avatar greenkeeperio-bot avatar helen-dikareva avatar inikulin avatar kirovboris avatar lavrovartem avatar margaritaloseva avatar marketionist avatar miherlosev avatar nuarat avatar ogurecher avatar pavelmor25 avatar titerman avatar vasilystrelyaev avatar wentwrong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

testcafe's Issues

Incorrect runner behavior when tests list is empty

  1. runner.src([]).run() - should not open a browser until all tests are not compiled. Because if compilation fails we end up with the hanging open local browser connections.
  2. runner.src(someTests).filter(()=>false).run() - runner crashes with a js error now

Review rules after upgrading eslint to 1.x

From Migrating to 1.0.0:
The most important difference in v1.0.0 is that all rules are off by default. When using --init, your configuration file will automatically include the following line:

{
    "extends": "eslint:recommended"
}

This setting mimics some of the default behavior from 0.x, but not all.
These rules are no longer on by default, so you should review your settings to ensure they are still as you expect:
no-alert
no-array-constructor
no-caller
no-catch-shadow
no-empty-label
no-eval
no-extend-native
no-extra-bind
no-extra-strict
no-implied-eval
no-iterator
no-label-var
no-labels
no-lone-blocks
no-loop-func
no-multi-spaces
no-multi-str
no-native-reassign
no-new
no-new-func
no-new-object
no-new-wrappers
no-octal-escape
no-process-exit
no-proto
no-return-assign
no-script-url
no-sequences
no-shadow
no-shadow-restricted-names
no-spaced-func
no-trailing-spaces
no-undef-init
no-underscore-dangle
no-unused-expressions
no-use-before-define
no-with
no-wrap-func
camelcase
comma-spacing
consistent-return
curly
dot-notation
eol-last
eqeqeq
key-spacing
new-cap
new-parens
quotes
semi
semi-spacing
space-infix-ops
space-return-throw-case
space-unary-ops
strict
yoda
See also: the full diff where the defaults were changed.

List of recommended rules:
comma-dangle - disallow or enforce trailing commas (recommended)
no-cond-assign - disallow assignment in conditional expressions (recommended)
no-console - disallow use of console in the node environment (recommended)
no-constant-condition - disallow use of constant expressions in conditions (recommended)
no-control-regex - disallow control characters in regular expressions (recommended)
no-debugger - disallow use of debugger (recommended)
no-dupe-args - disallow duplicate arguments in functions (recommended)
no-dupe-keys - disallow duplicate keys when creating object literals (recommended)
no-duplicate-case - disallow a duplicate case label. (recommended)
no-empty-character-class - disallow the use of empty character classes in regular expressions (recommended)
no-empty - disallow empty statements (recommended)
no-ex-assign - disallow assigning to the exception in a catch block (recommended)
no-extra-boolean-cast - disallow double-negation boolean casts in a boolean context (recommended)
no-extra-semi - disallow unnecessary semicolons (recommended)
no-func-assign - disallow overwriting functions written as function declarations (recommended)
no-inner-declarations - disallow function or variable declarations in nested blocks (recommended)
no-invalid-regexp - disallow invalid regular expression strings in the RegExp constructor (recommended)
no-irregular-whitespace - disallow irregular whitespace outside of strings and comments (recommended)
no-negated-in-lhs - disallow negation of the left operand of an in expression (recommended)
no-obj-calls - disallow the use of object properties of the global object (Math and JSON) as functions (recommended)
no-regex-spaces - disallow multiple spaces in a regular expression literal (recommended)
no-sparse-arrays - disallow sparse arrays (recommended)
no-unreachable - disallow unreachable statements after a return, throw, continue, or break statement (recommended)
use-isnan - disallow comparisons with the value NaN (recommended)
valid-typeof - Ensure that the results of typeof are compared against a valid string (recommended)
no-fallthrough - disallow fallthrough of case statements (recommended)
no-octal - disallow use of octal literals (recommended)
no-redeclare - disallow declaring the same variable more than once (recommended)
no-delete-var - disallow deletion of variables (recommended)
no-undef - disallow use of undeclared variables unless mentioned in a /*global */ block (recommended)
no-unused-vars - disallow declaration of variables that are not used in the code (recommended)
no-mixed-spaces-and-tabs - disallow mixed spaces and tabs for indentation (recommended)

We need to review .eslintrc for inheriting default rules and manually adding rules that were excluded from defaults (e.g. no-undef, semi and so).

Don't escape step code strings

AFAIK we need this only for the Studio, so let pass this functionality to the decorators (and don't do it in the default decorators
escape
)

Implement tty-dectorator for test errors, plug-in decorators and formatter into reporters

  • We should pass user-provided errorDecorator to the format, currently it's called formatter in the runner and reporter
  • If decorator is not provided fallback to the tty or plain-text decorators (depends on the type of the output stream)
  • Put decorators into the decorators dir in the sources
  • Consider moving src/test-error content to the src/reporters/errors
  • Rename src/test-error/index.js to the src/reporters/errors/format.js
  • Test error diffs and viewportWidth since we have a wordwrap for text (https://github.com/superroma/testcafe-phoenix/blob/master/src/reporters/base.js#L140). Seems like we will need more complicated logic for the errors to consider indents.

Support the 'release' issue

Build bot should recognize the issue with a special 'release' title and create a comment in the issue with list of issues closed after the last release and the guide 'what you should do before release'

Tests requires cache doesn't work properly

When several test files from the runner.src(files) argument require the same file, Compiler reads this file for each test file (but should read it once, save it to the cache and then read from the cache).
It occurs because of Compiler process all files in parallel.

Create gulp-publish task

The task should build sources before publishing and ensure that the NPM user is logged as devexpress. Then it should execute npm publish. It can perform additional checks, e.g. what CHANGELOG is updated, latest travis build is passing, etc.

Get rid of jQuery in scripts

  • Get rid of util jquery functions using
  • Get rid of jquery using for create, select and manipulate with dom-elements
  • Get rid of jquery binding for 'ready' and 'load' events
  • Get rid of jquery

We need to rethink client (once again)

There are couple of things I don't like in our client right now and which we should rethink before new API implementation:

  • Create concept of autowait which will include current action-barrier code, page loads etc. and make it optional
  • I don't understand current responsibilities of the client/runner/runner.js, currently it looks like a god-object and existence of the test-iterator makes whole thing more complicated. We need new and more clear runner structure
  • Action descriptor concept in automations is too complicated and I already forgot why we need this. We need clean API for the automations, we need to refactor them as well.

Refactor client scripts (move scripts to ES6)

  1. Linting (scripts and tests)
  2. Constants (const keyword, new naming format)
  3. Classes (use where possible, any object which has state now or init method or something like this should be turned into the classes and instantiated there necessary)
  4. Arrows
  5. Promises (get rid of the async module and callbacks)

Browser job completion mechanism is incorrect.

There are two ways which leads to the job completion:

  1. All job's test runs are finished.
  2. Job's task was aborted

In the first scenario browser requests status an we query job in the front of the queue for the next test run. If job doesn't contain pending test runs any more it returns null and raises done event. done event handler in the BrowserConnection removes job from the queue. But since BrowserConnection.getStatus() already queried queue browser goes to the idle state. It will query status anyway, however it leads to the unecessary delay.

The second scenario has more complicated problems. Task calls abort() for each of it's jobs. abort() just cleans pending test runs queue. So, from the browsers perspective we will have the same issue as described for the first case. The other issue for this approach is that we still relay on done event for the abortion scenario which is really fragile. done event on all jobs will trigger done event for the task. Which is wrong. Currently we rely on the fact that adopting code will call task.removeAllListeners() immediately after task.abort() which is definetly uncool.

The proposal is:

  • Do not rely on the done event of the job in the BrowserConnection. Use the following algorithm instead:
    1. If jobQueue is empty then switch browser to the idle state and abort these steps.
    2. Try query job in the front of the queue. If it returns null then shift the queue and repeat this step. Else pass returned test run to the browser.
  • task.abort() should immediately remove all task's jobs from the appropriate browser connections.

Reorganize client-side scripts

Split scripts to:

  • core.js (or testcafe_core.js)
  • runner.js (or testcafe_runner.js)
  • ui.js (or testcafe_ui.js)

Each module has documented API. Modules are available via a global variable in window.

/cc @inikulin

Stack traces for the client errors.

We can't do it currently since we need to remove stack frames related to our code (especially, Hammerhead). But this task is complicated by the fact that stack formats differs from browser to browser. However there are some libraries what unifies stack traces.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.