nbmake
nbmake copied to clipboard
Widget calls requiring browser context hang during testing
Describe the bug The ITKWidgets project cannot test a notebooks that calls a widget which is only initialised when a browser is present
To Reproduce See https://github.com/InsightSoftwareConsortium/itkwidgets/pull/587
Expected behavior Can call the initialised widget API successfully
Additional context This issue occurs because nbclient is an alternative to running a full jupyter web app + server (architecture diagram) and doesn't run a browser context.
Problem cell example
image = itk.image_from_array(array)
print('Dimension', image.GetImageDimension())
print('Components', image.GetNumberOfComponentsPerPixel())
from ipynb.
This repo has a pretty advanced setup using Selenium's python APIs @thewtex you can see that they actually test the widget's functionality (not just load it).
@alex-treebeard here is a high level architecture that aims to:
- Provide the needed JavaScript, WebGL context
- Be simple, requiring relatively little code
- Work with the existing nbmake code
References:
- pytest-pyodide (Selenium pytest browser testing)
- jupyter_server websocket protocols
- jupyter_server extensions
weights and biases have come up with an interesting cypress-based solution
https://github.com/wandb/weave/blob/4891c2f5d35bb9077d4add9ab4d92536dbf7b00c/integration_test/cypress/e2e/notebooks/notebooks.ts
Interesting! It does not look like they are running the notebooks in an actual browser, though, from what I can tell.