Skip to content

Commit 4fef7a9

Browse files
committed
test(wtr): update tests to use relative path to utils
instead of weird fake module
1 parent f611598 commit 4fef7a9

File tree

57 files changed

+118
-62
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+118
-62
lines changed

packages/@lwc/integration-not-karma/helpers/test-hydrate.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import * as LWC from 'lwc';
2+
import { spyConsole } from './console';
3+
import { setHooks } from './hooks';
24

3-
window.TestUtils.setHooks({
4-
sanitizeHtmlContent: (content) => content,
5-
});
5+
setHooks({ sanitizeHtmlContent: (content) => content });
66

77
function parseStringToDom(html) {
88
return Document.parseHTMLUnsafe(html).body.firstChild;
@@ -28,7 +28,7 @@ async function runTest(ssrRendered, Component, testConfig) {
2828
let target = container.querySelector(selector);
2929

3030
let testResult;
31-
const consoleSpy = window.TestUtils.spyConsole();
31+
const consoleSpy = spyConsole();
3232
setFeatureFlags(testConfig.requiredFeatureFlags, true);
3333

3434
if (testConfig.test) {

packages/@lwc/integration-not-karma/test-hydration/attributes/falsy-mismatch/index.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { expectConsoleCallsDev } from '../../../helpers/utils.js';
12
export default {
23
props: {
34
isFalse: false,
@@ -28,7 +29,7 @@ export default {
2829
expect(divs[i].getAttribute('data-foo')).toEqual(expectedAttrValues[i]);
2930
}
3031

31-
TestUtils.expectConsoleCallsDev(consoleCalls, {
32+
expectConsoleCallsDev(consoleCalls, {
3233
error: [],
3334
warn: [
3435
'Hydration attribute mismatch on: <div> - rendered on server: data-foo=null - expected on client: data-foo="undefined"',

packages/@lwc/integration-not-karma/test-hydration/context/index.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { expectConsoleCalls } from '../../helpers/utils.js';
12
export default {
23
// server is expected to generate the same console error as the client
34
expectedSSRConsoleCalls: {
@@ -40,7 +41,7 @@ export default {
4041
// Expect an error as one context was generated twice.
4142
// Expect an error as one context was malformed (did not define connectContext or disconnectContext methods).
4243
// Expect server/client context output parity (no hydration warnings)
43-
TestUtils.expectConsoleCalls(consoleCalls, {
44+
expectConsoleCalls(consoleCalls, {
4445
error: [],
4546
warn: [
4647
'Attempted to connect to trusted context but received the following error',

packages/@lwc/integration-not-karma/test-hydration/errors/already-hydrated/index.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { expectConsoleCalls } from '../../../helpers/utils.js';
12
export default {
23
advancedTest(target, { Component, hydrateComponent, consoleSpy }) {
34
hydrateComponent(target, Component, {});
@@ -6,7 +7,7 @@ export default {
67

78
const consoleCalls = consoleSpy.calls;
89

9-
TestUtils.expectConsoleCalls(consoleCalls, {
10+
expectConsoleCalls(consoleCalls, {
1011
warn: ['"hydrateComponent" expects an element that is not hydrated.'],
1112
});
1213
},

packages/@lwc/integration-not-karma/test-hydration/inner-outer-html/index.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import { extractDataIds } from '../../helpers/utils.js';
12
export default {
23
props: {},
34
advancedTest(target, { consoleSpy }) {
4-
const ids = Object.entries(TestUtils.extractDataIds(target)).filter(
5+
const ids = Object.entries(extractDataIds(target)).filter(
56
([id]) => !id.endsWith('.shadowRoot')
67
);
78
for (const [id, node] of ids) {

packages/@lwc/integration-not-karma/test-hydration/light-dom/scoped-styles/deduped-scoped-styles/index.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import { expectConsoleCalls } from '../../../../helpers/utils.js';
12
export default {
23
test(target, snapshot, consoleCalls) {
34
// W-19087941: Expect no errors or warnings, hydration or otherwise
4-
TestUtils.expectConsoleCalls(consoleCalls, {
5+
expectConsoleCalls(consoleCalls, {
56
error: [],
67
warn: [],
78
});

packages/@lwc/integration-not-karma/test-hydration/mismatches/attrs-compatibility/index.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { expectConsoleCallsDev } from '../../../helpers/utils.js';
12
export default {
23
props: {
34
ssr: true,
@@ -18,7 +19,7 @@ export default {
1819
expect(p.getAttribute('data-same')).toBe('same-value');
1920
expect(p.getAttribute('data-another-diff')).toBe('client-val');
2021

21-
TestUtils.expectConsoleCallsDev(consoleCalls, {
22+
expectConsoleCallsDev(consoleCalls, {
2223
error: [],
2324
warn: [
2425
'Hydration attribute mismatch on: <p> - rendered on server: title="ssr-title" - expected on client: title="client-title"',

packages/@lwc/integration-not-karma/test-hydration/mismatches/attrs-expression/index.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { expectConsoleCallsDev } from '../../../helpers/utils.js';
12
export default {
23
props: {
34
foo: 'server',
@@ -17,7 +18,7 @@ export default {
1718
expect(div.getAttribute('data-foo')).toBe('client');
1819
expect(div.getAttribute('data-static')).toBe('same-value');
1920

20-
TestUtils.expectConsoleCallsDev(consoleCalls, {
21+
expectConsoleCallsDev(consoleCalls, {
2122
error: [],
2223
warn: [
2324
'Hydration attribute mismatch on: <div> - rendered on server: data-foo="server" - expected on client: data-foo="client"',

packages/@lwc/integration-not-karma/test-hydration/mismatches/class-attr/dynamic-different/index.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { expectConsoleCallsDev } from '../../../../helpers/utils.js';
12
export default {
23
props: {
34
classes: 'c1 c2 c3',
@@ -18,7 +19,7 @@ export default {
1819
expect(p).not.toBe(snapshots.p);
1920
expect(p.className).not.toBe(snapshots.classes);
2021

21-
TestUtils.expectConsoleCallsDev(consoleCalls, {
22+
expectConsoleCallsDev(consoleCalls, {
2223
error: [],
2324
warn: [
2425
'Hydration attribute mismatch on: <p> - rendered on server: class="c1 c2 c3" - expected on client: class="c2 c3 c4"',

packages/@lwc/integration-not-karma/test-hydration/mismatches/class-attr/dynamic-empty-in-ssr-null-string-in-client/index.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { expectConsoleCallsDev } from '../../../../helpers/utils.js';
12
// SSR has no class at all, whereas the client has `class="null"`.
23
// This is to test if hydration is smart enough to recognize the difference between a null
34
// attribute and the literal string "null".
@@ -21,7 +22,7 @@ export default {
2122
expect(p).not.toBe(snapshots.p);
2223
expect(p.className).not.toBe(snapshots.className);
2324

24-
TestUtils.expectConsoleCallsDev(consoleCalls, {
25+
expectConsoleCallsDev(consoleCalls, {
2526
error: [],
2627
warn: [
2728
'Hydration attribute mismatch on: <p> - rendered on server: class="" - expected on client: class="null"',

0 commit comments

Comments
 (0)