Skip to content

Latest commit

 

History

History

pass-parameters-to-tests

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Pass Parameters to Tests

Test Code: index.js

This example demonstrates how to pass parameters to TestCafe tests. You can obtain the parameter values from the following sources:

  • a JSON configuration file
  • a JavaScript object
  • an environment variable

Before test execution, two parameters are loaded from the .json and .js files with an import statement. The third parameter is set as an environment variable with the process.env property.

The test.page method sets the initial page for each test. The page URL is passed as its parameter. Then, a clientFunction obtains the File URL of the current page, and the t.expect.eql method compares this value to the full path calculated based on the specified parameter.

TestCafe Functions and Methods Used in This Example

  1. Test Structure:
  2. Assertion and Evaluation:
  3. Custom Scripts: