Code Monkey home page Code Monkey logo

jest-it-up's Introduction

Hi there ๐Ÿ‘‹

I'm Rafael, a frontend developer in the Amsterdam Area. Creator of Carteiro, a popular and highly-rated Android package tracking app in Brazil, as well as several open source projects.

Stats Top Languages by Repo Top Languages by Commit

jest-it-up's People

Contributors

jcorpe26 avatar juzerzarif avatar peteryinusa avatar rbardini avatar saunders1989 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

jest-it-up's Issues

Make jest-it-up only increase coverage thresholds only to master (or specified) branch

Probably more of an enhancement request but here goes:

REQUEST:
Is there any way to add to the config to have jest-it-up only make adjustments to the master branch (or any specified set of branches)?

Was thinking that it could check the branch name or commits for the word master or something to that degree.

USE CASE:
We have a develop branch that serves as more of a playground and sometimes need to get code up quickly for integration testing as well as asynchronous unit/automation test writing while in a live ENV.

Could this be added or is there any unforeseen negative outcome to doing this?

Thanks

Read coverage dir path from jest config

The coverage directory is hard coded to look at cwd/coverage currently. This doesn't allow for custom coverage directory locations which is something that jest allows via its config. I see the config is already being read here https://github.com/rbardini/jest-it-up/blob/master/lib/getData.js#L4 so the coverageDirectory option could just be read from there (defaulting to the cwd/coverage if undefined).

In the same vein, it would also be nice to have the ability to provide a custom jest config path.

I'd be willing to put up a PR if this is something you'd be cool with supporting ๐Ÿ˜‡.

When using jest-it-up as a reporter in Jenkins file, throws TypeError, Not a constructor

  • `11:55:37 > [email protected] test /build/workspace/oslo_event-ui_PR-18096/pkgs/event-widgets
  • 11:55:37 > TZ=Pacific/Tongatapu BABEL_ENV=node jest "--maxWorkers=30%" "--reporters=default" "--reporters=jest-it-up"
  • 11:55:37
  • 11:55:38 > TypeError: An error occurred while adding the reporter at path "/build/workspace/oslo_event-ui_PR-18096/node_modules/.pnpm/[email protected]/node_modules/jest-it-up/lib/index.js".Reporter is not a constructor`

Not sure but module is exported as an arrow function thus it might be not able to initialise with new !

Support non-global coverageThreshold

Currently this lib only support reading the global coverageThreshold, it would be nice to support bumping it for others too, eg:

coverageThreshold: {
  global: {
    branches: 100,
    functions: 100,
    lines: 100,
    statements: 100,
  },
  './src/some-dir/': {
    branches: 80,
    functions: 81,
    lines: 90,
    statements: 83,
  },
  './src/some-other-dir/': {
    branches: 100,
    functions: 100,
    lines: 100,
    statements: 100,
  },
},

Rounding?

I'd like to have it only bump coverage numbers down to the nearest whole value. Is there an option for this that I'm not seeing? Threshold appears to still set it to the thousandths place once you cross the threshold.

We're having a lot of issues with merge conflicts on the jest config because the coverage values change for every single PR.

Allow to specify jest config

We're using jest.config.cjs in our project to work correctly in out esm package. Jest-it-up has a hardcoded path to jest.config.js which prevents us to work with this. Would it be possible to add a parameter to specify config file path?

I'm happy to provide PR with this change.

Can't make it work with Next Js 12

Hello There! have been a promoter of this project for a while in my work because it helps me keep the demons at bay with the unit testing, thank you very much for it. Recently I found myself trying Next JS 12 and for some reason, I couldn't use jest-it-up with the createJestConfig export. The steps to reproduce:

  1. follow the getting started tutorial
  2. follow the setting up jest with the rust compiler tutorial
  3. you end up with a jest.config.js like this:
// jest.config.js
const nextJest = require('next/jest')

const createJestConfig = nextJest({
  dir: './',
})

const customJestConfig = {
  // typical jest configuration export attributes
  // An object that configures minimum threshold enforcement for coverage results
  coverageThreshold: {
    global: {
      branches: 32.69,
      functions: 36.19,
      lines: 43.34,
      statements: 43.46,
    },
  },
  moduleDirectories: ['node_modules', '<rootDir>/'],
  testEnvironment: 'jest-environment-jsdom',
}

module.exports = createJestConfig(customJestConfig)

but what i get on post test execution is

C:\git\omneural\frontend\node_modules\jest-it-up\lib\getData.js:6
    coverageThreshold: { global: thresholds },
                                 ^

TypeError: Cannot read properties of undefined (reading 'global')
    at getData (C:\git\omneural\frontend\node_modules\jest-it-up\lib\getData.js:6:34)
    at module.exports (C:\git\omneural\frontend\node_modules\jest-it-up\lib\index.js:20:37)
    at Object.<anonymous> (C:\git\omneural\frontend\node_modules\jest-it-up\bin\jest-it-up:15:1)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)
    at node:internal/main/run_main_module:17:47

from what I read in your code you are expecting the coverage to be at a root level in the file directly,
currently runing a package.json

{  
   ...
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "export": "next export",
    "lint": "next lint",
    "test": "jest --coverage=true --notify",
    "posttest": "jest-it-up",
    "test:watch": "yarn test --watch",
    "prepare": "cd ../ && husky install ./frontend/.husky",
    "coverage": "jest --coverage --ci --silent --coverageReporters=cobertura"
  },
  "lint-staged": {
    "**/*.{js,jsx}": [
      "yarn lint",
      "yarn coverage"
    ]
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "next": "^12.1.2",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
  },
  "devDependencies": {
    "@testing-library/dom": "^8.13.0",
    "@testing-library/jest-dom": "^5.16.4",
    "@testing-library/react": "^12.1.5",
    "@testing-library/react-hooks": "^7.0.2",
    "@testing-library/user-event": "^13.2.1",
    "cz-conventional-changelog": "^3.1.0",
    "eslint": "^8.11.0",
    "eslint-config-next": "^12.1.0",
    "jest-canvas-mock": "^2.3.0",
    "jest": "^27.5.1",
    "jest-it-up": "^2.0.0",
    "lint-staged": "^11.0.0",
    "node-notifier": "^10.0.1",
    "stage": "^1.0.0"
  },
  "config": {
    "commitizen": {
      "path": "cz-conventional-changelog"
    }
  }
}

Minimum coverage?

Depending on the company/team's goals, they may prefer to have a minimum of coverage, and understand that they don't need to reach 100%.
Does it make sense to think of a solution within jest-it-up? Example: jest-it-up --minimum 70

Read coverage directory from package.json

Our Jest config is currently part of our package.json, and jest-it-up seems unable to detect it. Is there a way around this, or would you be willing to add this as an enhancement?

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.