@tauk.com/tauk

Helper package to facilitate Tauk's reporting for webdriver-based tests.

Usage no npm install needed!

<script type="module">
  import taukComTauk from 'https://cdn.skypack.dev/@tauk.com/tauk';
</script>

README

Tauk WebdriverIO Package for JavaScript and TypeScript

Installation

$ npm install --save-dev  @tauk.com/tauk

Usage

Import the Tauk package in your test suite.

import Tauk from "@tauk.com/tauk"

Instantiate Tauk with your API TOKEN and PROJECT ID from the Tauk Web UI.

const tauk: Tauk = new Tauk("API-TOKEN", "PROJECT-ID");

If you want to exclude a test suite from analysis you can pass in the parameter{ excluded: true }. For example:

const tauk: Tauk = new Tauk("API-TOKEN", "PROJECT-ID", { excluded: true } );

Provide Tauk with a reference to your driver object.

tauk.setDriver(driver);

Wrap your individual test cases in tauk.observe().

The first parameter is the test case name as a string. The second parameter is your test case function. For example:

  await tauk.observe("Add new contact", async () => {
    await (await driver.$(`android=${AndroidContacts.locators.firstNameTextField}`)).setValue("Tauk");
    await (await driver.$(`android=${AndroidContacts.locators.lastNameTextField}`)).setValue("Samples");
    await (await driver.$(AndroidContacts.locators.saveButton)).click();
  });

Call tauk.upload() before ending your driver session.

await tauk.upload();

Recommendations for use in BDD-style test suites

When using the Tauk package in BDD-style test suites, such as Mocha and Jasmine, here are some recommendations:

  • Instantiate Tauk within the describe() hook.
  • Set the driver object in the before() hook.
  • Use tauk.observe() in each of your it() hooks.
  • Call tauk.upload() before ending your driver session in your after() hook.

For example:

describe('Android Contacts App Test', function () {
  ...
  const tauk: Tauk = new Tauk("API-TOKEN", "PROJECT-ID");

  before(async function () {
    ...
    tauk.setDriver(driver);
  });

  it('Add new contact', async function () {
    await tauk.observe(`${this.test?.title}`, async () => {
      // Your test case logic
    });
  });

  after(async function () {
    ...
    await tauk.upload(); // Invoke right before ending the session
    await driver.deleteSession();
  });
});

For the full source of this example, please take a look at the androidContacts.ts test case in the tests directory of the repository.