Skip to content

Latest commit

 

History

History

extract-code-to-helpers

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Extract Reused Code to Helper Functions

Test Code: index.js

This example shows how to extract test code to functions defined in a separate module.

The index.js test file imports three methods from helper.js: enterName, typeComment and submitForm. These helper functions execute test actions like t.click or t.typeText.

Note that the test controller instance is imported from the testcafe module. You don't need to pass t to helper functions because TestCafe can resolve the current test context and provide the correct test controller instance.