kibana/packages/kbn-journeys
Dzmitry Lemechko 6c33644b53
[kbn-journeys] add optional beforeSteps hook (#151717)
## Summary

Related to #151613

There might be cases when we need to add extra wait for Kibana plugin to
be ready before starting loading test data with `esArchiver` /
`kbnArchiver`.

Currently journey lifecycle looks like this:

- `onSetup` wrapped with mocha `before` hook
  - in parallel 
    - `setupBrowserAndPage` (including EBT tracker setup)
    - load ES data / Kibana saved objects
  - `setupApm`
- steps execution (each step wrapped with mocha `it` function)
- `onTeardown` wrapped with mocha `after` hook
  - `tearDownBrowserAndPage` (including closing EBT tracker)
  - `teardownApm`
  - load ES data / Kibana saved objects

beforeSteps hook purpose is to make sure Kibana/ES state is ready for
journey execution and not load test data, since it won't be unloaded
during `after` hook:

- `onSetup` wrapped with mocha `before` hook
    - `setupBrowserAndPage` (including EBT tracker setup)
- run beforeSteps hook -> prepare Kibana/ES for data ingestion / steps
execution
    - load ES data / Kibana saved objects
    - `setupApm`

How to use:

```
export const journey = new Journey({
  beforeSteps: async ({ kibanaServer, retry }) => {
    retry.try(async () => {
      const response = await kibanaServer.request({
        path: '/internal/cloud_security_posture/status?check=init',
        method: 'GET',
      });
      return response.status === 200;
    });
  },
  esArchives: [...],
  kbnArchives: [...],
})
  .step({...})
  .step({...})
```
2023-02-22 18:53:00 +01:00
..
journey [kbn-journeys] add optional beforeSteps hook (#151717) 2023-02-22 18:53:00 +01:00
services [ftr] add first-class support for playwrite journeys (#140680) 2022-09-22 01:06:46 -07:00
index.ts Benchmark single apis (#146297) 2023-01-09 16:38:30 +01:00
jest.config.js [ftr] add first-class support for playwrite journeys (#140680) 2022-09-22 01:06:46 -07:00
kibana.jsonc Transpile packages on demand, validate all TS projects (#146212) 2022-12-22 19:00:29 -06:00
package.json Transpile packages on demand, validate all TS projects (#146212) 2022-12-22 19:00:29 -06:00
README.mdx [ftr] add first-class support for playwrite journeys (#140680) 2022-09-22 01:06:46 -07:00
tsconfig.json Transpile packages on demand, validate all TS projects (#146212) 2022-12-22 19:00:29 -06:00

---
id: kibDevDocsOpsJourneys
slug: /kibana-dev-docs/ops/journeys
title: Journeys
description: A new style of functional test, focused on performance testing for now
tags: ['kibana', 'dev', 'contributor', 'operations', 'performance', 'functional', 'testing']
---

Journeys are a slightly newer take on Functional Tests, currently powered by [playwright](https://playwright.dev/docs).

A Journey is a single pathway through Kibana and looks something like this:

```ts
import { Journey } from '@kbn/journeys';
import { subj } from '@kbn/test-subj-selector';

export const journey = new Journey({
  esArchives: [ ... ],
  kbnArchives: [ ... ],
  scalabilitySetup: { ... },
})
  .step('Go to Discover Page', async ({ page, kbnUrl }) => {
    await page.goto(kbnUrl.get(`/app/discover`));
    await page.waitForSelector(subj('discoverDocTable'));
  })

  .step('Expand the first document', async ({ page }) => {
    const expandButtons = page.locator(subj('docTableExpandToggleColumn'));
    await expandButtons.first().click();
    await page.locator('text="Expanded document"');
  });
```