1export enum SuiteEnum { 2 client, 3 clientWebsockets, 4 invoke, 5 unary, 6 ChunkParser, 7 cancellation, 8 detach, 9} 10 11type enumMap = {[key: string]: number} & {[key: number]: string}; 12const suiteNamesMap: enumMap = SuiteEnum as any; 13 14let specifiedSuiteName: string | undefined; 15if (typeof process.env.TEST_SUITE_NAME !== "undefined") { 16 specifiedSuiteName = process.env.TEST_SUITE_NAME; 17} else if (typeof window !== "undefined") { 18 specifiedSuiteName = window.location.hash.length > 1 ? window.location.hash.substring(1) : undefined; 19} 20export function conditionallyRunTestSuite(suite: SuiteEnum, suiteFunction: () => void) { 21 if (suiteNamesMap[suite] === undefined) { 22 throw new Error(`Unrecognised suite name: ${suite}`); 23 } 24 const suiteName = suiteNamesMap[suite]; 25 if (specifiedSuiteName) { 26 if (suiteName === specifiedSuiteName) { 27 describe(suiteName, suiteFunction); 28 } else { 29 console.log(`Skipping "${suiteName}" suite as it is not the specified suite (specifiedSuiteName is "${specifiedSuiteName}")`) 30 } 31 return; 32 } 33 describe(suiteName, suiteFunction); 34} 35