Skip to content

Test runner times out when assertions fail with DOM elements #2967

@mkutny

Description

@mkutny

This test times out instead of failing:

import { fixture, expect } from '@open-wc/testing';

it('fails with DOM element', async () => {
  const element = await fixture(`<h1>Title</h1>`);
  expect(element).to.be.true; // Will cause timeout
});

I launch it as npx web-test-runner test/minimal-timeout.test.js --node-resolve

Running this test in a --watch mode in a custom browser (M) fails as expected.

However, running it in Chromium (D) logs these errors in the browser's console:
Uncaught (in promise) DataCloneError: Failed to execute 'structuredClone' on 'Window': HTMLHeadingElement object could not be cloned.

And the next error log is:

autorun.js:1 Uncaught (in promise) DataCloneError: Failed to execute 'structuredClone' on 'Window': HTMLHeadingElement object could not be cloned.
    at stable (__web-dev-server__web-socket.js:23:24)
    at sendMessage (__web-dev-server__web-socket.js:171:20)
stable	@	__web-dev-server__web-socket.js:23
sendMessage	@	__web-dev-server__web-socket.js:171

What would be a workaround to assert DOM elements while this issue is open?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions