From 1e9cbd3c3aae5152c2a5b10504bb9b01d30d4517 Mon Sep 17 00:00:00 2001 From: Simon H <5968653+dummdidumm@users.noreply.github.com> Date: Mon, 6 Jan 2025 11:07:07 +0100 Subject: [PATCH] chore: run Svelte 5 tests in loose parser mode (#2652) can help catch regressions in that area --- packages/svelte2tsx/test/helpers.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/svelte2tsx/test/helpers.ts b/packages/svelte2tsx/test/helpers.ts index 7fa3f5acf..9b50f5774 100644 --- a/packages/svelte2tsx/test/helpers.ts +++ b/packages/svelte2tsx/test/helpers.ts @@ -56,7 +56,8 @@ export class Sample { constructor( dir: string, - readonly name: string + readonly name: string, + public emitOnTemplateError = false ) { this.directory = path.resolve(dir, 'samples', name); this.folder = fs.readdirSync(this.directory); @@ -110,7 +111,7 @@ export class Sample { const sample = this; - _it(this.name, function () { + _it(this.name + (this.emitOnTemplateError ? ' (loose parser mode)' : ''), function () { try { fn(); if (sample.skipped) this.skip(); @@ -237,7 +238,7 @@ export function test_samples(dir: string, transform: TransformSampleFn, js: 'js' const config = { filename: svelteFile, sampleName: sample.name, - emitOnTemplateError: false, + emitOnTemplateError: sample.emitOnTemplateError, preserveAttributeCase: sample.name.endsWith('-foreign-ns') }; @@ -382,6 +383,9 @@ export function get_svelte2tsx_config(base: BaseConfig, sampleName: string): Sve export function* each_sample(dir: string) { for (const name of fs.readdirSync(`${dir}/samples`)) { yield new Sample(dir, name); + if (isSvelte5Plus && !fs.existsSync(`${dir}/samples/${name}/expected.error.json`)) { + yield new Sample(dir, `${name}`, true); + } } }