(...args: string[])
| 15 | * @param args - the spec test name to load |
| 16 | */ |
| 17 | export function loadSpecTests(...args: string[]): any[] { |
| 18 | const specPath = path.resolve(...[__dirname].concat(args)); |
| 19 | |
| 20 | const suites = fs |
| 21 | .readdirSync(specPath) |
| 22 | .filter(x => x.includes('.json')) |
| 23 | .map(x => ({ |
| 24 | ...EJSON.parse(fs.readFileSync(path.join(specPath, x), 'utf8'), { relaxed: true }), |
| 25 | name: path.basename(x, '.json') |
| 26 | })); |
| 27 | |
| 28 | for (const suite of suites) { |
| 29 | if (suite.tests && hasDuplicates(suite.tests)) { |
| 30 | throw new Error( |
| 31 | `Failed to load suite ${suite.name} because it contains duplicate test cases` |
| 32 | ); |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | return suites; |
| 37 | } |
no test coverage detected