Replies: 4 comments
-
|
|
Beta Was this translation helpful? Give feedback.
-
|
Does anyone know of a compatible package which does this? |
Beta Was this translation helpful? Give feedback.
-
|
It's really helpful to be able to chain tests together and reduce typing, but as the original poster mentioned, the But it seems you have to place all the If anyone has found a good workaround, I'd love to hear it. |
Beta Was this translation helpful? Give feedback.
-
|
I found a good solution. 🎉 Firstly, understand that vitest is using Chai as the underlying framework, and with Chai, expect(3).not.toBe(1).toBe(2); // this will passTo continue the chain but stop the import { chai } from 'vitest'
chai.Assertion.addProperty('is', function () {
this.__flags.negate = false;
});Now you can write tests like this: // This test now passes!
expect(3)
.not.toBe(1).toBe(2)
.is.toBe(3).toBe(3);I chose the term Would be good to see chaining and |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
👋 Hi guys,
we are currently migrating from
jesttovitest.In
jestwe used a package called jest-chain which allows you to chain matchers that are partially applied (with their own context), so f.e. anisNotis not interfering with a following matcher.We put our matchers in a setup file and they are loaded but the ability to chain them is currently missing. As soon as an
isNotis set, it's reversing the logic and outcome of the other matchers. How can we achieve this?This is the source of the chain.js of jest-chain.
Thx.
Beta Was this translation helpful? Give feedback.
All reactions