Skip to content

jest + collectCoverage with babel-plugin-lodash results into error #3959

Closed

Description

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

What is the current behavior?

Using babel-plugin-lodash, collectCoverage enabled and a lodash function as show below imported from test file, results into an error.

import { flow, flatten } from 'lodash/fp'

// export const testFunction1 = flatten 
export const testFunction2 = flow(flatten) 

example#testFunction1 npm test will output

    /home/nam/projects/jest-babel-lodash-issue/src/example.js:3
    var testFunction1 = /* istanbul ignore next */exports.testFunction1 = ();
                                                                           ^
    
    SyntaxError: Unexpected token )

example#testFunction2 npm test will output

    ReferenceError: /home/nam/projects/jest-babel-lodash-issue/src/example.js: Container is falsy
      
      at NodePath._replaceWith (node_modules/babel-traverse/lib/path/replacement.js:170:11)

Removing collectCoverage from package.json lets the tests run without failure.
Removing babel-plugin-lodash from .babelrc or importing directly from lodash also runs without failure.

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.

https://github.com/namjul/jest-babel-lodash-issue

What is the expected behavior?
Test should run without errors.

Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.
Ubuntu 16.04.1 LTS, node v6.11.0 npm 3.10.10 also tested with node v8.1.3 npm 5.0.3

previous issue: lodash/babel-plugin-lodash#179

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions