Permalink
Fetching contributors…
Cannot retrieve contributors at this time
58 lines (31 sloc) 2.16 KB

Analytics Testing

Why

Our Analytics practice relies on a dataLayer object that is injected onto the DOM at build time, this object must follow a specific structure and format, values will vary based on application and route of the website. We should test for that structure, format and values as part of our automated testing.

What

Validate the object in the e2e testing phase using JSON Schema

  1. validate structure & format (consistent across all implementations)
  2. validate values across pages per project (custom schemas needed in each project)

How

In our isomorphic starter kit, we have a standard schemas that defines the dataLayer global object rules, using nightwatch custom assertion, the schema validation will run against your pages.

Additionally, if a custom schema is provided for the project level, it will validate values as well.

These are automated gating tests. If the structure or content of your objects is incorrect, the test will fail, and the delivery pipeline will be halted.

When

Writing analytics tests: Up on story completion, make sure to include the assertion, also make sure to pull the latest starter-kit change regarding dataLayer to incorporate latest analytics checklist

Running analytics tests: As part of the delivery pipeline

Standards

Analytics team to set

TODO

  • create a standalone nightwatch-json-schema OSS package that implements the logic above
  • if the dataLayer schema can be shared publicly, we should separate that into it's own package

Who

  • @analytics: dataLayer definition and schema ownership
  • @delivery, @developers, @qa: tooling & implementation

References

  • JSON Schema

    Spec documentation

  • AJV

    node based JSON Schema Validator, proven to be the fastest at the time of writing.