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

Fix: Coverages for React #14

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

sbenemerito
Copy link

@sbenemerito sbenemerito commented Jun 21, 2023

Hello to the maintainers of this repo 👋
(@shivani-sharechat @sachan-sharechat @sanjeevyadavIT)

I know this library has been marked as deprecated, but recently, I was tasked to write a report for how 'documented' our React app was, and I resorted to using this tool as I thought it was most fit for our use-case.

I'm making this pull request to hopefully resolve the following issues for getting coverage for React:

Component's name being a required definition in prop types

For example, we have a simple Component defined as:

import PropTypes from 'prop-types';
import React from 'react';

interface Props {
  active: boolean;
  testProp: string;
}

const MyTestProp = (props: Props) => {
  const { active, testProp } = props;
  return (
    <span>Hello</span>
  );
};

MyTestProp.propTypes = {
  active: PropTypes.bool.isRequired,
  testProp: PropTypes.string.isRequired,
};

export default MyTestProp;

doc-coverage apparently says MyTestProp is missing from the defined propTypes. I'm not sure we want to define an unnecessary prop type with the component's name everytime, so I thought we should remove it instead.

Please let me know if my understanding is wrong in any way 🙇

Components with no props are not being considered "covered"

When a component has no props (say the same component as above, except it's defined as something like const MyTestProp = (props: Props)), doc-coverage will say that it has 0% coverage, and is not included in the count for componentsWithStoriesOrPropTypes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant