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.
- Test Structure:
- Assertion and Evaluation:
- t.expect.eql Method
- Custom Scripts:
- ClientFunction Object