From 264f727a8fda2562487fe1b3cce0dacbf2977aba Mon Sep 17 00:00:00 2001 From: Arthur <82575487+arthur-mountain@users.noreply.github.com> Date: Sat, 10 Aug 2024 01:44:00 +0800 Subject: [PATCH] docs(testing): moved the cleanup func calls into the func that be export default (#27268) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Current Behavior The cleanup function is called **immediately** when the file is imported if it is placed outside of the exported function in jest global setup file. Screenshot 2024-08-02 at 7 45 12 AM ## Expected Behavior The cleanup func in jest global setup file, should be call inside the default export function. ## Related Issue(s) N/A! --- docs/generated/packages/jest/documents/overview.md | 5 +++-- docs/shared/packages/jest/jest-plugin.md | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/generated/packages/jest/documents/overview.md b/docs/generated/packages/jest/documents/overview.md index 725f715962..2012ffe1f0 100644 --- a/docs/generated/packages/jest/documents/overview.md +++ b/docs/generated/packages/jest/documents/overview.md @@ -274,9 +274,10 @@ const cleanupRegisteredPaths = registerTsProject('./tsconfig.base.json'); import { yourFancyFunction } from '@some-org/my-util-library'; export default async function () { yourFancyFunction(); + + // make sure to run the clean up! + cleanupRegisteredPaths(); } -// make sure to run the clean up! -cleanupRegisteredPaths(); ``` If you're using `@swc/jest` and a global setup/teardown file, you have to set the `noInterop: false` and use dynamic imports within the setup function: diff --git a/docs/shared/packages/jest/jest-plugin.md b/docs/shared/packages/jest/jest-plugin.md index 725f715962..2012ffe1f0 100644 --- a/docs/shared/packages/jest/jest-plugin.md +++ b/docs/shared/packages/jest/jest-plugin.md @@ -274,9 +274,10 @@ const cleanupRegisteredPaths = registerTsProject('./tsconfig.base.json'); import { yourFancyFunction } from '@some-org/my-util-library'; export default async function () { yourFancyFunction(); + + // make sure to run the clean up! + cleanupRegisteredPaths(); } -// make sure to run the clean up! -cleanupRegisteredPaths(); ``` If you're using `@swc/jest` and a global setup/teardown file, you have to set the `noInterop: false` and use dynamic imports within the setup function: