diff --git a/playground/layouts/default.vue b/playground/layouts/default.vue
index a96b4391a..0053bc919 100644
--- a/playground/layouts/default.vue
+++ b/playground/layouts/default.vue
@@ -11,6 +11,9 @@
NuxtPicture
+
+ Events
+
diff --git a/playground/pages/events.vue b/playground/pages/events.vue
new file mode 100644
index 000000000..a0ff52343
--- /dev/null
+++ b/playground/pages/events.vue
@@ -0,0 +1,45 @@
+
+
+
Original
+ { console.log('Image was loaded') }"
+ />
+ { console.log('Image was loaded') }"
+ />
+
+ Placeholder
+ { console.log('Image was loaded') }"
+ />
+ { console.log('Image was loaded') }"
+ />
+
+ 404
+ { console.log('Error loading image') }"
+ />
+
+
+
+
diff --git a/test/e2e/no-ssr.test.ts b/test/e2e/no-ssr.test.ts
index c49b6a0e1..8f7679383 100644
--- a/test/e2e/no-ssr.test.ts
+++ b/test/e2e/no-ssr.test.ts
@@ -39,12 +39,18 @@ describe('browser (ssr: false)', () => {
expect(requests.map(r => r.replace(url('/'), '/')).filter(r => r !== providerPath && !r.match(/\.(js|css)/))).toMatchSnapshot()
})
+})
+
+describe('browser (ssr: false) common', () => {
+ it('should emit load and error events', async () => {
+ const page = await createPage(url('/events'))
+ const logs: string[] = []
+
+ page.on('console', (msg) => { logs.push(msg.text()) })
- it.todo('should emit load event', async () => {
- // await page.waitForEvent('console', (msg) => {
- // expect(msg.text()).toBe('Image was loaded.')
+ await page.waitForLoadState('networkidle')
- // return true
- // })
+ expect(logs.filter(log => log === 'Image was loaded').length).toBe(4)
+ expect(logs.filter(log => log === 'Error loading image').length).toBe(1)
})
})