From 39a9be9e3403e87366b2ba0f8e5e1c39860e32a6 Mon Sep 17 00:00:00 2001 From: Francesco Trotta Date: Fri, 27 Sep 2024 13:48:13 +0200 Subject: [PATCH] Fetch list of TypeScript versions dynamically --- test/spec/ts-defs.spec.mjs | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/test/spec/ts-defs.spec.mjs b/test/spec/ts-defs.spec.mjs index 2d9c83e..90e33f8 100644 --- a/test/spec/ts-defs.spec.mjs +++ b/test/spec/ts-defs.spec.mjs @@ -197,15 +197,22 @@ describe 'TypeScript definitions', () => { - describe('TypeScript 4.7', () => defineTests('typescript_4.7')); - describe('TypeScript 4.8', () => defineTests('typescript_4.8')); - describe('TypeScript 4.9', () => defineTests('typescript_4.9')); - describe('TypeScript 5.0', () => defineTests('typescript_5.0')); - describe('TypeScript 5.1', () => defineTests('typescript_5.1')); - describe('TypeScript 5.2', () => defineTests('typescript_5.2')); - describe('TypeScript 5.3', () => defineTests('typescript_5.3')); - describe('TypeScript 5.4', () => defineTests('typescript_5.4')); - describe('TypeScript 5.5', () => defineTests('typescript_5.5')); - describe('TypeScript 5.6', () => defineTests('typescript_5.6')); + const typescriptPkgNames = + (() => + { + const require = createRequire(import.meta.url); + const { devDependencies } = require('../../package.json'); + const typescriptPkgNames = + Object + .keys(devDependencies) + .filter(devDependency => /^typescript_\d+\.\d+$/.test(devDependency)); + return typescriptPkgNames; + } + )(); + for (const typescriptPkgName of typescriptPkgNames) + { + const title = typescriptPkgName.replace(/^typescript_/, 'TypeScript '); + describe(title, () => defineTests(typescriptPkgName)); + } }, );