Eventvisor

Workflow

Testing

Events, attributes, and other entities along with all the conditions and transforms can grow in complexity over time. It's important you have the confidence they work as intended before you deploy the datafiles affecting your applications in production.

Just how you declare the original definitions of the entities, you can also declare tests for them in a similar way. And then run them using Eventvisor CLI.

Running tests

Command
$ npx eventvisor lint

Specs

Each entity can have one or more test specs in tests directory.

Unlike the original definition files, test spec file names do not carry any meaning. So you can name them whatever you want.

Testing events

tests/events/pageView.spec.yml
event: pageView
assertions:
- description: assertion description is here
track:
url: https://example.com
expectedToBeValid: true
expectedEvent:
url: https://example.com

Testing attributes

tests/attributes/deviceId.spec.yml
attribute: deviceId
assertions:
- description: assertion description is here
set: device-123
expectedToBeValid: true
expectedAttribute: device-123

Testing destinations

tests/destinations/browser.spec.yml
destination: browser
assertions:
- description: assertion description is here
actions:
- type: setAttribute
name: deviceId
value: device-123
- type: track
name: pageView
value:
url: https://example.com
expectedBody:
deviceId: device-123
url: https://example.com

Testing effects

tests/effects/marketing-pixel.spec.yml
effect: marketing-pixel
assertions:
- description: assertion description is here
actions:
- type: setAttribute
name: deviceId
value: device-123
- type: track
name: pageView
value:
url: https://example.com
expectedState:
injected: true
expectedToBeHandled: true
expectedToBeCalled:
- handler: pixel
times: 1
Previous
Building datafiles