(page: IJupyterLabPageFixture, tmpPath: string, theme: 'JupyterLab Light' | 'JupyterLab Dark')
| 51 | } |
| 52 | |
| 53 | const testPlotUpdates = async (page: IJupyterLabPageFixture, tmpPath: string, theme: 'JupyterLab Light' | 'JupyterLab Dark') => { |
| 54 | const paths = klaw(path.resolve(__dirname, './notebooks'), {filter: item => filterUpdateNotebooks(item), nodir: true}); |
| 55 | const notebooks = paths.map(item => path.basename(item.path)); |
| 56 | |
| 57 | const contextPrefix = theme == 'JupyterLab Light' ? 'light' : 'dark'; |
| 58 | page.theme.setTheme(theme); |
| 59 | |
| 60 | for (const notebook of notebooks) { |
| 61 | let results = []; |
| 62 | |
| 63 | await page.notebook.openByPath(`${tmpPath}/${notebook}`); |
| 64 | await page.notebook.activate(notebook); |
| 65 | |
| 66 | const getCaptureImageName = (contextPrefix: string, notebook: string, id: number): string => { |
| 67 | return `${contextPrefix}-${notebook}-cell-${id}.png`; |
| 68 | }; |
| 69 | |
| 70 | let cellCount = 0; |
| 71 | await page.notebook.runCellByCell({ |
| 72 | onAfterCellRun: async (cellIndex: number) => { |
| 73 | // Always get first cell output which must contain the plot |
| 74 | const cell = await page.notebook.getCellOutput(0); |
| 75 | if (cell) { |
| 76 | results.push(await cell.screenshot()); |
| 77 | cellCount++; |
| 78 | } |
| 79 | } |
| 80 | }); |
| 81 | |
| 82 | await page.notebook.save(); |
| 83 | |
| 84 | for (let i = 0; i < cellCount; i++) { |
| 85 | expect(results[i]).toMatchSnapshot(getCaptureImageName(contextPrefix, notebook, i), {threshold: 0.3}); |
| 86 | } |
| 87 | |
| 88 | await page.notebook.close(true); |
| 89 | } |
| 90 | }; |
| 91 | |
| 92 | test.describe('bqplot Visual Regression', () => { |
| 93 | test.beforeEach(async ({ page, tmpPath }) => { |
no test coverage detected
searching dependent graphs…