Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
8c7ed79
test(wtr): update tests to use relative path to utils
wjhsf Aug 28, 2025
e2f88d5
test(wtr): revert removing TestUtils
wjhsf Sep 2, 2025
81275d0
test(wtr): remove useless describe
wjhsf Sep 2, 2025
39533d3
test(wtr): replace IIFE script with module import
wjhsf Sep 2, 2025
33e58c8
test(wtr): clean up SSR execution script
wjhsf Sep 2, 2025
d0b8003
test(wtr): always use DISABLE_SYNTHETIC
wjhsf Sep 3, 2025
976c002
test(wtr): enable all hydration tests
wjhsf Sep 3, 2025
8d39505
Merge branch 'master' into wjh/wtr-hyd
wjhsf Sep 4, 2025
c66afad
test(wtr): remove side effect from signals helper
wjhsf Sep 4, 2025
f1c50b0
test(wtr): import directly from file, not from barrel exporter
wjhsf Sep 4, 2025
7a73bf0
test(wtr): change bulk export statement to individual exports
wjhsf Sep 4, 2025
9b7b21b
test(wtr): remove unnecessary aria re-export
wjhsf Sep 4, 2025
9deaca2
test(wtr): fix a few more ARIA util imports
wjhsf Sep 4, 2025
1cf1275
chore: move comment for nicer aesthetic
wjhsf Sep 4, 2025
7fc137c
test(wtr): remove unused option
wjhsf Sep 4, 2025
ae937cc
test(wtr): fix another ARIA util import
wjhsf Sep 4, 2025
9250dd5
test(wtr): import directly from hooks file rather than utils
wjhsf Sep 4, 2025
d4280e8
test(wtr): import directly from signals file rather than utils
wjhsf Sep 4, 2025
bbffbf3
test(wtr): import directly from console helper rather than utils
wjhsf Sep 4, 2025
1ef88ed
test(wtr): import directly from constants helper rather than utils
wjhsf Sep 4, 2025
02f8ed1
test(wtr): only import what is needed from LWC
wjhsf Sep 4, 2025
7a5260a
test(wtr): split lwc:dynamic load helpers into separate file
wjhsf Sep 4, 2025
1a08a62
test(wtr): avoid relying on global LWC
wjhsf Sep 4, 2025
f14c829
Merge branch 'master' into wjh/wtr-smaller-utils
wjhsf Sep 9, 2025
289deeb
Merge branch 'master' into wjh/wtr-smaller-utils
wjhsf Sep 9, 2025
b97f783
test(wtr): remove unnecessary wrapping of hydration test config
wjhsf Sep 9, 2025
3cdb65c
test(wtr): remove test-utils logic from resolveImport
wjhsf Sep 9, 2025
7009a26
test(wtr): move plugin from shared config to only config that uses it
wjhsf Sep 9, 2025
19c1090
test(wtr): remove useless guid
wjhsf Sep 9, 2025
5e75329
test(wtr): remove unnecessary test-utils global
wjhsf Sep 9, 2025
497bfa8
test(wtr): clean up component definition
wjhsf Sep 9, 2025
8ff59c5
test(wtr): change component in test from IIFE to import
wjhsf Sep 11, 2025
885ce57
test(wtr): shift logic out of wrapper into static test runner file
wjhsf Sep 11, 2025
aa47c49
test(wtr): make test setup/teardown more idiomatic
wjhsf Sep 11, 2025
6185811
test(wtr): clean up module compilation
wjhsf Sep 11, 2025
ec0186f
chore(wtr): make dependency on @vitest/spy explicit
wjhsf Sep 11, 2025
3463450
test(wtr): remove console suppression
wjhsf Sep 11, 2025
7c0eb0a
test(wtr): clean up names and comments
wjhsf Sep 11, 2025
d91c8aa
Merge branch 'master' into wjh/wtr-clean-hydration
wjhsf Sep 11, 2025
371032d
Merge branch 'master' into wjh/wtr-clean-hydration
wjhsf Sep 12, 2025
c47a44d
test(wtr): move and rename file
wjhsf Sep 12, 2025
639f754
Merge branch 'master' into wjh/wtr-clean-hydration
wjhsf Sep 12, 2025
c21a895
test(wtr): remove usage of global TestUtils from hydration tests
wjhsf Sep 12, 2025
d041a23
test(wtr): remove LWC import from utils
wjhsf Sep 12, 2025
cb6213c
test(wtr): remove unused external deps
wjhsf Sep 12, 2025
2fd9ebf
Merge branch 'master' into wjh/wtr-test-utils-hydration
wjhsf Sep 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,6 @@ export default tseslint.config(
globals: {
lwcRuntimeFlags: true,
process: true,
TestUtils: true,
...globals.browser,
...globals.jasmine,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async function compileModule(input, targetSSR, format) {
}),
],

