p5.js icon indicating copy to clipboard operation
p5.js copied to clipboard

Update Chai assertion library to the latest version

Open lindapaiste opened this issue 1 year ago • 6 comments

Increasing Access

It would allow users to look at the Chai documentation and be able to use any assertions that they find there.

Most appropriate sub-area of p5.js?

  • [ ] Accessibility
  • [ ] Color
  • [ ] Core/Environment/Rendering
  • [ ] Data
  • [ ] DOM
  • [ ] Events
  • [ ] Image
  • [ ] IO
  • [ ] Math
  • [ ] Typography
  • [ ] Utilities
  • [ ] WebGL
  • [ ] Build Process
  • [X] Unit Testing
  • [ ] Internalization
  • [ ] Friendly Errors
  • [ ] Other (specify if possible)

Feature enhancement details

We are using chai version ^3.5.0 but we should update it to ^5.0.0.

I tried writing a unit test with assert.notExists() but I got an error that notExists isn't a function. Updating to the latest version will enable more types of assertions like this.

lindapaiste avatar Jan 02 '24 21:01 lindapaiste

On a related note, we say in the contributor docs

Similarly we can use assert.strictEqual(myp5.keyIsPressed, true) to assert if the value is true.

Personally I would use assert.isTrue(myp5.keyIsPressed) for that because I think it's better to use more specific assertions.

lindapaiste avatar Jan 02 '24 21:01 lindapaiste

@lindapaiste I would like to have a go at it! Also, correct me if I am wrong but I think that latest release of chai is ^4.3.7

ayushanand308 avatar Jan 03 '24 07:01 ayushanand308

The latest release is 5.0.0. If there are no breaking change affecting our tests, this can go ahead and be updated.

limzykenneth avatar Jan 12 '24 13:01 limzykenneth

@ayushanand308 Are you working on this? I've too been looking to get some experience with unit tests, let me know if I can help or be a part of this issue in any way :)

diyaayay avatar Jan 13 '24 06:01 diyaayay

I tried running tests with latest Chai version and found that most of tests were failing. I am curious about how should we proceed next? I am assuming that it will require manual investigation on failing tests and fixing them?

mohitbalwani avatar Jan 14 '24 21:01 mohitbalwani

If updating the version of Chai at this point is not very straightforward, I would suggest deferring it for now and focus on the 2.0 RFC at #6678 which proposes using Vitest to run the tests. Chai is bundled with Vitest (although we can use our own version if we really want to) so handling versions should not be an issue.

limzykenneth avatar Jan 15 '24 10:01 limzykenneth