Skip to content

Commit

Permalink
chore: run Svelte 5 tests in loose parser mode (#2652)
Browse files Browse the repository at this point in the history
can help catch regressions in that area
  • Loading branch information
dummdidumm authored Jan 6, 2025
1 parent 477e76d commit 1e9cbd3
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/svelte2tsx/test/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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')
};

Expand Down Expand Up @@ -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);
}
}
}

Expand Down

0 comments on commit 1e9cbd3

Please sign in to comment.