-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new TypeScript project for unit tests (#39436)
* Add test-specific `tsconfig` * Convert `Text` unit tests to TypeScript * Add custom Jest matcher types * Disable `import/no-extraneous-dependencies` for all TypeScript tests * Remove `@types/node` from `tsconfig.test.json` * Update `toMatchStyleDiffSnapshot` type defs * Change snapshot extension from `js` to `tsx` * Update toMatchStyleDiffSnapshot docs * Update test to use toMatchStyleDiffSnapshot * Use alternative link syntax in the JSDoc comment * Improve comment wording * Allow null values to be passed to `toMatchStyleDiffSnapshot` * Remove jest types reference * Rename testing-library declarations to gutenberg-test-env * Change approach from a dedicated test project, to re-using the components' existing project Co-authored-by: Jon Surrell <[email protected]>
- Loading branch information
Showing
6 changed files
with
60 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...src/text/test/__snapshots__/index.js.snap → ...rc/text/test/__snapshots__/index.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
declare namespace jest { | ||
interface Matchers< R > { | ||
/** | ||
* Similar to the [`toMatchDiffSnapshot` matcher], this custom matcher | ||
* allows to snapshot only the difference between the _styles_ associated | ||
* with different states of a component. | ||
* | ||
* @see [to-match-style-diff-snapshot.js] | ||
* @see [Testing Overview docs] | ||
* @cite https://github.com/testing-library/react-testing-library/issues/36#issuecomment-440442300 | ||
* | ||
* [`toMatchDiffSnapshot` matcher]: https://github.com/jest-community/snapshot-diff | ||
* [to-match-style-diff-snapshot.js]: https://github.com/WordPress/gutenberg/blob/trunk/test/unit/config/matchers/to-match-style-diff-snapshot.js | ||
* [Testing Overview docs]: https://github.com/WordPress/gutenberg/blob/trunk/docs/contributors/code/testing-overview.md#best-practices | ||
*/ | ||
toMatchStyleDiffSnapshot( expected: Element | null ): R; | ||
} | ||
} |