Skip to content

Commit d6858a6

Browse files
committed
tidier output
1 parent 0ce8798 commit d6858a6

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

packages/svelte/tests/hydration/samples/ignore-mismatched-href/_config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,9 @@ export default test({
1111

1212
test(assert, target) {
1313
assert.equal(target.querySelector('a')?.getAttribute('href'), '/bar');
14-
}
14+
},
15+
16+
errors: [
17+
'Detected a href attribute value change during hydration. This will not be repaired during hydration, the href value that came from the server will be used. Related element:'
18+
]
1519
});

packages/svelte/tests/hydration/test.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ interface HydrationTest extends BaseTest {
3232
) => void | Promise<void>;
3333
before_test?: () => void;
3434
after_test?: () => void;
35+
errors?: any[];
3536
}
3637

3738
function read(path: string): string | void {
@@ -65,6 +66,7 @@ const { test, run } = suite<HydrationTest>(async (config, cwd) => {
6566
const snapshot = config.snapshot ? config.snapshot(target) : {};
6667

6768
const error = console.error;
69+
const errors: any[] = [];
6870
let got_hydration_error = false;
6971
console.error = (message: any) => {
7072
if (typeof message === 'string' && message.startsWith('ERR_SVELTE_HYDRATION_MISMATCH')) {
@@ -73,7 +75,7 @@ const { test, run } = suite<HydrationTest>(async (config, cwd) => {
7375
error(message);
7476
}
7577
} else {
76-
error(message);
78+
errors.push(message);
7779
}
7880
};
7981

@@ -85,12 +87,19 @@ const { test, run } = suite<HydrationTest>(async (config, cwd) => {
8587
});
8688

8789
console.error = error;
90+
8891
if (config.expect_hydration_error) {
8992
assert.ok(got_hydration_error, 'Expected hydration error');
9093
} else {
9194
assert.ok(!got_hydration_error, 'Unexpected hydration error');
9295
}
9396

97+
if (config.errors) {
98+
assert.deepEqual(errors, config.errors);
99+
} else if (errors.length) {
100+
throw new Error(`Unexpected errors: ${errors.join('\n')}`);
101+
}
102+
94103
const expected = read(`${cwd}/_expected.html`) ?? rendered.html;
95104
assert_html_equal(target.innerHTML, expected);
96105

packages/svelte/tests/runtime-browser/test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ let browser: import('@playwright/test').Browser;
1414

1515
beforeAll(async () => {
1616
browser = await chromium.launch();
17-
console.log('[runtime-browser] Launched browser');
1817
}, 20000);
1918

2019
afterAll(async () => {

0 commit comments

Comments
 (0)