Jest Puppeteer Demo

This demo shows how to use Jest for integration testing a web application that uses yFiles for HTML.

You can find more information about testing a yFiles-based application in general, and about using Jest and yFiles together in particular, in the documentation.

Starting the demo and running the integration tests

  1. Go to the demo's directory demos-ts/testing/jest-puppeteer.
  2. Run npm install.
  3. Run the integration tests: npm run test:integration.
  4. Run the integration tests in watch mode: npm run test:integration:watch.

The integration tests check yFiles functionality by simulating node, edge and port creation gestures and verifying that the graph instance actually contains the newly created graph items.

The tests run in a Puppeteer environment instead of the default jsdom environment, because yFiles for HTML needs a common, standards-compliant browser environment, which jsdom does not provide (in particular, jsdom lacks a complete SVG DOM implementation).

With Puppeteer, the tests can be run in a complete Chrome headless environment.

The application under test is the Simple Testable App. The GraphComponent instance is accessed from its parent element through the [data-this] attribute.