MCPcopy Create free account
hub / github.com/Dart-Code/Dart-Code / run

Function run

src/test/test_runner.ts:38–87  ·  view source on GitHub ↗
(testsRoot: string)

Source from the content-addressed store, hash-verified

36 getTestSuites,
37
38 async run(testsRoot: string): Promise<void> {
39 console.log("\nStarting test runner...\n");
40
41 // Create the mocha test
42 const mocha = new Mocha({
43 color: true,
44 forbidOnly: !!process.env.MOCHA_FORBID_ONLY,
45 reporter: MultiReporter,
46 reporterOptions: {
47 output: process.env.TEST_XML_OUTPUT,
48 testRunName: process.env.TEST_RUN_NAME,
49 },
50 retries: isCI ? 2 : 0, // Retry failing tests to reduce flakes
51 slow: 20000, // increased threshold before marking a test as slow
52 timeout: 360000, // increased timeout because starting up Code, Analyzer, Pub, etc. is slooow
53 ui: "bdd", // the TDD UI is being used in extension.test.ts (suite, test, etc.)
54 });
55
56 // Set up source map support.
57 // eslint-disable-next-line @typescript-eslint/no-require-imports
58 require("source-map-support").install();
59
60 return new Promise(async (resolve, reject) => {
61 try {
62 const testFilter = process.env.DART_CODE_TEST_FILTER;
63 const filters: string[] | undefined = testFilter ? JSON.parse(testFilter) : undefined;
64 const files = await getTestSuites(testsRoot, filters);
65
66 // Add files to the test suite
67 files.forEach((f) => mocha.addFile(f));
68
69 if (files.length === 0) {
70 console.log(`No test files found.`);
71 resolve();
72 return;
73 }
74
75 // Run the mocha test
76 mocha.run((failures) => {
77 if (failures > 0) {
78 reject(new Error(`${failures} tests failed.`));
79 } else {
80 resolve();
81 }
82 });
83 } catch (err) {
84 return reject(err);
85 }
86 });
87 },
88};

Callers

nothing calls this directly

Calls 2

getTestSuitesFunction · 0.85
logMethod · 0.45

Tested by

no test coverage detected