Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
babel-plugin-transform-flow-to-gen
Advanced tools
Transforms flow type aliases into generators for property based testing
This Babel plugin attempts to alleviate the manual task of creating and maintaining fixtures/mocks by transforming all Flowtype type aliases into generator functions for mock data. Additionally, it provides a framework for automatically generating random input for typed functions and React components. If you're unfamiliar with generative or property based testing, please check out an implementation of Quickcheck in your language of choice. Also look at testcheck.js which is 100% compatible and wrapped by the runtime of this library.
By running this Babel transform on your code:
TODO:
babel-plugin-transform-flow-to-gen
transforms your type aliases into functions
that create testcheck.js generators.
import {sample, types} from 'babel-plugin-transform-flow-to-gen';
type Person<T> = {
firstName: string,
lastName: string,
age: T
}
// call the function directly to return a single fixture
Person(types.number());
// {
// "firstName": "bcd2GH",
// "lastName": "oX1",
// "age": 1
// }
// use the generator static member to create samples
const personGen = Person.$GEN(types.number());
sample(personGen, 20);
// [{
// "firstName": "9OY3o",
// "lastName": "fB",
// "age": 0
// },
// {
// "firstName": "8Hft5LwfK",
// "lastName": "51Vnn54vb9xHO",
// "age": 2
// },
// {
// "firstName": "7i59Sr35GAJiv626uiV",
// "lastName": "s7GIgEf",
// "age": 3
// },
// {
// "firstName": "Mys89F65i36n921",
// "lastName": "",
// "age": 1
// }, ...]
function setFirstName(person: Person<number>, firstName: string) {
// ...
}
// returns an array of args for setFirstName
sample(setFirstName.$GEN());
// [
// [{
// "firstName": "3o",
// "lastName": "j467DA",
// "age": 0
// }, "f02j"]
// , ...]
yarn add babel-plugin-transform-flow-to-gen
MIT
FAQs
Turn flow definitions into generator functions
The npm package babel-plugin-transform-flow-to-gen receives a total of 20 weekly downloads. As such, babel-plugin-transform-flow-to-gen popularity was classified as not popular.
We found that babel-plugin-transform-flow-to-gen demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.