Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mappedCoverage.addStatement is not a function #3560

Closed
screendriver opened this issue May 12, 2017 · 9 comments
Closed

mappedCoverage.addStatement is not a function #3560

screendriver opened this issue May 12, 2017 · 9 comments
Assignees

Comments

@screendriver
Copy link
Contributor

Do you want to request a feature or report a bug?

A bug.

What is the current behavior?

I updated my project to Jest 20.0.1 and updated ts-jest to 20.0.3 as well. I tried out the new coverage feature and get following error:

UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: mappedCoverage.addStatement is not a function

If the current behavior is a bug, please provide the steps to reproduce and either a repl.it demo through https://repl.it/languages/jest or a minimal repository on GitHub that we can yarn install and yarn test.

You can find a repo here

What is the expected behavior?

Report test coverage.

Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.

"jest": {
    "globals": {
      "__TS_CONFIG__": "./test/tsconfig.json"
    },
    "transform": {
      ".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js"
    },
    "testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
    "testPathIgnorePatterns": [
      "<rootDir>/build"
    ],
    "snapshotSerializers": [
      "enzyme-to-json/serializer"
    ],
    "setupTestFrameworkScriptFile": "./test/setupTestFramework.ts",
    "mapCoverage": true,
    "moduleFileExtensions": [
      "ts",
      "tsx",
      "js"
    ],
    "moduleNameMapper": {
      "\\.(svg|woff|ttf|eot)$": "<rootDir>/test/__mocks__/fileMock.js",
      "\\.(css)$": "<rootDir>/test/__mocks__/styleMock.js"
    },
    "setupFiles": [
      "./test/setupJest.ts"
    ]
  },

There is also an issue at the ts-jest project: kulshekhar/ts-jest#211 We are not really sure if this is a ts-jest or a Jest issue 🤔

@GeeWee
Copy link

GeeWee commented May 21, 2017

This only happens when piping the tsc output through babel-jest.

@cpojer
Copy link
Member

cpojer commented Aug 24, 2017

Probably a ts-jest issue.

@cpojer cpojer closed this as completed Aug 24, 2017
@dzyhenry
Copy link

dzyhenry commented May 30, 2018

I meet a "TypeError: mappedCoverage.addStatement is not a function" error while using
without using jest's "istanbul-lib-source-maps" functionality, the whole information is as below:

TypeError: mappedCoverage.addStatement is not a function
at /tmp/build/src/node_modules/jest-cli/node_modules/istanbul-lib-source-maps/lib/transformer.js:97:28
at Array.forEach ()
at SourceMapTransformer.processFile (/tmp/build/src/node_modules/jest-cli/node_modules/istanbul-lib-source-maps/lib/transformer.js:88:34)
at /tmp/build/src/node_modules/jest-cli/node_modules/istanbul-lib-source-maps/lib/transformer.js:169:24
at Array.forEach ()
at SourceMapTransformer.transform (/tmp/build/src/node_modules/jest-cli/node_modules/istanbul-lib-source-maps/lib/transformer.js:159:25)
at MapStore.transformCoverage (/tmp/build/src/node_modules/jest-cli/node_modules/istanbul-lib-source-maps/lib/map-store.js:143:8)
at /tmp/build/src/node_modules/jest-cli/build/reporters/coverage_reporter.js:115:57
at Generator.next ()
at step (/tmp/build/src/node_modules/jest-cli/build/reporters/coverage_reporter.js:63:191)

PS:
jest version: 22.4.3 and 23.0.1
In my case, there is nothing related with "ts-jest"

@SimenB
Copy link
Member

SimenB commented May 30, 2018

Please open up a new issue with reproduction steps

@MedinaGitHub

This comment has been minimized.

@SimenB

This comment has been minimized.

@MedinaGitHub
Copy link

this solution work me

rm -rf $TMPDIR/react-* && watchman watch-del-all && npm cache clean --force && npm run jest --clearCache

@kopax
Copy link

kopax commented Dec 19, 2019

I am not using ts-jest and I also have this error with expo sdk 36.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants