Using fusspot for more than validation?
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 11
- Forks
- 5
- PR merge metrics
- No merged PRs in 30d
Description
TLDR: Certain functions in node.js application could benefit from fusspot's parameter validation. This could be used as a sort of react-props for node.js which validates only when running the tests.
A lot of times a simple typo could silently sneak in and cause unexpected behaviour. In the example below, emphasise would remain falsy since foo gets the wrong parameter property.
const foo = ({ abc, xyz, tgif, emphasise }) => {
if (emphasise) {
return chalk.bold('I am emphasised');
}
}
foo({ abc, xyz, tgif, emphasize }); // a simple American to British glitch
Also, if a fellow developer decides to change foo's parameter schema, she/he needs to dig into all the call sites of foo to fix it. These problems aren't anything new and can be carefully fixed with unit testing.
My proposal is that we use fusspot along with unit testing to write less test cases and catch bugs early on. A function could be wrapped around an assertion function (v.assertParams?) and the code would only validate when running tests i.e. NODE_ENV=test else it would simply be a passthrough (for performance reasons).
One of the drawbacks of this approach would be that we would need to write the parameters at two places and keep them in sync. Also, it is a non standard solution and might throw some people off.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing fusspot's existing assertion capabilities and the proposed v.assertParams-style wrapper. Clarify the API, how NODE_ENV=test should control validation, and how unit tests would demonstrate parameter mismatches and passthrough behavior; the issue mentions no files or existing tests to begin with.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100