innovationOUtside / jupyterlab_empinken_extension

Coloured JupyterLab / RetroLab notebook cells based on cell tags
https://innovationoutside.github.io/jupyterlab_empinken_extension/
MIT License
5 stars 0 forks source link

Automated tests #1

Open psychemedia opened 2 years ago

psychemedia commented 2 years ago

JupyterLab supports testing helpers for use with playwright in the form of https://github.com/jupyterlab/jupyterlab/tree/master/galata

Tests can be performed over console messages as well as UIs.

For example, here is a test against console messages to check an extension is installed:

import { expect, test } from '@jupyterlab/galata';

/**
 * Don't load JupyterLab webpage before running the tests.
 * This is required to ensure we capture all log messages.
 */
test.use({ autoGoto: false });

test('should emit an activation console message', async ({ page }) => {
  const logs: string[] = [];

  page.on('console', message => {
    logs.push(message.text());
  });

  await page.goto();

  expect(
    logs.filter(s => s === 'JupyterLab extension URDF is activated!')
  ).toHaveLength(1);
});

In the case of the empinken extension, we should also be able to write tests that check that eg whether a tagged cell has appropriate style tags applied to it.