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

bug(tests): docgen.parse #24487

Closed
muescha opened this issue May 26, 2020 · 6 comments
Closed

bug(tests): docgen.parse #24487

muescha opened this issue May 26, 2020 · 6 comments
Assignees
Labels
help wanted Issue with a clear description that the community can help with. status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. type: bug An issue or pull request relating to a bug in Gatsby

Comments

@muescha
Copy link
Contributor

muescha commented May 26, 2020

Description

i have 2 tests failing.

Steps to reproduce

yarn test

note: since i get errors when installing with yarn.lock i delete it always before yarn run bootstrap

Expected result

no error

Actual result

Summary of all failing tests
 FAIL  packages/gatsby-transformer-react-docgen/src/__tests__/displayname-handler.js
  ● DisplayNameHandler › Explicitly set displayName as static class member

    No suitable component definition found.

      14 |     ${source}
      15 |   `
    > 16 |   return docgen.parse(code, findAllComponentDefinitions, [handler])[0]
         |                 ^
      17 | }
      18 | 
      19 | describe(`DisplayNameHandler`, () => {

      at parse (node_modules/react-docgen/dist/parse.js:66:13)
      at Object.parse (node_modules/react-docgen/dist/main.js:61:29)
      at parse (packages/gatsby-transformer-react-docgen/src/__tests__/displayname-handler.js:16:17)
      at Object.<anonymous> (packages/gatsby-transformer-react-docgen/src/__tests__/displayname-handler.js:32:17)

  ● DisplayNameHandler › Infer displayName from class declaration/expression name

    No suitable component definition found.

      14 |     ${source}
      15 |   `
    > 16 |   return docgen.parse(code, findAllComponentDefinitions, [handler])[0]
         |                 ^
      17 | }
      18 | 
      19 | describe(`DisplayNameHandler`, () => {

      at parse (node_modules/react-docgen/dist/parse.js:66:13)
      at Object.parse (node_modules/react-docgen/dist/main.js:61:29)
      at parse (packages/gatsby-transformer-react-docgen/src/__tests__/displayname-handler.js:16:17)
      at Object.<anonymous> (packages/gatsby-transformer-react-docgen/src/__tests__/displayname-handler.js:67:19)

Environment

Run gatsby info --clipboard in your project directory and paste the output here:

  System:
    OS: macOS 10.15.3
    CPU: (8) x64 Intel(R) Core(TM) i7-3820QM CPU @ 2.70GHz
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 12.13.1 - ~/.nvm/versions/node/v12.13.1/bin/node
    Yarn: 1.21.0 - /usr/local/bin/yarn
    npm: 6.14.5 - ~/.nvm/versions/node/v12.13.1/bin/npm
  Languages:
    Python: 3.7.6 - /usr/local/opt/python/libexec/bin/python
  Browsers:
    Chrome: 83.0.4103.61
    Safari: 13.0.5
  npmGlobalPackages:
    gatsby-cli: 2.12.29
@muescha muescha added the type: bug An issue or pull request relating to a bug in Gatsby label May 26, 2020
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label May 26, 2020
@madalynrose madalynrose added the status: needs more info Needs triaging and reproducible examples or more information to be resolved label May 26, 2020
@madalynrose
Copy link
Contributor

Hi there, @muescha! Could you add some more detail about how to reproduce the test failures you're seeing? Which directory are you in?

@madalynrose madalynrose removed the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label May 26, 2020
@muescha
Copy link
Contributor Author

muescha commented May 26, 2020

i am in main directory and running add the tests with yarn test

(Note: I do rm -rf node_modules/ yarn.lock and then yarn run bootstrap after I fetch the master because otherwise I never get some of the node sharp things installed)

@vladar
Copy link
Contributor

vladar commented Jun 3, 2020

It happens because yarn.lock has react-docgen version pinned to 5.0.0-beta.1. And they had a breaking change in 5.0.0 which changed the way it detects react classes reactjs/react-docgen#397

I would say to fix this we should update react-docgen dependency to ^5.0.0 and fix tests. Tests that fail do not extend React.Component, e.g.:

class MyComponent { static displayName = 'foo'; render() {} }

Every entry like this should be changed to

class MyComponent extends React.Component { static displayName = 'foo'; render() {} }

P.S. A PR with the fix is very welcome!

@vladar vladar added help wanted Issue with a clear description that the community can help with. status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. and removed status: needs more info Needs triaging and reproducible examples or more information to be resolved labels Jun 3, 2020
@muescha
Copy link
Contributor Author

muescha commented Jun 4, 2020

thanks for the guide :)

i start to work on a PR

@muescha
Copy link
Contributor Author

muescha commented Jun 4, 2020

@vladar

i created an PR:

@vladar
Copy link
Contributor

vladar commented Jun 5, 2020

Fixed via #24788

@vladar vladar closed this as completed Jun 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Issue with a clear description that the community can help with. status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

No branches or pull requests

4 participants