Summary
valid-expect currently treats some expect modifier combinations in a Jest-like way.
However, Vitest's expect API is Chai-style chainable, so not.resolves and not.rejects are valid Vitest assertions:
await expect(Promise.resolve(1)).not.resolves.toBe(2)
await expect(Promise.reject(new Error('error'))).not.rejects.toThrow('other')
These chains should not be reported as modifierUnknown.
This is different from Jest. In Jest, promise modifiers are exposed as resolves.not / rejects.not, and not.resolves / not.rejects are not part of the runtime API.
For example, this fails in Jest:
await expect(Promise.resolve(1)).not.resolves.toBe(2)
with:
TypeError: Cannot read properties of undefined (reading 'toBe')
The same assertion passes in Vitest.
Reproduction
This should be valid:
await expect(Promise.resolve(1)).not.resolves.toBe(2)
This should be reported as missing await / return:
expect(Promise.resolve(1)).not.resolves.toBe(2)
Currently, the unawaited case can be reported as modifierUnknown instead of being treated as a valid async assertion chain.
Expected behavior
valid-expect should treat not.resolves and not.rejects as valid Vitest expect chains.
They should still be treated as async assertions because resolves / rejects is present.
Notes
This should intentionally differ from eslint-plugin-jest, because Jest and Vitest expose different expect chain APIs.
This issue does not cover duplicate not chains such as not.not, since that is more about lint policy than promise modifier compatibility.
Summary
valid-expectcurrently treats some expect modifier combinations in a Jest-like way.However, Vitest's expect API is Chai-style chainable, so
not.resolvesandnot.rejectsare valid Vitest assertions:These chains should not be reported as
modifierUnknown.This is different from Jest. In Jest, promise modifiers are exposed as
resolves.not/rejects.not, andnot.resolves/not.rejectsare not part of the runtime API.For example, this fails in Jest:
with:
The same assertion passes in Vitest.
Reproduction
This should be valid:
This should be reported as missing
await/return:Currently, the unawaited case can be reported as
modifierUnknowninstead of being treated as a valid async assertion chain.Expected behavior
valid-expectshould treatnot.resolvesandnot.rejectsas valid Vitest expect chains.They should still be treated as async assertions because
resolves/rejectsis present.Notes
This should intentionally differ from
eslint-plugin-jest, because Jest and Vitest expose different expect chain APIs.This issue does not cover duplicate
notchains such asnot.not, since that is more about lint policy than promise modifier compatibility.