Skip to content

fix(ts types): declare 2 forgotten custom expect matchers ts definition#54

Merged
johnjenkins merged 1 commit intostenciljs:mainfrom
MathisPct:fix/missing-ts-definition-declaration-custom-matcher
Dec 12, 2025
Merged

fix(ts types): declare 2 forgotten custom expect matchers ts definition#54
johnjenkins merged 1 commit intostenciljs:mainfrom
MathisPct:fix/missing-ts-definition-declaration-custom-matcher

Conversation

@MathisPct
Copy link
Contributor

@MathisPct MathisPct commented Dec 12, 2025

What is the current behavior?

https://github.com/stenciljs/playwright/blob/main/src/test-expect.ts

interface CustomMatchers<R = unknown> {
  /**
   * Will check if the event spy received the expected event.
   */
  toHaveReceivedEvent(): R;

  /**
   * Will check if the event spy received the expected event with the expected detail.
   * @param eventDetail The expected detail of the event.
   */
  toHaveReceivedEventDetail(eventDetail: any): R;

  /**
   * Will check how many times the event has been received.
   */
  toHaveReceivedEventTimes(count: number): R;
}

declare global {
  namespace PlaywrightTest {
    interface Matchers<R> extends CustomMatchers<R> {}
  }
}

export {};

It does not export toHaveNthReceivedEventDetail and toHaveFirstReceivedEventDetail

GitHub Issue Number: 53

What is the new behavior?

Export toHaveNthReceivedEventDetail and toHaveFirstReceivedEventDetail

Documentation

Does this introduce a breaking change?

  • Yes
  • No

Testing

Overwrite ts definitions in my project

// TODO: to delete when we update to version of @stencil/playwright that includes forged matchers definition

interface CustomMatchers<R = unknown> {
    /**
     * Will check if the event spy received the expected event.
     */
    toHaveReceivedEvent(): R;

    /**
     * Will check if the event spy received the expected event with the expected detail.
     * @param eventDetail The expected detail of the event.
     */
    toHaveReceivedEventDetail(eventDetail: any): R;

    /**
     * Will check if the event spy received the expected event at the given index with the expected detail.
     * @param index position of the event in the received events array.
     * @param eventDetail The expected detail of the event.
     */
    toHaveNthReceivedEventDetail(index: number, eventDetail: any): R;

    /**
     * Will check if the event spy received the expected event with the expected detail on the first received event.
     * @param eventDetail The expected detail of the event.
     */
    toHaveFirstReceivedEventDetail(eventDetail: any): R;

    /**
     * Will check how many times the event has been received.
     */
    toHaveReceivedEventTimes(count: number): R;
}

declare global {
    // eslint-disable-next-line @typescript-eslint/no-namespace
    namespace PlaywrightTest {
        // eslint-disable-next-line @typescript-eslint/no-unused-vars
        interface Matchers<R> extends CustomMatchers<R> {}
    }
}

export {};

Other information

@MathisPct MathisPct requested a review from a team as a code owner December 12, 2025 12:02
@johnjenkins johnjenkins merged commit 2acf2b3 into stenciljs:main Dec 12, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments