Skip to content

Commit d4300f5

Browse files
committed
Add Galata tests
1 parent 7933df7 commit d4300f5

21 files changed

+4899
-97
lines changed

.eslintignore

+2
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ dist
33
coverage
44
**/*.d.ts
55
tests
6+
ui-tests/**
7+
ipympl/labextension/**
68
ipympl/nbextension/extension.js

.github/workflows/main.yml

+58
Original file line numberDiff line numberDiff line change
@@ -155,3 +155,61 @@ jobs:
155155

156156
- name: Validate the labextension
157157
run: jupyter labextension list 2>&1 | grep jupyter-matplotlib
158+
159+
160+
visual-regression-tests:
161+
runs-on: ubuntu-latest
162+
needs: [build]
163+
164+
strategy:
165+
fail-fast: false
166+
167+
steps:
168+
169+
- name: Checkout
170+
uses: actions/checkout@v2
171+
172+
- name: Setup conda
173+
uses: conda-incubator/setup-miniconda@v2
174+
with:
175+
python-version: 3.9
176+
mamba-version: "*"
177+
auto-activate-base: false
178+
channels: conda-forge
179+
180+
- name: Install dependencies
181+
run: mamba install pip yarn jupyterlab=3.0.11 ipywidgets jupyter-packaging
182+
183+
- uses: actions/download-artifact@v2
184+
with:
185+
name: dist ${{ github.run_number }}
186+
path: ./dist
187+
188+
- name: Install the package
189+
run: pip install -vv ipympl*.whl
190+
working-directory: dist
191+
192+
- name: Install test dependencies
193+
run: yarn install
194+
working-directory: ui-tests
195+
196+
- name: Launch JupyterLab
197+
run: yarn run start-jlab:detached
198+
working-directory: ui-tests
199+
200+
- name: Wait for JupyterLab
201+
uses: ifaxity/wait-on-action@v1
202+
with:
203+
resource: http-get://localhost:8888/api
204+
timeout: 20000
205+
206+
- name: Run UI Tests
207+
run: yarn run test
208+
working-directory: ui-tests
209+
210+
- name: Upload UI Test artifacts
211+
if: always()
212+
uses: actions/upload-artifact@v2
213+
with:
214+
name: ui-test-output
215+
path: ui-tests/test-output

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ ipympl/nbextension/index.*
2121
ipympl/nbextension/package.json
2222
ipympl/labextension/*.tgz
2323

24+
ui-tests/test-output
25+
2426
# Coverage data
2527
# -------------
2628
**/coverage/

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@
3232
"watch:lib": "tsc -w",
3333
"watch:nbextension": "webpack --watch --mode=development",
3434
"watch:labextension": "jupyter labextension watch .",
35-
"eslint": "eslint . --fix --ignore-path .gitignore --ext .ts",
36-
"eslint:check": "eslint . --ignore-path .gitignore --ext .ts",
35+
"eslint": "eslint . --fix --ignore-path .eslintignore --ext .ts",
36+
"eslint:check": "eslint . --ignore-path .eslintignore --ext .ts",
3737
"lint": "yarn run prettier && yarn run eslint",
3838
"lint:check": "yarn run prettier:check && yarn run eslint:check",
3939
"prepublish": "yarn run clean && yarn run build",
40-
"prettier": "prettier --ignore-path .gitignore --write \"**/*{.ts,.css,.json}\"",
41-
"prettier:check": "prettier --check --ignore-path .gitignore \"**/*{.ts,.css,.json}\""
40+
"prettier": "prettier --ignore-path .eslintignore --write \"**/*{.ts,.css,.json}\"",
41+
"prettier:check": "prettier --check --ignore-path .eslintignore \"**/*{.ts,.css,.json}\""
4242
},
4343
"jupyterlab": {
4444
"extension": "lib/plugin",

pyproject.toml

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ build-backend = "setuptools.build_meta"
55

66
[tool.pytest.ini_options]
77
testpaths = [
8-
"test-notebooks",
98
"examples",
109
]
1110
norecursedirs = [

test-notebooks/UAT.ipynb

-92
This file was deleted.

ui-tests/README.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Visual regression tests using Galata
2+
3+
This directory contains visual regression tests for ipympl, using Galata.
4+
5+
In order to run them, you need to install dependencies:
6+
7+
```bash
8+
const install -c conda-forge yarn jupyterlab=3.0.7
9+
10+
yarn install
11+
```
12+
13+
Then start JupyterLab in one terminal (you need to check that it properly starts on port 8888):
14+
```bash
15+
yarn run start-jlab
16+
```
17+
18+
Finally, run the galata tests:
19+
```bash
20+
yarn run test
21+
```
22+
23+
If bqplot visuals change, you can re-generate reference images by running:
24+
```bash
25+
yarn run update-references
26+
```

ui-tests/galata-config.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"testId": "test"
3+
}

ui-tests/jupyter_server_config.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
c.ServerApp.port = 8888 # noqa
2+
c.ServerApp.token = "" # noqa
3+
c.ServerApp.password = "" # noqa
4+
c.ServerApp.disable_check_xsrf = True # noqa
5+
c.ServerApp.open_browser = False # noqa
6+
c.LabApp.open_browser = False # noqa
7+
c.LabApp.expose_app_in_browser = True # noqa

ui-tests/package.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "ipympl-ui-tests",
3+
"version": "1.0.0",
4+
"description": "ipympl UI Tests",
5+
"private": true,
6+
"scripts": {
7+
"start-jlab": "jupyter lab --config ./jupyter_server_config.py",
8+
"start-jlab:detached": "yarn run start-jlab&",
9+
"clean": "rimraf tests/notebooks/.ipynb_checkpoints && rimraf test-output",
10+
"test": "yarn run clean && galata --image-match-threshold 0.33",
11+
"update-references": "galata --update-references"
12+
},
13+
"author": "ipympl",
14+
"license": "Apache-2.0",
15+
"dependencies": {
16+
"@jupyterlab/galata": "3.0.11-2",
17+
"klaw-sync": "^6.0.0",
18+
"rimraf": "^3.0.2"
19+
}
20+
}
Loading
Loading
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)