-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
p3-minor-bugAn edge case that only affects very specific usage (priority)An edge case that only affects very specific usage (priority)
Description
Describe the bug
Based on this reproduction: https://stackblitz.com/edit/vitest-dev-vitest-w9khjv?file=test%2Fbasic.test.ts,test%2Fsuite.test.ts,vitest.config.ts&initialPath=__vitest__/
The following code:
import { assert, expect, test } from 'vitest';
console.log({ testPathOutside: expect.getState().testPath });
test('Math.sqrt()', () => {
console.log({ testPathInside: expect.getState().testPath });
// ...
});yields:
stdout | test/basic.test.ts
{
"testPathOutside": undefined,
}
stdout | test/basic.test.ts > Math.sqrt()
{
"testPathInside": "/home/projects/vitest-dev-vitest-qq8ndy/test/basic.test.ts",
}
I'd expect that expect.getState().testPath would always work when invoked in the file, regardless of its position. Seems like it also yields undefined when called inside of describe calls.
Reproduction
System Info
-Used Package Manager
pnpm
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.
Metadata
Metadata
Assignees
Labels
p3-minor-bugAn edge case that only affects very specific usage (priority)An edge case that only affects very specific usage (priority)