diff --git a/packages/playwright-ct-vue2/registerSource.mjs b/packages/playwright-ct-vue2/registerSource.mjs index b313e702da..fd8a2d063d 100644 --- a/packages/playwright-ct-vue2/registerSource.mjs +++ b/packages/playwright-ct-vue2/registerSource.mjs @@ -190,6 +190,9 @@ window.playwrightUpdate = async (element, options) => { throw new Error('Component was not mounted'); const component = wrapper.componentInstance; + if (!component) + throw new Error('Updating a native HTML element is not supported'); + const { nodeData, slots } = __pwCreateComponent(options); for (const [name, value] of Object.entries(nodeData.on || {})) { diff --git a/tests/components/ct-vue2-cli/tests/update/update.spec.tsx b/tests/components/ct-vue2-cli/tests/update/update.spec.tsx index bb93b99118..f9f7cf9c61 100644 --- a/tests/components/ct-vue2-cli/tests/update/update.spec.tsx +++ b/tests/components/ct-vue2-cli/tests/update/update.spec.tsx @@ -43,3 +43,11 @@ test('update slots without remounting', async ({ mount }) => { await expect(component.getByTestId('remount-count')).toContainText('1'); }); + +test('throw error when updating a native html element', async ({ mount }) => { + const component = await mount(
); + + await expect(async () => { + await component.update(
); + }).rejects.toThrowError('Updating a native HTML element is not supported'); +});