shlomiassaf/ngrid

[V3] Introduce testing heplers

Closed this issue · 1 comments

Currently there are no tests in nGrid, not Unit and not E2E.
We need both Unit Test & E2E support.

Since nGrid is a 3rd party component it should also provide a small utility framework to support
testing nGrid in applications.

Steps:

  • Integrate Karma as unit test runner for demo/docs app and libraries
  • Integrate Cypress as E2E test environment & framework for demo/docs app
  • A set of Unit Test Component test harnesses helpers, unique to nGrid
  • A Set of E2E Test Component harness LIKE helpers for Cypress

Unit Tests

Integration should be simple, using nx schematics.
We chose Karma because we need a real DOM to test layout related feature, scrolling behaviour (virtual scroll)
and other features missing in JSDOM hence making Jest impractical for testing nGrid.

The harnesses should support all unit test frameworks/runners out of the box due to the unique
abstraction offered by the component harness eco-system.

In addition, multi environment support is also offered out of the box so protractor should work for E2E testing as well.
An exception about E2E might be some custom behaviours in the harness might require working with DOM elements, which will require special support when used in protractor.

Using Karma will not remove support from Jest, testers will still be able to use the harnesses with Jest although
with some testing features unavilable.

E2E Tests

Integration should be simple, using nx schematics.
We chose Cypress because protractor is already supported through the unit tests and personally I think it's an excellent framework.

The harnesses in this case will be limited for Cypress use only and will not share logic with other implementations.
Cypress has a unique flow and it runs different than other frameworks so we will need to build it from scratch.

We will not be able to use the test harness infrastructure provided by the angular CDK not we will be able to build a TestEnvironment for it. (see this issue)

Done, helpers are lightweight and will get more sugar as we add tests to the repo