MCPcopy
hub / github.com/mongodb/node-mongodb-native / loadSpecTests

Function loadSpecTests

test/spec/index.ts:17–37  ·  view source on GitHub ↗
(...args: string[])

Source from the content-addressed store, hash-verified

15 * @param args - the spec test name to load
16 */
17export 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}

Calls 4

hasDuplicatesFunction · 0.85
mapMethod · 0.45
filterMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected