Appearance
TEST.loadDataFromJson()
Loads data from a JSON file.
This is commonly used to externalize test data (e.g. user credentials, form inputs, configuration values) so that test scripts remain clean and reusable.
The file path can be:
- relative to the current test file, or
- absolute from the project root
Usage
js
TEST.loadDataFromJson(filepath: string)Parameters
| Parameter | Type | Description |
|---|---|---|
filepath | string | Path to the JSON file to load. Can be relative to the current test file or from the project root. |
Returns
The parsed contents of the JSON file as a JavaScript object.
Example
Given a data file at data/admin-user.json with the following contents:
json
// data/admin-user.json
{
"username": "[email protected]",
"password": "correct-horse-battery-staple",
"role": "admin"
}To load and use the data in a test script:
js
var admin_user = TEST.loadDataFromJson("data/admin-user.json")
I.fill("Username", admin_user.username)
I.fill("Password", admin_user.password)