Open matthew-white opened 3 months ago
We had to move from Should.js to Chai in Frontend
Is there any background on what forced the change?
Would it be acceptable to replace should
incrementally? E.g. in different test suites individually?
We had to move from Should.js to Chai in Frontend
Is there any background on what forced the change?
I'm working on replacing Vue CLI with Vite (getodk/central-frontend#671). As part of that, I'm replacing Karma with Vitest (specifically, Vitest's browser mode). However, Should.js doesn't play well with Vitest: I see an error when I try to use it. I think it's because Should.js doesn't play well with ES Modules.
It actually didn't take too long to replace Should.js with Chai in Frontend, which is part of what made me think that we might as well make the switch in Backend as well. I like that Chai is much better documented and that it's maintained.
Would it be acceptable to replace
should
incrementally? E.g. in different test suites individually?
I think it'd be reasonable for migration tests to start using Chai right away. If anything, it'd be one fewer instance of Should.js for us to convert later. 😅
Chai has three options for assertion style: assert
, expect
, and should
. I adopted the should
style in Frontend, since that allowed me to minimize the number of changes. However, like Should.js, the should
style of Chai extends Object.prototype
, so I don't think that Should.js and Chai can coexist in tests that are run together. It's not like one integration test could use Should.js while another uses Chai. But since migration tests are separate, I think it would work for them to use Chai from the start.
Should.js hasn't been updated on npm since 2018, and its repo is archived. We had to move from Should.js to Chai in Frontend (getodk/central-frontend#1015). There are a lot of similarities between the two, but Chai is better documented. There are also some differences, and I think trying to remember those differences while switching between Backend and Frontend will end up causing friction. This issue is to replace Should.js with Chai in Backend. We should time work on this issue such that no large Backend work is in progress.