-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
Describe the bug
beforeAll accepts a optional teardown function returned from the callback, but there is a typecheck being performed which throws a TypeError: hook teardown value must be function, received "boolean" when truthy non-function values like true are returned. It is useful for one-liners like:
beforeAll(async () => await connectDatabase()); // if connectDatabase returns `true`, vitest throwsThis typecheck breaks compatibilty with jest which does not typecheck the return value, so I suggest vitest to just silently ignore any non-function value returned in beforeAll.
Reproduction
Works in jest but throws in vitest:
beforeAll(() => true); // TypeError: hook teardown value must be function, received "boolean"Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels