<commit_before># Okapi

Integration testing based on [Puppeteer](https://github.com/GoogleChrome/puppeteer).

Okapi is aimed at single page apps that rely on APIs.
The goal is to be able to use the VCR pattern in order to first mock the API on your local tests and then be able to commit the results and test it on your continuous integration.

## Example

```javascript
const path = require("path");
const Okapi = require("../index");

test("it should get the content of elements of the page", async () => {
  const result = await Okapi.prepare()
    .goto("file://" + path.join(__dirname, "getH1.html"))
    .capture(() => document.querySelector("h1").textContent)
    .capture(() => document.querySelector("h2").textContent)
    .run();
  expect(result).toEqual(["content of h1", "content of h2"]);
});
```

## API

##### Table of Contents

* [Okapi.prepare()](#okapiprepare)
* [Okapi.goto(url)](#okapigotourl)
* [Okapi.click(selector)](#okapiclickselector)
* [Okapi.insert(selector, value)](#okapiinsertselector-value)
* [Okapi.fillForm(data)](#okapifillformdata)
* [Okapi.capture(func)](#okapicapturefunc)
* [Okapi.puppeteer(func)](#okapipuppeteerfunc)
* [Okapi.run()](#okapirun)

#### Okapi.prepare()

Start the chain of events you want to send for your test.<commit_msg>better doc<commit_after># Okapi

Integration testing based on [Puppeteer](https://github.com/GoogleChrome/puppeteer).

Okapi is aimed at single page apps that rely on APIs.
The goal is to be able to use the VCR pattern in order to first mock the API on your local tests and then be able to commit the results and test it on your continuous integration.

## Example

In theory, you could use Okapi with any test framework, here is an example with [Jest](https://facebook.github.io/jest/)

```javascript
const path = require("path");
const Okapi = require("../index");

test("it should get the content of elements of the page", async () => {
  const result = await Okapi.prepare()
    .goto("file://" + path.join(__dirname, "getH1.html"))
    .capture(() => document.querySelector("h1").textContent)
    .capture(() => document.querySelector("h2").textContent)
    .run();
  expect(result).toEqual(["content of h1", "content of h2"]);
});
```

## API

##### Table of Contents

* [Okapi.prepare()](#okapiprepare)
* [Okapi.goto(url)](#okapigotourl)
* [Okapi.click(selector)](#okapiclickselector)
* [Okapi.insert(selector, value)](#okapiinsertselector-value)
* [Okapi.fillForm(data)](#okapifillformdata)
* [Okapi.capture(func)](#okapicapturefunc)
* [Okapi.puppeteer(func)](#okapipuppeteerfunc)
* [Okapi.run()](#okapirun)

#### Okapi.prepare()

Start the chain of events you want to send for your test.
{'fraction_non_alphanumeric': 0.15750093527871306, 'fraction_numerical': 0.0037411148522259632, 'mean_word_length': 5.118993135011442, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '995699', 'n_tokens_mistral': 883, 'n_tokens_neox': 850, 'n_words': 252}