fix most of the tests

pull/14629/head
Simon Holthausen 2 years ago
parent afe0c9b48f
commit 1e8be19ff7

@ -12,6 +12,13 @@ interface CompilerErrorTest extends BaseTest {
};
}
/**
* Remove the "See https://svelte.dev/e/..." link
*/
function strip_link(message: string) {
return message.slice(0, message.lastIndexOf('\n'));
}
const { test, run } = suite<CompilerErrorTest>((config, cwd) => {
if (!fs.existsSync(`${cwd}/main.svelte`) && !fs.existsSync(`${cwd}/main.svelte.js`)) {
throw new Error('Expected main.svelte or main.svelte.js');
@ -30,7 +37,7 @@ const { test, run } = suite<CompilerErrorTest>((config, cwd) => {
caught_error = true;
expect(error.code).toBe(config.error.code);
expect(error.message).toBe(config.error.message);
expect(strip_link(error.message)).toBe(config.error.message);
if (config.error.position) {
expect(error.position).toEqual(config.error.position);
@ -55,7 +62,7 @@ const { test, run } = suite<CompilerErrorTest>((config, cwd) => {
caught_error = true;
expect(error.code).toEqual(config.error.code);
expect(error.message).toEqual(config.error.message);
expect(strip_link(error.message)).toEqual(config.error.message);
if (config.error.position) {
expect(error.position).toEqual(config.error.position);

@ -13,6 +13,13 @@ interface ValidatorTest extends BaseTest {
};
}
/**
* Remove the "See https://svelte.dev/e/..." link
*/
function strip_link(message: string) {
return message.slice(0, message.lastIndexOf('\n'));
}
const { test, run } = suite<ValidatorTest>(async (config, cwd) => {
const expected_warnings = try_load_json(`${cwd}/warnings.json`) || [];
const expected_errors = try_load_json(`${cwd}/errors.json`);
@ -40,7 +47,7 @@ const { test, run } = suite<ValidatorTest>(async (config, cwd) => {
assert.deepEqual(
warnings.map((w) => ({
code: w.code,
message: w.message,
message: strip_link(w.message),
start: { line: w.start?.line, column: w.start?.column },
end: { line: w.end?.line, column: w.end?.column }
})),
@ -56,7 +63,7 @@ const { test, run } = suite<ValidatorTest>(async (config, cwd) => {
assert.deepEqual(
{
code: error.code,
message: error.message,
message: strip_link(error.message),
start: { line: error.start?.line, column: error.start?.column },
end: { line: error.end?.line, column: error.end?.column }
},

Loading…
Cancel
Save