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

Babel Plugin Display Name Injections Not Used in Coverage Runs #6242

Closed
louisscruz opened this issue May 23, 2018 · 3 comments
Closed

Babel Plugin Display Name Injections Not Used in Coverage Runs #6242

louisscruz opened this issue May 23, 2018 · 3 comments
Labels

Comments

@louisscruz
Copy link

🐛 Bug Report

When running --coverage, Babel transforms on components' displayNames aren't found, leading to failing tests.

I'm using this Babel plugin to change all display names of components created with react-fela: https://github.com/louisscruz/babel-plugin-transform-react-fela-display-name.

Example test failure:

    Method “simulate” is only meant to be run on a single node. 0 found instead.

       98 |       expect(wrapper).toBeOnStep('ReceivingCallStep');
       99 |
    > 100 |       wrapper.find('AcceptCallButton').simulate('click');

My understanding is that Babel Jest should be making the transformation (before being instrumented?) specified in my configuration:

const babelJest = require('babel-jest');

module.exports = babelJest.createTransformer({
  plugins: [
    require.resolve('babel-plugin-transform-class-properties'),
    require.resolve('babel-plugin-transform-decorators-legacy'),
    require.resolve('babel-plugin-inline-react-svg'),
    require.resolve('babel-plugin-import-remove-resource-query'),
    require.resolve('babel-plugin-transform-react-fela-display-name'),
  ],
  presets: [require.resolve('babel-preset-react-app')],
  babelrc: false,
});

And in my jestConfig.json:

...
  "transform": {
    ...,
    "^.+\\.(js|jsx)$": "<rootDir>/config/jest/transforms/babelTransform.js",
    ...
  }
...

But that doesn't seem to be the case.

To Reproduce

Steps to reproduce the behavior:

  • Add babel plugin that alters component displayName to your babel-jest configuration.
  • Have code that triggers a displayName injection to your code.
  • Write a test that relies on that displayName.
  • Run jest --coverage and watch your test fail.

Expected behavior

The test runs during coverage collection should use the displayName set by the Babel plugin.

Run npx envinfo --preset jest

Paste the results here:

  System:
    OS: macOS Sierra 10.12.6
    CPU: x64 Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz
  Binaries:
    Node: 8.9.3 - ~/.nvm/versions/node/v8.9.3/bin/node
    Yarn: 1.5.1 - /usr/local/bin/yarn
    npm: 5.5.1 - ~/.nvm/versions/node/v8.9.3/bin/npm
  npmPackages:
    jest: 23.0.0-beta.2 => 23.0.0-beta.2
@github-actions
Copy link

This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 14 days.

@github-actions github-actions bot added the Stale label Feb 25, 2022
@github-actions
Copy link

This issue was closed because it has been stalled for 7 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

@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 Apr 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant