/
TestCafe Basic
TestCafe Basic
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 project's dependencies using the command npm install testcafe --save-dev
Visit https://devexpress.github.io/testcafe/documentation/guides/basic-guides/assert.html for more info on this basic structure
Use the following link to get a better understanding of the TestController api https://devexpress.github.io/testcafe/documentation/reference/test-api/selector/
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>