Skip to content

Instantly share code, notes, and snippets.

@pcafstockf
pcafstockf / declaw-jest.ts
Created February 19, 2022 23:37
Do you really need Jest?
/**
* If you wish to break free from the embrace->extend->imprison paradigm of Jest, this little Adapter can help you gradually break free.
* Use these methods along with the generic statements like xdescribe instead of describe.skip ('it', 'fit', 'xit', instead of 'test')
* Create your new tests using these adapters, and over time swap out your Jest specific calls in existing tests.
* Once your project is fully converted, you can simply replace Jasmine for Jest inside your package.json and all your tests should still be green.
*
* Jest+Yarn+jsdom expose your project to almost 4,000 currently open issues, and 400ish open PRs (somebody spent personal time to submit a fix, but it is still being ignored).
* For Node.js based applications, I personally just don't see the need for Jest.
*
* On a related note if you add CRA into the mix, you get an *additional* 2,000ish open issues and *another* 400ish open PRs.