Replies: 1 comment
-
Not available as builtin, but a custom reporter can do something like this. https://stackblitz.com/edit/vitest-dev-vitest-as4c3dmw?file=vite.config.ts export default defineConfig({
test: {
reporters: [
'default',
{
onTestRunEnd(testModules, unhandledErrors, reason) {
const tests = testModules.flatMap((m) => [...m.children.allTests()]);
tests.sort(
(x, y) => x.diagnostic()?.duration! - y.diagnostic()?.duration!
);
tests.reverse();
console.log(
Object.fromEntries(
tests.map((t) => [
`${t.module.moduleId} | ${t.fullName}`,
t.diagnostic()?.duration,
])
)
);
},
},
],
},
}); {
'/home/projects/vitest-dev-vitest-as4c3dmw/test/suite.test.ts | suite name > snapshot': 0.9900010000001203,
'/home/projects/vitest-dev-vitest-as4c3dmw/test/basic.test.ts | Math.sqrt()': 0.7350009999936447,
'/home/projects/vitest-dev-vitest-as4c3dmw/test/suite.test.ts | suite name > foo': 0.5550000000000637,
'/home/projects/vitest-dev-vitest-as4c3dmw/test/basic.test.ts | JSON': 0.3999999999650754,
'/home/projects/vitest-dev-vitest-as4c3dmw/test/suite.test.ts | suite name > bar': 0.24000099999989288,
'/home/projects/vitest-dev-vitest-as4c3dmw/test/basic.test.ts | Squared': 0.15999999997438863
} Also test duration reporting is sometimes a part of CI platform integration. For example, I remember circleci tracks test durations over the time if you upload Vitest's junit reporter output. https://circleci.com/docs/insights-tests/#slowest-tests |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I want to print the slowest tests in Vitest. Is there any built-in way to do this? If not, can this be achieved using a custom reporter? If anyone has implemented this or has suggestions, please share.
Beta Was this translation helpful? Give feedback.
All reactions