vitest
vitest copied to clipboard
Show example chai.use example
Show how to extend vitest.chai using chai.use for existing plugins or ones that the developer creates. It's not clear in the documentation how to do this and I believe this is the place to just briefly mention it.
I am not sure if we should guide this. While we already provide built-in mocking, I'd consider using Sinon would be a bit niche and advanced usage. Guiding here might make it a bit misleading.
I am not sure if we should guide this. While we already provide built-in mocking, I'd consider using Sinon would be a bit niche and advanced usage. Guiding here might make it a bit misleading.
oh i see. What can we change the example to? The real reason here is just to show how to use Chai plugins. The documentation was somehow missing that. I had to go through a bit of digging to figure it out. Just documenting it will remove that hustle.
I am not sure if we should guide this. While we already provide built-in mocking, I'd consider using Sinon would be a bit niche and advanced usage. Guiding here might make it a bit misleading.
oh i see. What can we change the example to? The real reason here is just to show how to use Chai plugins. The documentation was somehow missing that. I had to go through a bit of digging to figure it out. Just documenting it will remove that hustle.
May you edit with the appropriate example plugin?
this would be a great addition to the documentation. since migrating to vitest, i've been using import chai from 'chai' rather than import { chai } from 'vitest' in my setup file. i didn't realize i should've been using the latter until upgrading to 0.28.4 and i started getting Invalid Chai property errors
also, as far as examples go, would showing how to modify chai.config work?
maybe something like this:
import { chai } from 'vitest'
chai.config.includeStack = true
chai.config.truncateThreshold = 0
also, as far as examples go, would showing how to modify
chai.configwork?
We support chaiConfig directly in the config now, so I don't think this is necessary.
But it would be nice to have a mention about chai.use in "Extending Matchers", but I think it should be explained in detail - not just reference other libraries, but shows how to add your own matcher.
@emahuni do you think you can add this? Or should this PR be closed?
Seems like the original author cannot work on this PR anymore (I asked if this should be closed a year ago). Feel free to open a new PR.