fadi

Logo

FADI - Ingest, store and analyse big data flows

View the Project on GitHub cetic/fadi

Testing the FADI framework

Jest Puppeteer

implemented with puppeteer tested with jest

Introduction

The FADI framework is tested using Puppeteer and Jest.

Puppeteer is a Node library which provides a high-level API to control Chrome or Chromium over the DevTools Protocol. Puppeteer runs headless by default, but can be configured to run full (non-headless) Chrome or Chromium.

Jest is a JavaScript Testing Framework with a focus on simplicity. It works with projects using: Babel, TypeScript, Node, React, Angular, Vue and more!

Quick start

To test the FADI framework, you need to implement the following instructions:

  1. Install FADI framework. Refer to the INSTALL section.
  2. Create a Docker container using the Puppeteer-Jest Docker image. To achieve that, run the following command:
docker container run --name testing-fadi  fzalila/docker-puppeteer-jest:latest
  1. Inside the created container, clone the FADI repository:
git clone https://github.com/cetic/fadi.git
  1. Configure here the urls and paths of different FADI platform services

  2. Go to the tests folder and launch the tests:

cd fadi/tests
npm run test

If tests pass, you should obtain the following results:

Tests results

Examples

The following example checks the creation of a example_basic table in the postgres database.

it('should create a table', async () => {
    // Go to the indicated page 
    await page.goto(url)

    // Click on SQL query button 
    await click(page, '.ltr > #menu > .links > a:nth-child(1)')

    // type the query
    await typeText(page, 'CREATE TABLE example_basic (measure_ts TIMESTAMP NOT NULL,temperature FLOAT (50));', '.ltr > #content > #form > p > .jush')

    // Execute the table creation query
    await click(page, '.ltr > #content > #form > p > input:nth-child(1)')

    // Check the creation of the table
    await shouldExist(page, '#content > p.message')
})

More examples are available in the test-scripts folder.

Documentation

Test cases of the FADI framework are specified using Cockburns[1] templates, available here.

Test scripts specifications are available here.

Two templates are available in order to define a new test case and a new test script.

Continuous integration

To automate testing inside a continuous integration process, you can for example add a test stage to a Gitlab-CI pipeline by editing the .gitlab-ci.yml configuration:

stages:
- deployWithHelm
- test

deployWithHelm:
[...]

test:
  stage: test
  image: ceticasbl/puppeteer-jest
  script:
   - cd tests/
   - npm run test

References

[1] Alistair Cockburn. 2000. Writing Effective Use Cases (1st. ed.). Addison-Wesley Longman Publishing Co., Inc., USA.