Gathering detailed insights and metrics for prop-types-faker
Gathering detailed insights and metrics for prop-types-faker
Gathering detailed insights and metrics for prop-types-faker
Gathering detailed insights and metrics for prop-types-faker
npm install prop-types-faker
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
1 Stars
27 Commits
1 Forks
1 Watchers
21 Branches
1 Contributors
Updated on Sep 19, 2024
Latest Version
1.0.2
Package Id
prop-types-faker@1.0.2
Unpacked Size
77.66 kB
Size
24.77 kB
File Count
4
NPM Version
6.9.0
Node Version
8.15.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Generate fake props that match the propTypes data contract of your React component.
1npm install --save-dev prop-types-faker
This makes testing quite a bit easier since you don't need to write fixture data by hand for your test suites. Here's an example of how it could be used on a basic component.
Create a component to put under test:
1import React from 'react'; 2import PropTypes from 'prop-types'; 3 4// functional react component 5export const Greetings = ({ name }) => <span>{`hello ${name}!`}</span>; 6 7 8// make sure to set the propTypes 9Greetings.propTypes = { 10 name: PropTypes.string 11}
Then use generateProps
to create valid data for the component under test:
1// NOTE: this needs to be first in the imports 2import parsePropTypes from 'parse-prop-types'; 3import React from 'react'; 4import { shallow } from 'enzyme'; 5import generateFake from 'prop-types-faker'; 6import { Greetings } from './index'; 7 8 9describe('Greetings', () => { 10 let fakeProps; 11 12 beforeEach(() => { 13 fakeProps = generateFake(Greetings); 14 }); 15 16 it('should display the name', () => { 17 const expectedText = `hello ${fakeProps.name}!`; 18 19 const actual = shallow(<Greetings {...fakeProps} />) 20 21 expect(actual.find('span').text()).toBe(expectedText) 22 }); 23});
There's a demo project to show an example of how to use the library here.
Don't forget to import parsePropTypes at the top of your test files.
Feel free to open issues for bugs. I'm still shaking out some new ideas and it will probably be a bit before this library is stable.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 0/22 approved changesets -- score normalized to 0
Reason
project is archived
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
70 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More