Skip to content

Instantly share code, notes, and snippets.

@jtpio
Last active November 9, 2021 14:25
Show Gist options
  • Save jtpio/8046759a49e9ba15382aaf8ec5d6a99d to your computer and use it in GitHub Desktop.
Save jtpio/8046759a49e9ba15382aaf8ec5d6a99d to your computer and use it in GitHub Desktop.
Galata getCellOutput
node_modules
playwright-report
test-results
yarn.lock

Galata getCellOutput

yarn --frozen-lockfile

yarn start

yarn test
import { test } from '@jupyterlab/galata';
import { expect } from '@playwright/test';
import * as path from 'path';
test.describe('Visual Regression', () => {
test.beforeEach(async ({ page, tmpPath }) => {
await page.contents.uploadFile(
path.resolve(__dirname, './test.ipynb'),
`${tmpPath}/test.ipynb`
);
await page.filebrowser.openDirectory(tmpPath);
});
test('Run test.ipynb', async ({
page,
tmpPath,
}) => {
const notebook = 'test.ipynb';
await page.notebook.openByPath(`${tmpPath}/${notebook}`);
await page.notebook.activate(notebook);
const captures = new Array<Buffer>();
const cellCount = await page.notebook.getCellCount();
await page.notebook.runCellByCell();
await page.notebook.save();
const cell = await page.notebook.getCellOutput(0);
expect(await cell.screenshot()).toMatchSnapshot();
});
});
from tempfile import mkdtemp
c.ServerApp.port = 8888
c.ServerApp.open_browser = False
c.ServerApp.root_dir = mkdtemp(prefix='galata-test-')
c.ServerApp.token = ""
c.ServerApp.password = ""
c.ServerApp.disable_check_xsrf = True
c.LabApp.expose_app_in_browser = True
{
"name": "test",
"private": true,
"version": "0.1.0",
"description": "test",
"scripts": {
"start": "jupyter lab --config ./jupyter_server_config.py",
"start:detached": "yarn run start&",
"test": "playwright test",
"test:debug": "PWDEBUG=1 playwright test",
"test:report": "http-server ./playwright-report -a localhost -o",
"test:update": "playwright test --update-snapshots"
},
"author": "Project Jupyter",
"license": "BSD-3-Clause",
"dependencies": {
"@jupyterlab/galata": "~4.0.2"
}
}
const baseConfig = require('@jupyterlab/galata/lib/playwright-config');
module.exports = {
...baseConfig,
timeout: 240000,
retries: 1,
};
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import sys\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.2"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment