diff --git a/packages/@lwc/integration-not-karma/configs/plugins/serve-integration.js b/packages/@lwc/integration-not-karma/configs/plugins/serve-integration.js index 6604e74d08..d3a5bb6044 100644 --- a/packages/@lwc/integration-not-karma/configs/plugins/serve-integration.js +++ b/packages/@lwc/integration-not-karma/configs/plugins/serve-integration.js @@ -1,4 +1,5 @@ import path from 'node:path'; +import { fileURLToPath } from 'node:url'; import { rollup } from 'rollup'; import lwcRollupPlugin from '@lwc/rollup-plugin'; @@ -9,6 +10,8 @@ import { DISABLE_SYNTHETIC_SHADOW_SUPPORT_IN_COMPILER, } from '../../helpers/options.js'; +const UTILS = fileURLToPath(new URL('../../helpers/utils.js', import.meta.url)); + /** Cache reused between each compilation to speed up the compilation time. */ let cache; @@ -22,7 +25,7 @@ const createRollupPlugin = (input, options) => { // Sourcemaps don't work with Istanbul coverage sourcemap: !process.env.COVERAGE, experimentalDynamicComponent: { - loader: 'test-utils', + loader: UTILS, strict: true, }, enableDynamicComponents: true, @@ -85,7 +88,7 @@ const transform = async (ctx) => { // Rollup should not attempt to resolve the engine and the test utils, Karma takes care of injecting it // globally in the page before running the tests. - external: ['lwc', 'wire-service', 'test-utils', '@test/loader'], + external: ['lwc', 'wire-service', '@test/loader', UTILS], onwarn(warning, warn) { // Ignore warnings from our own Rollup plugin diff --git a/packages/@lwc/integration-not-karma/helpers/test-hydrate.js b/packages/@lwc/integration-not-karma/helpers/test-hydrate.js index 5b65bdc6c2..95c8823860 100644 --- a/packages/@lwc/integration-not-karma/helpers/test-hydrate.js +++ b/packages/@lwc/integration-not-karma/helpers/test-hydrate.js @@ -1,8 +1,8 @@ import * as LWC from 'lwc'; +import { spyConsole } from './console'; +import { setHooks } from './hooks'; -window.TestUtils.setHooks({ - sanitizeHtmlContent: (content) => content, -}); +setHooks({ sanitizeHtmlContent: (content) => content }); function parseStringToDom(html) { return Document.parseHTMLUnsafe(html).body.firstChild; @@ -28,7 +28,7 @@ async function runTest(ssrRendered, Component, testConfig) { let target = container.querySelector(selector); let testResult; - const consoleSpy = window.TestUtils.spyConsole(); + const consoleSpy = spyConsole(); setFeatureFlags(testConfig.requiredFeatureFlags, true); if (testConfig.test) { diff --git a/packages/@lwc/integration-not-karma/mocks/lwc.mjs b/packages/@lwc/integration-not-karma/mocks/lwc.mjs deleted file mode 100644 index 023844a214..0000000000 --- a/packages/@lwc/integration-not-karma/mocks/lwc.mjs +++ /dev/null @@ -1,6 +0,0 @@ -// IMPORTANT: we must use @lwc/engine-dom instead of lwc in order to avoid circular imports -import { sanitizeAttribute as _sanitizeAttribute } from '@lwc/engine-dom'; -import { fn } from '@vitest/spy'; - -export * from '@lwc/engine-dom'; -export const sanitizeAttribute = fn(_sanitizeAttribute); diff --git a/packages/@lwc/integration-not-karma/test/accessibility/non-standard-aria-props/index.spec.js b/packages/@lwc/integration-not-karma/test/accessibility/non-standard-aria-props/index.spec.js index 63557204e4..e47812f130 100644 --- a/packages/@lwc/integration-not-karma/test/accessibility/non-standard-aria-props/index.spec.js +++ b/packages/@lwc/integration-not-karma/test/accessibility/non-standard-aria-props/index.spec.js @@ -1,11 +1,11 @@ import { createElement } from 'lwc'; +import Light from 'x/light'; +import Shadow from 'x/shadow'; import { attachReportingControlDispatcher, detachReportingControlDispatcher, nonStandardAriaProperties, -} from 'test-utils'; -import Light from 'x/light'; -import Shadow from 'x/shadow'; +} from '../../../helpers/utils.js'; // This test only works if the ARIA reflection polyfill is loaded describe.runIf(process.env.ENABLE_ARIA_REFLECTION_GLOBAL_POLYFILL)( diff --git a/packages/@lwc/integration-not-karma/test/accessibility/synthetic-cross-root-aria/index.spec.js b/packages/@lwc/integration-not-karma/test/accessibility/synthetic-cross-root-aria/index.spec.js index ec0ccf10fe..62dfe7b28b 100644 --- a/packages/@lwc/integration-not-karma/test/accessibility/synthetic-cross-root-aria/index.spec.js +++ b/packages/@lwc/integration-not-karma/test/accessibility/synthetic-cross-root-aria/index.spec.js @@ -1,8 +1,11 @@ import { createElement } from 'lwc'; -import { attachReportingControlDispatcher, detachReportingControlDispatcher } from 'test-utils'; import AriaContainer from 'x/ariaContainer'; import Valid from 'x/valid'; +import { + attachReportingControlDispatcher, + detachReportingControlDispatcher, +} from '../../../helpers/utils.js'; const expectedMessageForCrossRoot = 'Error: [LWC warn]: Element uses attribute "aria-labelledby" to reference element