Flood Element includes a simple facility for loading Test Data from CSV and JSON files, or as a list of data specified directly in the script.
The simplest way to provide data to your test is right from the script itself:
You may then use the data in your steps:
For larger or more complicated data sets, you may load data from CSV or JSON files.
If you have data available in a CSV file, perhaps exported from Excel, you can use it to power your test:
Note that the first line of each column is taken to be the name of that column.
. property access notation.
would be accessed as:
Loading data from a JSON is just as simple as loading from CSV
When running Element in cli mode (
element run), place the data files in the same directory as your test script.
When its running as a load test on flood.io, upload the data files alongside your script.
When it's important that your test data is well-defined, Flood Element provides two main approaches: type checking and manual assertion
Element test scripts are written in TypeScript and are thus type checked before being run. Type checking helps write more reliable code (as well as providing documentation and code completion in your editor).
Its possible to define test data using the
any type (as in the examples above). However you could also add explicit type annotations:
A hidden problem with the type checking approach is that it's not possible to automatically type check data loaded in from a CSV or JSON at runtime (The techinal reason is that TypeScript's type annotations are not available at runtime - they're said to be "erased" once compiled)
When loading in data from a file, we can still validate it by using
assert. (Note that in this example we're still using type annotations to make the coding experience better)
false are considered to be
false in an
Falsy values are
"" (an empty string),
undefined; all other values are truthy.
Its important to understand this when validating data, since for example a value of
0 might be valid, but would be considered to be
false when tested with