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.

TypeError: classnames is not a function when mapCoverage: true

See original GitHub issue
  • Issue

Seeing some TypeError when mapCoverage: true. I managed to reproduce the error with classnames when enabling mapCoverage, but in my full project even removing mapCoverage doesn’t work.

I have to change all imports from import React = require('react') to import * as React from 'react' too.

  • Expected behavior

work like old versions

  • Link to a minimal repo that reproduces this issue

https://github.com/fliptaboada/ts-jest-import-test

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:14 (2 by maintainers)

github_iconTop GitHub Comments

14reactions
cdeutschcommented, Oct 17, 2017

I needed to leave "allowSyntheticDefaultImports": true and setting "skipBabel": true caused new issues (as suggested here)

What finally worked for me was to change…

import * as classNames from 'classnames';

…to

import classNames from 'classnames';

Hope that helps someone else.

2reactions
staticdengcommented, Sep 28, 2018

esModuleInterop

When i use this ts config, it still has error of TypeError: classnames is not a function,Until I used the following configuration "noImplicitAny": false, The following is the complete configuration in tsconfig.json { "compilerOptions": { "target": "es5", "module": "commonjs", "jsx": "react", /*suport react*/ "sourceMap": true, "noImplicitAny": false, "strict": true, "allowSyntheticDefaultImports": true }, "exclude":[ "node_modules" ] }

Read more comments on GitHub >

github_iconTop Results From Across the Web

classnames_1.default is not a function when testing with Jest
I just want to see if element has specific class when loaded. classnames is simply js library to return single string of classnames...
Read more >
Configuring Jest
Thresholds for globs are applied to all files matching the glob. If the file specified by path is not found, an error is...
Read more >
Maps JavaScript API Release Notes - Google Developers
Introduces a language parameter to Geocoder JS API. Maps JS API no longer considers US as a default region in Geocoder if it's...
Read more >
TypeError: .map is not a function : r/react - Reddit
I created this React application to practice the fetch API. However, while writing the code to display the data on the browser via...
Read more >
@jest/reporters | Yarn - Package Manager
main. Features. Fixes. Chore & Maintenance. Performance. 29.3.1. Fixes. [jest-config] Do not warn about preset in ProjectConfig #13583 ...
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