Coder Social home page Coder Social logo

jest-runtime's Introduction

@side/jest-runtime

Custom runtime for Jest which addresses memory leak when using Typescript

Build Status Coverage semantic-release Code Style

NOTE This package was intentionally left as JS instead of being converted to TS because it is only a slight modification of existing Jest code based on this PR

  1. Install SWC if you haven't already @swc/core @swc/jest

  2. Make sure to configure SWC if you haven't already:

    {
       "jsc": {
          "parser": {
             "syntax": "typescript",
             "decorators": true
          },
          "transform": {
             "legacyDecorator": true,
             "decoratorMetadata": true
          }
       }
    }
    
  3. Install custom runtime: yarn add @side/jest-runtime

  4. Use within jest.config.js:

    module.exports = {
      transform: {
        '^.+\\.ts$': '@swc/jest',
      },
      runtime: '@side/jest-runtime',
    };

Why?

We were seeing memory leaks using ts-jest with node >16.10. When investigating solutions this PR fixing the issue was noticed. Since it hasn't been merged, and we still wanted to share this logic, we created this lib.

jest-runtime's People

Contributors

a88zach avatar dependabot[bot] avatar prescottprue avatar renovate-bot avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jest-runtime's Issues

V8 code coverage broken when using this runtime

We're using the coverageProvider v8 in Jest 28.1.3 and have full code coverage for our app (for all code that is not ignored specifically), but are also experiencing the devastating memory leak your runtime is fixing. With your runtime enabled, a lot of previously covered lines are suddenly shown as uncovered, including imports and empty lines.

Are you aware of this issue? Would it be worth trying to pull in the latest version of https://github.com/facebook/jest/blob/main/packages/jest-runtime/src/index.ts?

Dependency Dashboard

This issue provides visibility into Renovate updates and their statuses. Learn more

Awaiting Schedule

These updates are awaiting their schedule. Click on a checkbox to get an update now.

  • Lock file maintenance

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/release.yml
  • actions/checkout v3
  • actions/setup-node v3
  • cycjimmy/semantic-release-action v2
  • actions/checkout v3
  • technote-space/workflow-conclusion-action v2.2.2
  • reside-eng/workflow-status-notification-action v1.0.7
.github/workflows/verify.yml
  • actions/checkout v3
  • actions/setup-node v3
npm
package.json
  • @commitlint/cli 17.0.2
  • @side/commitlint-config 0.1.10
  • @side/eslint-config-base 0.14.0
  • @side/eslint-config-jest 0.4.0
  • @side/prettier-config 0.0.0
  • eslint 8.17.0
  • eslint-config-prettier 8.5.0
  • eslint-plugin-jsdoc 38.1.6
  • husky 7.0.4
  • jest 28.1.1
  • lint-staged 12.5.0
  • prettier 2.7.0
  • rimraf 3.0.2
  • jest ^28
  • node >=16

  • Check this box to trigger a request for Renovate to run again on this repository

Jest v29 support

Looks like the memory leak is still there in v29, any chance to upgrade this package to support it?

Undeclared dependencies

Getting this error when using yarn to install and run this, seems you need to add jest-runtime and @jest/transform to the package.json as dependencies or peerDependencies.

@side/jest-runtime tried to access jest-runtime, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
 @side/jest-runtime tried to access @jest/transform, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Node 16 required?

Any particular reason for requiring node 16? The package seems to be working just fine on node 14 too (a CI run as a proof), and I dont see anything that would require higher version.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.