MCPcopy
hub / github.com/vitest-dev/vitest / createFailedFileTask

Function createFailedFileTask

packages/vitest/src/node/ast-collect.ts:287–310  ·  view source on GitHub ↗
(project: TestProject, filepath: string, error: Error)

Source from the content-addressed store, hash-verified

285}
286
287export function createFailedFileTask(project: TestProject, filepath: string, error: Error): File {
288 const testFilepath = relative(project.config.root, filepath)
289 const file: ParsedFile = {
290 filepath,
291 type: 'suite',
292 id: /* @__PURE__ */ generateHash(`${testFilepath}${project.config.name || ''}`),
293 name: testFilepath,
294 fullName: testFilepath,
295 mode: 'run',
296 tasks: [],
297 start: 0,
298 end: 0,
299 projectName: project.name,
300 meta: {},
301 pool: project.browser ? 'browser' : project.config.pool,
302 file: null!,
303 result: {
304 state: 'fail',
305 errors: serializeError(project, error),
306 },
307 }
308 file.file = file
309 return file
310}
311
312function serializeError(ctx: TestProject, error: any): TestError[] {
313 if ('errors' in error && 'pluginCode' in error) {

Callers 3

astCollectTestsFunction · 0.85

Calls 3

generateHashFunction · 0.90
serializeErrorFunction · 0.70
relativeFunction · 0.50

Tested by

no test coverage detected