diff --git a/ci/single_example.sh b/ci/single_example.sh index 5bf70a7..77f5d08 100755 --- a/ci/single_example.sh +++ b/ci/single_example.sh @@ -73,7 +73,8 @@ export default defineConfig({ command: 'npm run serve', url: 'http://localhost:$PORT', reuseExistingServer: !process.env.CI - } + }, + snapshotPathTemplate: '{testDir}/../../../../tests/snapshots/{arg}{ext}' }); EOF diff --git a/ci/tests/example.spec.ts b/ci/tests/example.spec.ts index f2cb6e0..a0368b7 100644 --- a/ci/tests/example.spec.ts +++ b/ci/tests/example.spec.ts @@ -17,7 +17,7 @@ test('loads bokehjs', async ({ page }) => { test('is interactive', async ({ page }) => { await page.goto('/'); - // Take screenshot + await expect(page).toHaveScreenshot('initial.png'); const boxZoom = await page.getByTitle('Box Zoom').click(); const bbox = await page.locator('.bk-CartesianFrame').boundingBox(); @@ -28,9 +28,12 @@ test('is interactive', async ({ page }) => { await page.mouse.move(bbox!.x + bbox!.width*0.8, bbox!.y + bbox!.height*0.8); await page.mouse.up(); await page.waitForTimeout(100); - // Take screenshot + + await expect(page).toHaveScreenshot('zoom.png'); const reset = await page.getByTitle('Reset').click(); await page.waitForTimeout(100); - // Take screenshot + + // Reset image is the same as initial image except for tool selection + await expect(page).toHaveScreenshot('reset.png'); }); diff --git a/ci/tests/snapshots/initial.png b/ci/tests/snapshots/initial.png new file mode 100644 index 0000000..9b5d088 Binary files /dev/null and b/ci/tests/snapshots/initial.png differ diff --git a/ci/tests/snapshots/reset.png b/ci/tests/snapshots/reset.png new file mode 100644 index 0000000..948f170 Binary files /dev/null and b/ci/tests/snapshots/reset.png differ diff --git a/ci/tests/snapshots/zoom.png b/ci/tests/snapshots/zoom.png new file mode 100644 index 0000000..e28cb7c Binary files /dev/null and b/ci/tests/snapshots/zoom.png differ diff --git a/ci/typescript/create_vanilla_vite.sh b/ci/typescript/create_vanilla_vite.sh index 982291b..9d8b0a3 100755 --- a/ci/typescript/create_vanilla_vite.sh +++ b/ci/typescript/create_vanilla_vite.sh @@ -58,7 +58,7 @@ function create_bokehjs_plot(): Bokeh.Plotting.Figure { return plot; } -document.querySelector('#app')!.innerHTML = \`
Hello
\`; +document.querySelector('#app')!.innerHTML = \`
\`; Bokeh.Plotting.show(create_bokehjs_plot(), "#target"); EOF diff --git a/recipes/src/recipes/typescript/vanilla_vite_recipe.ts b/recipes/src/recipes/typescript/vanilla_vite_recipe.ts index 29e7804..e15b514 100644 --- a/recipes/src/recipes/typescript/vanilla_vite_recipe.ts +++ b/recipes/src/recipes/typescript/vanilla_vite_recipe.ts @@ -53,7 +53,7 @@ export class VanillaViteRecipe extends Recipe { baseTypeScriptExample.import + "\n" + baseTypeScriptExample.version + "\n" + baseTypeScriptExample.function + "\n" + - "document.querySelector('#app')!.innerHTML = \\`
Hello
\\`;\n\n" + + "document.querySelector('#app')!.innerHTML = \\`
\\`;\n\n" + baseTypeScriptExample.show() )); diff --git a/typescript/vanilla_vite/README.md b/typescript/vanilla_vite/README.md index 48336be..c5bf7ab 100644 --- a/typescript/vanilla_vite/README.md +++ b/typescript/vanilla_vite/README.md @@ -65,7 +65,7 @@ Create an initial basic project using `create-vite`. return plot; } - document.querySelector('#app')!.innerHTML = `
Hello
`; + document.querySelector('#app')!.innerHTML = `
`; Bokeh.Plotting.show(create_bokehjs_plot(), "#target");