MCPcopy
hub / github.com/docmirror/dev-sidecar / runTests

Function runTests

packages/core/src/modules/plugin/free-eye/client.js:91–142  ·  view source on GitHub ↗
(options = {})

Source from the content-addressed store, hash-verified

89}
90
91async function runTests (options = {}) {
92 const { testsDir, config } = options
93
94 const globalConfig = (config && typeof config === 'object') ? config : null
95 if (!globalConfig) {
96 throw new Error('FreeEye runtime config is required.')
97 }
98
99 const globalResults = {}
100 const summaries = []
101 const todoTests = await loadAllTests(testsDir, globalConfig)
102 console.log(
103 `Loaded ${todoTests.length} tests: ${
104 todoTests.map(t => t.getTestTag()).join(' ')}`,
105 )
106
107 const doneTests = []
108 while (todoTests.length > 0) {
109 const TestCls = getNextTest(todoTests, doneTests)
110 if (!TestCls) {
111 break
112 }
113
114 const testGroup = new TestCls(globalConfig, globalResults)
115 const testTag = testGroup.testTag
116 const summary = { tag: testTag, skipped: false }
117 printHeader(`${testTag} Test`, false)
118 if (testGroup.skipReason === null) {
119 const [testTime, testResults] = await testGroup.runTest()
120 summary.duration = testTime
121 summary.output = testResults
122 summary.resultSnapshot = testGroup.results
123 printHeader(`${testTag} Results: (done in ${testTime.toFixed(3)}s)`, true)
124 console.log(testResults)
125 } else {
126 summary.skipped = true
127 summary.skipReason = testGroup.skipReason
128 summary.output = `Test skipped because ${testGroup.skipReason}`
129 console.log(summary.output)
130 }
131 summaries.push(summary)
132 todoTests.splice(todoTests.indexOf(TestCls), 1)
133 doneTests.push(testTag)
134 }
135 console.log('All tests complete!')
136 return {
137 results: globalResults,
138 summaries,
139 totalTests: summaries.length,
140 completedTests: summaries.filter(item => !item.skipped).length,
141 }
142}
143
144// 独立运行时入口(CLI 模式),在 dev-sidecar 中不走此路径
145if (process.argv[1] != null && process.argv[1].endsWith('client.js')) {

Callers 2

executeTestsFunction · 0.85
client.jsFile · 0.85

Calls 6

loadAllTestsFunction · 0.85
getNextTestFunction · 0.85
printHeaderFunction · 0.85
logMethod · 0.80
runTestMethod · 0.80
getTestTagMethod · 0.45

Tested by

no test coverage detected