Creating a test
TestCafe supports tests written using JavaScript, TypeScript, or CoffeeScript with all modern features, such as arrow functions and async/await
. In addition to that, TestCafe will automatically transpile TypeScript and CoffeeScript code before running tests, so you do not need to tackle it on your own.
As we agreed initially, throughout this book we will be using JavaScript to write the tests.
In continuation of our previous efforts from Chapter 3, Setting Up the Environment, we already have test-project
folder with the .testcaferc.json
configuration file in it. So, let's start by opening any shell (for example, we will use Terminal with bash) and following the next steps:
- Go to
test-project
folder and create a folder for our tests:$ cd test-project/ $ mkdir tests
- Now go to that folder and create a
basic-tests.js
file:$ cd tests/ $ touch basic-tests.js
- Open
basic-tests.js
in a code editor (or IDE) of your choice and let's create a simple...