Skip to content

Commit

Permalink
chore(atomic): fix expect assertion type collisions between jest-do…
Browse files Browse the repository at this point in the history
…m and stencil/jest (#4996)

https://coveord.atlassian.net/browse/KIT-3907

We can easily remove the collision by just removing the problematic code
in @stencil/core. This might create a worse DX for the two lasting files
still using stencil/jest but this is well worth it. We will delete
@stencil/core anyway.

### before
goes to stencil-private.d.ts
<img width="562" alt="image"
src="https://github.com/user-attachments/assets/e048d64a-71ef-4862-af92-47c3e9ce8c77"
/>


### after
goes to testing-library/jest-dom/matchers.d.ts
<img width="527" alt="image"
src="https://github.com/user-attachments/assets/e85d5150-1b9b-4ba7-bb6a-c606701d1793"
/>
  • Loading branch information
alexprudhomme authored Feb 20, 2025
1 parent 60c25db commit b9856d9
Showing 1 changed file with 109 additions and 0 deletions.
109 changes: 109 additions & 0 deletions patches/@stencil+core+4.20.0.patch
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,112 @@ index 05c98c9..1ae35e5 100644
}
}
if (statements.length === 0) {
diff --git a/node_modules/@stencil/core/internal/stencil-private.d.ts b/node_modules/@stencil/core/internal/stencil-private.d.ts
index 602cf1f..6dbb9d8 100644
--- a/node_modules/@stencil/core/internal/stencil-private.d.ts
+++ b/node_modules/@stencil/core/internal/stencil-private.d.ts
@@ -1756,103 +1756,7 @@ export interface Workbox {
injectManifest(swConfig: any): Promise<any>;
copyWorkboxLibraries(wwwDir: string): Promise<any>;
}
-declare global {
- namespace jest {
- interface Matchers<R, T> {
- /**
- * Compares HTML, but first normalizes the HTML so all
- * whitespace, attribute order and css class order are
- * the same. When given an element, it will compare
- * the element's `outerHTML`. When given a Document Fragment,
- * such as a Shadow Root, it'll compare its `innerHTML`.
- * Otherwise it'll compare two strings representing HTML.
- */
- toEqualHtml(expectHtml: string): void;
- /**
- * Compares HTML light DOM only, but first normalizes the HTML so all
- * whitespace, attribute order and css class order are
- * the same. When given an element, it will compare
- * the element's `outerHTML`. When given a Document Fragment,
- * such as a Shadow Root, it'll compare its `innerHTML`.
- * Otherwise it'll compare two strings representing HTML.
- */
- toEqualLightHtml(expectLightHtml: string): void;
- /**
- * When given an element, it'll compare the element's
- * `textContent`. Otherwise it'll compare two strings. This
- * matcher will also `trim()` each string before comparing.
- */
- toEqualText(expectTextContent: string): void;
- /**
- * Checks if an element simply has the attribute. It does
- * not check any values of the attribute
- */
- toHaveAttribute(expectAttrName: string): void;
- /**
- * Checks if an element's attribute value equals the expect value.
- */
- toEqualAttribute(expectAttrName: string, expectAttrValue: any): void;
- /**
- * Checks if an element's has each of the expected attribute
- * names and values.
- */
- toEqualAttributes(expectAttrs: {
- [attrName: string]: any;
- }): void;
- /**
- * Checks if an element has the expected css class.
- */
- toHaveClass(expectClassName: string): void;
- /**
- * Checks if an element has each of the expected css classes
- * in the array.
- */
- toHaveClasses(expectClassNames: string[]): void;
- /**
- * Checks if an element has the exact same css classes
- * as the expected array of css classes.
- */
- toMatchClasses(expectClassNames: string[]): void;
- /**
- * When given an EventSpy, checks if the event has been
- * received or not.
- */
- toHaveReceivedEvent(): void;
- /**
- * When given an EventSpy, checks how many times the
- * event has been received.
- */
- toHaveReceivedEventTimes(count: number): void;
- /**
- * When given an EventSpy, checks the event has
- * received the correct custom event `detail` data.
- */
- toHaveReceivedEventDetail(eventDetail: any): void;
- /**
- * When given an EventSpy, checks the first event has
- * received the correct custom event `detail` data.
- */
- toHaveFirstReceivedEventDetail(eventDetail: any): void;
- /**
- * When given an EventSpy, checks the last event has
- * received the correct custom event `detail` data.
- */
- toHaveLastReceivedEventDetail(eventDetail: any): void;
- /**
- * When given an EventSpy, checks the event at an index
- * has received the correct custom event `detail` data.
- */
- toHaveNthReceivedEventDetail(index: number, eventDetail: any): void;
- /**
- * Used to evaluate the results of `compareScreenshot()`, such as
- * `expect(compare).toMatchScreenshot()`. The `allowableMismatchedRatio`
- * value from the testing config is used by default if
- * `MatchScreenshotOptions` were not provided.
- */
- toMatchScreenshot(opts?: MatchScreenshotOptions): void;
- }
- }
-}
+
export interface MatchScreenshotOptions {
/**
* The `allowableMismatchedPixels` value is the total number of pixels

0 comments on commit b9856d9

Please sign in to comment.