Creating a Chai like assertion library using proxies

This page summarizes the projects mentioned and recommended in the original post on dev.to

SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
surveyjs.io
featured
InfluxDB - Power Real-Time Data Analytics at Scale
Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
www.influxdata.com
featured
  • felte

    An extensible form library for Svelte, Solid and React

  • For the past few weeks I’ve taken the (arguably pointless) work of migrating Felte from using Jest to uvu. This is a really tedious work by itself, but one of details that would have made this work even more tedious is that Jest prefers assertions to the style of expect(…).toBe* while uvu gives you freedom to choose any assertion library, although there’s an official uvu/assert module that comes with assertions to the style of assert.is(value, expected).

  • uvu

    uvu is an extremely fast and lightweight test runner for Node.js and the browser

  • For the past few weeks I’ve taken the (arguably pointless) work of migrating Felte from using Jest to uvu. This is a really tedious work by itself, but one of details that would have made this work even more tedious is that Jest prefers assertions to the style of expect(…).toBe* while uvu gives you freedom to choose any assertion library, although there’s an official uvu/assert module that comes with assertions to the style of assert.is(value, expected).

  • SurveyJS

    Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.

    SurveyJS logo
  • uvu-expect

    Chai like BDD assertions for uvu

  • This setup works really good! But there’s some minor details: The assertion errors thrown by Chai are slightly different than those expected by uvu., so sometimes I’d get messages or extra details that are not so relevant to the test itself. Another issue is that I’d receive diffs comparing undefined to undefined when an assertion failed. As a proper developer with too much free time, I went ahead and decided to experiment with writing my own assertion library built on top of uvu’s assertions that I called uvu-expect. Here’s more or less how I did it.

  • uvu-expect-dom

    Dom assertions for uvu-expect built on top of jest-dom

  • Possibility to create plugins for it using an extend function. This is how I also created a plugin for it called uvu-expect-dom which offers similar validations to @testing-library/jest-dom.

  • Sinon.JS

    Test spies, stubs and mocks for JavaScript.

  • Assertions on mock functions (compatible with sinonjs and tinyspy).

  • tinyspy

    Discontinued 🕵🏻‍♂️ minimal fork of nanospy, with more features [Moved to: https://github.com/tinylibs/tinyspy] (by Aslemammad)

  • Assertions on mock functions (compatible with sinonjs and tinyspy).

  • mocha

    ☕️ simple, flexible, fun javascript test framework for node.js & the browser

  • While this is fine and I could have perfectly moved all my tests to use said assertion style, I like the descriptive way Jest tests look like. As a quick way to maintain certain similarity I reached for ChaiJS, an assertion library that is mainly used with mocha. Chai offers expect like assertions that can arguably be more descriptive than Jest’s. Instead of writing expect(…).toBe(true), you’d write expect(…).to.be.true. For the most part I managed to do a search and replace for this.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • Road Map To Become a Web Developer

    4 projects | dev.to | 24 Jul 2023
  • Unit testing: What to use, and how?

    5 projects | /r/node | 13 Feb 2023
  • Can AI help me write tests on legacy code?

    8 projects | dev.to | 9 Feb 2023
  • Top 15 Must Have Tools For JavaScript Developers

    9 projects | dev.to | 9 Nov 2022
  • Test Svelte Component Using Vitest & Playwright

    8 projects | dev.to | 27 Jul 2022