open-wc / open-wc

Open Web Components: guides, tools and libraries for developing web components.
https://open-wc.org/
MIT License
2.25k stars 423 forks source link

[sementic-dom-diff] Typings added in 0.19.8 interfere with all Should assertions #2675

Open rhelling opened 1 year ago

rhelling commented 1 year ago

Expected behavior

When i have a test that doesn't use semantic-dom-diff I expect the should assertion not to be asynchronous

Actual Behavior

An equal assertion to be synchronous

Describe what happens instead.

When using eslint it picks up the typings from chai-dom-diff-plugin.d.ts and reports async calls should be awaited.

error Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the void operator.

Additional context

See eslint result in the console output of this stackblitz project: https://stackblitz.com/edit/semantic-dom-diff-typeings?file=src%2FArithmetic.test.ts

Which packages and versions are you using.

@open-wc/testing: "3.1.8", @typescript-eslint/eslint-plugin: "^5.51.0", @typescript-eslint/parser: "^5.51.0", eslint: "^8.40.0", eslint-plugin-lit: "^1.8.3",

Also see: package.json

xt0rted commented 1 year ago

Dependabot just opened a PR in my project updating @open-wc/testing from 3.1.8 to 3.2.0 which also updates @open-wc/semantic-dom-diff from 0.19.7 to 0.20.0 and now eslint is failing with the same error.

The code that's being flagged:

const el: CustomElement = await fixture(html`
  <custom-element>
    <input ...>
  </custom-element>
`);

const input = el.querySelector<HTMLInputElement>("input");

// Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator.
// @typescript-eslint/no-floating-promises - https://typescript-eslint.io/rules/no-floating-promises
expect(input).to.equal(document.activeElement);

Ping @Westbrook - this issue is coming from #2419

manuel-mauky commented 6 days ago

Any updates? I'm having the same issue. At runtime equal is returning null so nothing to await. I cannot find any reference that Chai's equal is returning a Promise in any situation.