Test
Tests allow you to assert on the computed values that are the output of an
insight. Tests are run with the visivo test command.
Example
tests:
- name: Test One
if: ">{ ${ ref(Tested Insight).props.type } == 'scatter' }"
assertions:
- ">{ sum( ${ ref(Tested Insight).props.x } ) == 7 }"
- ">{ ${ ref(Tested Insight).props.x[0] } == 1 }"
Note
Quote each >{ ... } assertion (as above). Unquoted, YAML reads a
leading > as a folded block-scalar indicator, so the assertion never
reaches the parser as an eval string.
The numpy library is available in test expressions.
Attributes
| Field | Type | Default | Description |
|---|---|---|---|
| path | string | None | A unique path to this object |
| name | string | None | The unique name of the object across the entire project. |
| file_path | string | None | The path to the file that contains the object definition. |
| if_ | string | None | An optional eval string that gates the test; the assertions only run when it evaluates to true. |
| on_failure | exit | Whether a failure stops the test run (exit) or lets the remaining tests run (continue). |
|
| assertions | array | [] | A list of eval strings (>{ ... }) that must all evaluate to true for the test to pass. |