From 18e1442ff59c59fe4d0012ff9d5cef39991a3882 Mon Sep 17 00:00:00 2001 From: Tooooooooon Date: Mon, 21 Aug 2023 13:53:26 +0800 Subject: [PATCH 1/3] Update on next.js testing import js-dom causes error on latest release Running the test with the latest js-dom library will fail because of the changes on the import. `extend-expect` is no longer required when importing the library. Please see the release here - https://github.com/testing-library/jest-dom/releases/tag/v6.0.0 --- .../05-optimizing/10-testing.mdx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/03-pages/01-building-your-application/05-optimizing/10-testing.mdx b/docs/03-pages/01-building-your-application/05-optimizing/10-testing.mdx index d861a091ecff6..22de52d82720e 100644 --- a/docs/03-pages/01-building-your-application/05-optimizing/10-testing.mdx +++ b/docs/03-pages/01-building-your-application/05-optimizing/10-testing.mdx @@ -430,11 +430,16 @@ setupFilesAfterEnv: ['/jest.setup.js'] ``` Then, inside `jest.setup.js`, add the following import: - ```js filename="jest.setup.js" import '@testing-library/jest-dom/extend-expect' ``` +If you are using `@testing-library/jest-dom` release 6 and later, use the code below instead. As per the latest `@testing-library/jest-dom` [release (v6.0)](https://github.com/testing-library/jest-dom/releases/tag/v6.0.0) the `extend-expect` was removed. +```js filename="jest.setup.js" +import '@testing-library/jest-dom +``` + + If you need to add more setup options before each test, it's common to add them to the `jest.setup.js` file above. **Optional: Absolute Imports and Module Path Aliases** From d7ff6253317b477945906b95ec0a3363c458a487 Mon Sep 17 00:00:00 2001 From: Michael Novotny Date: Mon, 21 Aug 2023 10:28:32 -0500 Subject: [PATCH 2/3] Apply suggestions from code review --- .../05-optimizing/10-testing.mdx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/docs/03-pages/01-building-your-application/05-optimizing/10-testing.mdx b/docs/03-pages/01-building-your-application/05-optimizing/10-testing.mdx index 22de52d82720e..89236b73bd2ff 100644 --- a/docs/03-pages/01-building-your-application/05-optimizing/10-testing.mdx +++ b/docs/03-pages/01-building-your-application/05-optimizing/10-testing.mdx @@ -431,14 +431,10 @@ setupFilesAfterEnv: ['/jest.setup.js'] Then, inside `jest.setup.js`, add the following import: ```js filename="jest.setup.js" -import '@testing-library/jest-dom/extend-expect' -``` - -If you are using `@testing-library/jest-dom` release 6 and later, use the code below instead. As per the latest `@testing-library/jest-dom` [release (v6.0)](https://github.com/testing-library/jest-dom/releases/tag/v6.0.0) the `extend-expect` was removed. -```js filename="jest.setup.js" -import '@testing-library/jest-dom +import '@testing-library/jest-dom' ``` +> [`extend-expect` was removed in `v6.0`](https://github.com/testing-library/jest-dom/releases/tag/v6.0.0), so if you are using `@testing-library/jest-dom` before version 6, you will need to import `@testing-library/jest-dom/extend-expect` instead. If you need to add more setup options before each test, it's common to add them to the `jest.setup.js` file above. From ef0b186cddb6f09c70e899f945a8957a4bc2813f Mon Sep 17 00:00:00 2001 From: Michael Novotny Date: Mon, 21 Aug 2023 10:30:16 -0500 Subject: [PATCH 3/3] Space --- .../01-building-your-application/05-optimizing/10-testing.mdx | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/03-pages/01-building-your-application/05-optimizing/10-testing.mdx b/docs/03-pages/01-building-your-application/05-optimizing/10-testing.mdx index 89236b73bd2ff..75c5937582624 100644 --- a/docs/03-pages/01-building-your-application/05-optimizing/10-testing.mdx +++ b/docs/03-pages/01-building-your-application/05-optimizing/10-testing.mdx @@ -430,6 +430,7 @@ setupFilesAfterEnv: ['/jest.setup.js'] ``` Then, inside `jest.setup.js`, add the following import: + ```js filename="jest.setup.js" import '@testing-library/jest-dom' ```