Refactor any mocha/ava tests to use Jest
See original GitHub issueBackground
Each package in /packages has a test command in package.json. Over time our team tried different testing frameworks in different packages but now we are starting to standardise around using Jest.
It would be really beneficial if we could use the one test runner across all packages. For anybody interested in picking up this issue I suggest that the tasks below are worked on in separate Pull Requests.
- (Done in #198) offix-cache is currently using
mocha. This previous commit shows how we migrated frommochatojestin offix-offline which had the exact same setup. Migration should be really simple. - (Done in #194)
offix-conflicts-serveris usingava. It shouldn’t be too hard to also migrate that. - (Done in #209)
offix-clientis usingjestfor its unit tests but it uses a combination ofkarmaandmochato run theintegration-testcommand. Karma is a tool that lets us run our tests in a headless browser but the test files themselves are regularmocha. There is akarmaconfig file in offix-client that specifies mocha. I would say the migration will be simple enough and will require a small bit of research in the karma docs to find how to use Karma + Jest.
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
6 stages of refactoring a Jest test case
An underrated feature of Jest is customizing the way assertion errors that the console displays when tests fail are handled.
Read more >Jest Testing like a Pro - Tips and tricks
When you run Jest, tests are run by file, within that file you can have groups of related tests, which you put under...
Read more >Configuring Jest
This option provides the default configuration of fake timers for all tests. Calling jest.useFakeTimers() in a test file will use these ...
Read more >How to refactor my test to use Jest's Manual Mock feature?
I am able to get a basic test working with Jest, but when I try to refactor it to use Jest's manual mocks...
Read more >Refactoring: from strategy to interpreter pattern with Jest ...
Jest Unit Tests. Before we start implementing any solutions, we install Jest and configure it to be run with Typescript classes: npm i...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Is there documentation for the integration tests? I tried analyzing the code but it’s quite sizeable, this migration seems like an issue on its own, also considering they are in JavaScript, maybe it would be preferable to standardize TypeScript and possibly using the same
/test/folder for both tests, and filename conventions for Jest pattern matching like so:I investigated further and found out you the project runs Chrome Headless on Karma, Puppeteer (Headless Chrome Node.js API) can be implemented with Jest and there’s documentation on it. This could be separated into tasks to achieve a full, better implementation of the current integration tests.
In proposed form this will be task for maintainer. I think we might just create couple smaller tasks for this with hacktoberfest label or do this ourselves