(page: IJupyterLabPageFixture, tmpPath: string, theme: 'JupyterLab Light' | 'JupyterLab Dark')
| 12 | } |
| 13 | |
| 14 | const testCellOutputs = async (page: IJupyterLabPageFixture, tmpPath: string, theme: 'JupyterLab Light' | 'JupyterLab Dark') => { |
| 15 | const paths = klaw(path.resolve(__dirname, './notebooks'), {filter: item => !filterUpdateNotebooks(item), nodir: true}); |
| 16 | const notebooks = paths.map(item => path.basename(item.path)); |
| 17 | |
| 18 | const contextPrefix = theme == 'JupyterLab Light' ? 'light' : 'dark'; |
| 19 | page.theme.setTheme(theme); |
| 20 | |
| 21 | for (const notebook of notebooks) { |
| 22 | let results = []; |
| 23 | |
| 24 | await page.notebook.openByPath(`${tmpPath}/${notebook}`); |
| 25 | await page.notebook.activate(notebook); |
| 26 | |
| 27 | let numCellImages = 0; |
| 28 | |
| 29 | const getCaptureImageName = (contextPrefix: string, notebook: string, id: number): string => { |
| 30 | return `${contextPrefix}-${notebook}-cell-${id}.png`; |
| 31 | }; |
| 32 | |
| 33 | await page.notebook.runCellByCell({ |
| 34 | onAfterCellRun: async (cellIndex: number) => { |
| 35 | const cell = await page.notebook.getCellOutput(cellIndex); |
| 36 | if (cell) { |
| 37 | results.push(await cell.screenshot()); |
| 38 | numCellImages++; |
| 39 | } |
| 40 | } |
| 41 | }); |
| 42 | |
| 43 | await page.notebook.save(); |
| 44 | |
| 45 | for (let c = 0; c < numCellImages; ++c) { |
| 46 | expect(results[c]).toMatchSnapshot(getCaptureImageName(contextPrefix, notebook, c), {threshold: 0.3}); |
| 47 | } |
| 48 | |
| 49 | await page.notebook.close(true); |
| 50 | } |
| 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}); |
no test coverage detected
searching dependent graphs…