From 1277dc1e3572baf1bdd28640090b24dbd4e385bd Mon Sep 17 00:00:00 2001 From: Vladimir Date: Mon, 6 May 2024 12:12:02 +0200 Subject: [PATCH] feat!: run suite hooks in a stack (#5609) --- docs/guide/migration.md | 10 +++++++++- packages/vitest/src/node/config.ts | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/guide/migration.md b/docs/guide/migration.md index c4b43242f6bb..681cb9b92213 100644 --- a/docs/guide/migration.md +++ b/docs/guide/migration.md @@ -5,7 +5,15 @@ outline: deep # Migration Guide -## Migrating from Vitest 0.34.6 +## Migrating to Vitest 2.0 + +### Hooks are running in a stack + +Before Vitest 2.0, all hooks were running in parallel. In 2.0, all hooks run serially. In addition to this, `afterAll`/`afterEach` are running in a reverse order. + +You can revert to the previous behaviour by changing [`sequence.hooks`](/config/#sequence-hooks) to `'parallel'`. + +## Migrating to Vitest 1.0 diff --git a/packages/vitest/src/node/config.ts b/packages/vitest/src/node/config.ts index 499735ca876f..9edf7b005e1d 100644 --- a/packages/vitest/src/node/config.ts +++ b/packages/vitest/src/node/config.ts @@ -513,7 +513,7 @@ export function resolveConfig( ? RandomSequencer : BaseSequencer } - resolved.sequence.hooks ??= 'parallel' + resolved.sequence.hooks ??= 'stack' if (resolved.sequence.sequencer === RandomSequencer) resolved.sequence.seed ??= Date.now()