question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Refactor any mocha/ava tests to use Jest

See original GitHub issue

Background

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 from mocha to jest in offix-offline which had the exact same setup. Migration should be really simple.
  • (Done in #194) offix-conflicts-server is using ava. It shouldn’t be too hard to also migrate that.
  • (Done in #209) offix-client is using jest for its unit tests but it uses a combination of karma and mocha to run the integration-test command. Karma is a tool that lets us run our tests in a headless browser but the test files themselves are regular mocha. There is a karma config 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:closed
  • Created 4 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
dewstendcommented, Oct 11, 2019

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:

└───test
    ├───int
    │       File.int.test.ts
    │
    └───unit
            File.unit.test.ts

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.

0reactions
wtrockicommented, Oct 14, 2019

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found