external: ['lwc', '@lwc/ssr-runtime', 'test-utils', '@test/loader'], // @todo: add ssr modules for test-utils and @test/loader
external: ['lwc', '@lwc/ssr-runtime'],

onwarn(warning, warn) {
// Ignore warnings from our own Rollup plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,9 @@ const transform = async (ctx) => {
cache,
plugins: [customLwcRollupPlugin],

// 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/loader',
// Some helper files export functions that mutate a global state. The setup file calls
// some of those functions and does not get bundled. Including the helper files in the
// bundle would create a separate global state, causing tests to fail. We don't need to
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { __unstable__ReportingControl } from 'lwc';

/**
*
* @param dispatcher
* @param runtimeEvents List of runtime events to filter by. If no list is provided, all events will be dispatched.
*/
export function attachReportingControlDispatcher(dispatcher, runtimeEvents) {
__unstable__ReportingControl.attachDispatcher((eventName, payload) => {
if (!runtimeEvents || runtimeEvents.includes(eventName)) {
dispatcher(eventName, payload);
}
});
}

export function detachReportingControlDispatcher() {
__unstable__ReportingControl.detachDispatcher();
}
5 changes: 0 additions & 5 deletions packages/@lwc/integration-not-karma/helpers/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,10 @@ import { JestAsymmetricMatchers, JestChaiExpect, JestExtend } from '@vitest/expe
import * as chai from 'chai';
import { spyOn, fn } from '@vitest/spy';
import { registerCustomMatchers } from './matchers/index.js';
import * as TestUtils from './utils.js';
import { initSignals } from './signals.js';

initSignals();

// FIXME: As a relic of the Karma tests, some test files rely on the global object,
// rather than importing from `test-utils`.
window.TestUtils = TestUtils;

// allows using expect.extend instead of chai.use to extend plugins
chai.use(JestExtend);
// adds all jest matchers to expect
Expand Down
18 changes: 0 additions & 18 deletions packages/@lwc/integration-not-karma/helpers/utils.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/*
* An as yet uncategorized mishmash of helpers, relics of Karma
*/
import { __unstable__ReportingControl } from 'lwc';

// Listen for errors thrown directly by the callback
function directErrorListener(callback) {
Expand Down Expand Up @@ -47,23 +46,6 @@ export function customElementCallbackReactionErrorListener(callback) {
: windowErrorListener(callback);
}

/**
*
* @param dispatcher
* @param runtimeEvents List of runtime events to filter by. If no list is provided, all events will be dispatched.
*/
export function attachReportingControlDispatcher(dispatcher, runtimeEvents) {
__unstable__ReportingControl.attachDispatcher((eventName, payload) => {
if (!runtimeEvents || runtimeEvents.includes(eventName)) {
dispatcher(eventName, payload);
}
});
}

export function detachReportingControlDispatcher() {
__unstable__ReportingControl.detachDispatcher();
}

export function extractDataIds(root) {
const nodes = {};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expectConsoleCallsDev } from '../../../helpers/utils.js';

export default {
props: {
isFalse: false,
Expand Down Expand Up @@ -28,7 +30,7 @@ export default {
expect(divs[i].getAttribute('data-foo')).toEqual(expectedAttrValues[i]);
}

TestUtils.expectConsoleCallsDev(consoleCalls, {
expectConsoleCallsDev(consoleCalls, {
error: [],
warn: [
'Hydration attribute mismatch on: <div> - rendered on server: data-foo=null - expected on client: data-foo="undefined"',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expectConsoleCalls } from '../../helpers/utils.js';

export default {
// server is expected to generate the same console error as the client
expectedSSRConsoleCalls: {
Expand Down Expand Up @@ -40,7 +42,7 @@ export default {
// Expect an error as one context was generated twice.
// Expect an error as one context was malformed (did not define connectContext or disconnectContext methods).
// Expect server/client context output parity (no hydration warnings)
TestUtils.expectConsoleCalls(consoleCalls, {
expectConsoleCalls(consoleCalls, {
error: [],
warn: [
'Attempted to connect to trusted context but received the following error',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expectConsoleCalls } from '../../../helpers/utils.js';

export default {
advancedTest(target, { Component, hydrateComponent, consoleSpy }) {
hydrateComponent(target, Component, {});
Expand All @@ -6,7 +8,7 @@ export default {

const consoleCalls = consoleSpy.calls;

TestUtils.expectConsoleCalls(consoleCalls, {
expectConsoleCalls(consoleCalls, {
warn: ['"hydrateComponent" expects an element that is not hydrated.'],
});
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { extractDataIds } from '../../helpers/utils.js';

export default {
props: {},
advancedTest(target, { consoleSpy }) {
const ids = Object.entries(TestUtils.extractDataIds(target)).filter(
const ids = Object.entries(extractDataIds(target)).filter(
([id]) => !id.endsWith('.shadowRoot')
);
for (const [id, node] of ids) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { expectConsoleCalls } from '../../../../helpers/utils.js';

export default {
test(target, snapshot, consoleCalls) {
// W-19087941: Expect no errors or warnings, hydration or otherwise
TestUtils.expectConsoleCalls(consoleCalls, {
expectConsoleCalls(consoleCalls, {
error: [],
warn: [],
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expectConsoleCallsDev } from '../../../helpers/utils.js';

export default {
props: {
ssr: true,
Expand All @@ -18,7 +20,7 @@ export default {
expect(p.getAttribute('data-same')).toBe('same-value');
expect(p.getAttribute('data-another-diff')).toBe('client-val');

TestUtils.expectConsoleCallsDev(consoleCalls, {
expectConsoleCallsDev(consoleCalls, {
error: [],
warn: [
'Hydration attribute mismatch on: <p> - rendered on server: title="ssr-title" - expected on client: title="client-title"',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expectConsoleCallsDev } from '../../../helpers/utils.js';

export default {
props: {
foo: 'server',
Expand All @@ -17,7 +19,7 @@ export default {
expect(div.getAttribute('data-foo')).toBe('client');
expect(div.getAttribute('data-static')).toBe('same-value');

TestUtils.expectConsoleCallsDev(consoleCalls, {
expectConsoleCallsDev(consoleCalls, {
error: [],
warn: [
'Hydration attribute mismatch on: <div> - rendered on server: data-foo="server" - expected on client: data-foo="client"',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expectConsoleCallsDev } from '../../../../helpers/utils.js';

export default {
props: {
classes: 'c1 c2 c3',
Expand All @@ -18,7 +20,7 @@ export default {
expect(p).not.toBe(snapshots.p);
expect(p.className).not.toBe(snapshots.classes);

TestUtils.expectConsoleCallsDev(consoleCalls, {
expectConsoleCallsDev(consoleCalls, {
error: [],
warn: [
'Hydration attribute mismatch on: <p> - rendered on server: class="c1 c2 c3" - expected on client: class="c2 c3 c4"',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expectConsoleCallsDev } from '../../../../helpers/utils.js';

// SSR has no class at all, whereas the client has `class="null"`.
// This is to test if hydration is smart enough to recognize the difference between a null
// attribute and the literal string "null".
Expand All @@ -21,7 +23,7 @@ export default {
expect(p).not.toBe(snapshots.p);
expect(p.className).not.toBe(snapshots.className);

TestUtils.expectConsoleCallsDev(consoleCalls, {
expectConsoleCallsDev(consoleCalls, {
error: [],
warn: [
'Hydration attribute mismatch on: <p> - rendered on server: class="" - expected on client: class="null"',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expectConsoleCallsDev } from '../../../../helpers/utils.js';

// SSR has `class="null"`, whereas the client has no class at all.
// This is to test if hydration is smart enough to recognize the difference between a null
// attribute and the literal string "null".
Expand All @@ -21,7 +23,7 @@ export default {
expect(p).not.toBe(snapshots.p);
expect(p.className).not.toBe(snapshots.className);

TestUtils.expectConsoleCallsDev(consoleCalls, {
expectConsoleCallsDev(consoleCalls, {
error: [],
warn: [
'Hydration attribute mismatch on: <p> - rendered on server: class="null" - expected on client: class=""',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expectConsoleCallsDev } from '../../../../helpers/utils.js';

export default {
props: {
classes: 'c1 c2 c3',
Expand All @@ -18,7 +20,7 @@ export default {
expect(p).toBe(snapshots.p);
expect(p.className).toBe(snapshots.classes);

TestUtils.expectConsoleCallsDev(consoleCalls, {
expectConsoleCallsDev(consoleCalls, {
error: [],
warn: [],
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expectConsoleCallsDev } from '../../../../helpers/utils.js';

export default {
props: {
classes: 'yolo',
Expand All @@ -17,7 +19,7 @@ export default {
expect(p).not.toBe(snapshots.p);
expect(p.className).toBe('');

TestUtils.expectConsoleCallsDev(consoleCalls, {
expectConsoleCallsDev(consoleCalls, {
error: [],
warn: [
'Hydration attribute mismatch on: <p> - rendered on server: class="yolo" - expected on client: class=""',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expectConsoleCallsDev } from '../../../../helpers/utils.js';

export default {
props: {
classes: '',
Expand All @@ -17,7 +19,7 @@ export default {
expect(p).not.toBe(snapshots.p);
expect(p.className).toBe('yolo');

TestUtils.expectConsoleCallsDev(consoleCalls, {
expectConsoleCallsDev(consoleCalls, {
error: [],
warn: [
'Hydration attribute mismatch on: <p> - rendered on server: class="" - expected on client: class="yolo"',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expectConsoleCallsDev } from '../../../../helpers/utils.js';

export default {
props: {
classes: '',
Expand All @@ -14,7 +16,7 @@ export default {
expect(p).toBe(snapshots.p);
expect(p.className).toBe(snapshots.classes);

TestUtils.expectConsoleCallsDev(consoleCalls, {
expectConsoleCallsDev(consoleCalls, {
error: [],
warn: [],
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expectConsoleCallsDev } from '../../../../helpers/utils.js';

export default {
props: {
ssr: true,
Expand All @@ -19,7 +21,7 @@ export default {
expect(p.className).not.toBe(snapshots.classes);
expect(p.className).toBe('c1 c2 c3');

TestUtils.expectConsoleCallsDev(consoleCalls, {
expectConsoleCallsDev(consoleCalls, {
error: [],
warn: [
'Hydration attribute mismatch on: <p> - rendered on server: class="c1 c3" - expected on client: class="c1 c2 c3"',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expectConsoleCallsDev } from '../../../../helpers/utils.js';

export default {
props: {
ssr: true,
Expand All @@ -19,7 +21,7 @@ export default {
expect(p.className).not.toBe(snapshots.classes);
expect(p.className).toBe('c1 c3');

TestUtils.expectConsoleCallsDev(consoleCalls, {
expectConsoleCallsDev(consoleCalls, {
error: [],
warn: [
'Hydration attribute mismatch on: <p> - rendered on server: class="c1 c2 c3" - expected on client: class="c1 c3"',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expectConsoleCallsDev } from '../../../../helpers/utils.js';

export default {
advancedTest(target, { Component, hydrateComponent, consoleSpy }) {
// This simulates a condition where the server-rendered markup has
Expand All @@ -11,7 +13,7 @@ export default {
hydrateComponent(target, Component, {});

const consoleCalls = consoleSpy.calls;
TestUtils.expectConsoleCallsDev(consoleCalls, {
expectConsoleCallsDev(consoleCalls, {
error: [],
warn: [
'Hydration attribute mismatch on: <x-child> - rendered on server: class="foo" - expected on client: class=""',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expectConsoleCallsDev } from '../../../../helpers/utils.js';

export default {
props: {
ssr: true,
Expand Down Expand Up @@ -25,7 +27,7 @@ export default {
expect(p).not.toBe(snapshots.p);
expect(p.className).toBe('c1 c2 c3');

TestUtils.expectConsoleCallsDev(consoleCalls, {
expectConsoleCallsDev(consoleCalls, {
error: [],
warn: [
'Hydration attribute mismatch on: <p> - rendered on server: class="c3 c2 c1" - expected on client: class="c1 c2 c3"',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expectConsoleCallsDev } from '../../../helpers/utils.js';

export default {
props: {
showAsText: true,
Expand All @@ -17,7 +19,7 @@ export default {
expect(comment.nodeType).toBe(Node.COMMENT_NODE);
expect(comment.nodeValue).toBe(snapshots.text.nodeValue);

TestUtils.expectConsoleCallsDev(consoleCalls, {
expectConsoleCallsDev(consoleCalls, {
error: [],
warn: [
'Hydration node mismatch on: #comment - rendered on server: #text - expected on client: #comment',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expectConsoleCallsDev } from '../../../helpers/utils.js';

export default {
props: {
content: '<p>test-content</p>',
Expand All @@ -21,7 +23,7 @@ export default {
expect(p).not.toBe(snapshot.p);
expect(p.textContent).toBe('different-content');

TestUtils.expectConsoleCallsDev(consoleCalls, {
expectConsoleCallsDev(consoleCalls, {
error: [],
warn: [
'Hydration innerHTML mismatch on: <div> - rendered on server: <p>test-content</p> - expected on client: <p>different-content</p>',
Expand Down
Loading