Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Version History

« Previous Version 3 Current »

Pull the code from this repo git clone https://livingwater@bitbucket.org/living-water-js/testcafe-basics.git

Be sure to add testcafe to your projects dependencies using the command npm install testcafe --save-dev

Use the following link to get a better understanding of the TestController api https://devexpress.github.io/testcafe/documentation/reference/test-api/selector/

Visit https://devexpress.github.io/testcafe/documentation/guides/basic-guides/assert.html for more info on this basic structure

Basic test file structure

import {Selector} from "testcafe";

fixture `Getting Stated`            // Notice the back-tick, NOT a single or double quote
    .page `http://google.co.uk`     // notice what heppens when the test is run...  Add semicolon if no optional elements

    // optional elements for all tests...
    .beforeEach( async t => {       // This is optional
        console.log("This runs before any test case and is only run once...")
    })
    .afterEach( async t => {        // This is optional
        console.log("This runs after any test case and is only run once...")
    }); // semicolon to terminate optional elements

    
    test('My first test', async t => {
        console.log("My first test has run...")
    });

    test
    .before( async t => {   // This is optional
        console.log("This runs before the second test case...")
    })
    ('My second test', async t => {
        console.log("My second test has run...")
    })
    .after( async t => {    // This is optional
        console.log("This runs after the second test case...")
    })

The test can be run by typing testcafe chrome .\test\<.spec.ts filename>

  • No labels