mirror of
https://github.com/vitest-dev/vitest.git
synced 2025-12-08 18:26:03 +00:00
22 lines
524 B
TypeScript
22 lines
524 B
TypeScript
import type { Vitest } from 'vitest/node'
|
|
import { getSuites } from '../../vitest/src/utils'
|
|
|
|
const getCircularReplacer = () => {
|
|
const seen = new WeakSet()
|
|
return (key: any, value: any) => {
|
|
if (typeof value === 'object' && value !== null) {
|
|
if (seen.has(value))
|
|
return
|
|
|
|
seen.add(value)
|
|
}
|
|
return value
|
|
}
|
|
}
|
|
|
|
export const getSuitesAsJson = (vitest: Vitest) => {
|
|
const suites = getSuites(vitest.state.getFiles()).filter(x => x)
|
|
|
|
return JSON.stringify(suites, getCircularReplacer())
|
|
}
|