Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/giogonzo/fast-check-io-ts
io-ts codec to fast-check arbitrary mapping
https://github.com/giogonzo/fast-check-io-ts
Last synced: 21 days ago
JSON representation
io-ts codec to fast-check arbitrary mapping
- Host: GitHub
- URL: https://github.com/giogonzo/fast-check-io-ts
- Owner: giogonzo
- Created: 2019-08-06T13:58:22.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-08-31T10:21:14.000Z (about 3 years ago)
- Last Synced: 2024-10-11T22:51:16.097Z (about 1 month ago)
- Language: TypeScript
- Size: 14.6 KB
- Stars: 32
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# fast-check-io-ts
[io-ts](https://github.com/gcanti/io-ts) codecs mapped to [fast-check](https://github.com/dubzzz/fast-check) arbitraries.
## Usage
```ts
import * as fc from 'fast-check';
import * as t from 'io-ts';
import { getArbitrary } from 'fast-check-io-ts';const NonEmptyString = t.brand(
t.string,
(s): s is t.Branded => s.length > 0,
'NonEmptyString'
);
const User = t.type({
name: t.string,
status: t.union([t.literal('active'), t.literal('inactive')]),
handle: NonEmptyString
});const userArb = getArbitrary(User);
console.log(fc.sample(userArb, 1)[0]); // { name: '', status: 'inactive', handle: 'M.y?>A/' }
```## Known issues
- only supports predefined `io-ts` codecs, not custom types e.g. `DateFromISOString` from `io-ts-types`
- `getArbitrary(t.keyof({ ... }))` is currently marked as error by TS, even though the codec is supported in the implementation