Skip to content

Commit 1e8be19

Browse files
committed
fix most of the tests
1 parent afe0c9b commit 1e8be19

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

packages/svelte/tests/compiler-errors/test.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ interface CompilerErrorTest extends BaseTest {
1212
};
1313
}
1414

15+
/**
16+
* Remove the "See https://svelte.dev/e/..." link
17+
*/
18+
function strip_link(message: string) {
19+
return message.slice(0, message.lastIndexOf('\n'));
20+
}
21+
1522
const { test, run } = suite<CompilerErrorTest>((config, cwd) => {
1623
if (!fs.existsSync(`${cwd}/main.svelte`) && !fs.existsSync(`${cwd}/main.svelte.js`)) {
1724
throw new Error('Expected main.svelte or main.svelte.js');
@@ -30,7 +37,7 @@ const { test, run } = suite<CompilerErrorTest>((config, cwd) => {
3037
caught_error = true;
3138

3239
expect(error.code).toBe(config.error.code);
33-
expect(error.message).toBe(config.error.message);
40+
expect(strip_link(error.message)).toBe(config.error.message);
3441

3542
if (config.error.position) {
3643
expect(error.position).toEqual(config.error.position);
@@ -55,7 +62,7 @@ const { test, run } = suite<CompilerErrorTest>((config, cwd) => {
5562
caught_error = true;
5663

5764
expect(error.code).toEqual(config.error.code);
58-
expect(error.message).toEqual(config.error.message);
65+
expect(strip_link(error.message)).toEqual(config.error.message);
5966

6067
if (config.error.position) {
6168
expect(error.position).toEqual(config.error.position);

packages/svelte/tests/validator/test.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ interface ValidatorTest extends BaseTest {
1313
};
1414
}
1515

16+
/**
17+
* Remove the "See https://svelte.dev/e/..." link
18+
*/
19+
function strip_link(message: string) {
20+
return message.slice(0, message.lastIndexOf('\n'));
21+
}
22+
1623
const { test, run } = suite<ValidatorTest>(async (config, cwd) => {
1724
const expected_warnings = try_load_json(`${cwd}/warnings.json`) || [];
1825
const expected_errors = try_load_json(`${cwd}/errors.json`);
@@ -40,7 +47,7 @@ const { test, run } = suite<ValidatorTest>(async (config, cwd) => {
4047
assert.deepEqual(
4148
warnings.map((w) => ({
4249
code: w.code,
43-
message: w.message,
50+
message: strip_link(w.message),
4451
start: { line: w.start?.line, column: w.start?.column },
4552
end: { line: w.end?.line, column: w.end?.column }
4653
})),
@@ -56,7 +63,7 @@ const { test, run } = suite<ValidatorTest>(async (config, cwd) => {
5663
assert.deepEqual(
5764
{
5865
code: error.code,
59-
message: error.message,
66+
message: strip_link(error.message),
6067
start: { line: error.start?.line, column: error.start?.column },
6168
end: { line: error.end?.line, column: error.end?.column }
6269
},

0 commit comments

Comments
 (0)