Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ava-fast-check

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ava-fast-check - npm Package Compare versions

Comparing version 3.0.0 to 4.0.0

27

lib/ava-fast-check.d.ts

@@ -1,14 +0,19 @@

import test, { ExecutionContext, ImplementationResult } from 'ava';
import test, { AfterInterface, BeforeInterface, ExecutionContext, ImplementationResult } from 'ava';
import * as fc from 'fast-check';
declare type ArbitraryTuple<Ts extends [any] | any[]> = {
export { fc, test };
declare type NonEmptyArray<A> = A[] & {
0: A;
};
declare type ArbitraryTuple<Ts extends NonEmptyArray<any>> = {
[P in keyof Ts]: fc.Arbitrary<Ts[P]>;
};
declare type Prop<Ts extends [any] | any[]> = (t: ExecutionContext, ...args: Ts) => ImplementationResult;
export declare function testProp<Ts extends [any] | any[]>(label: string, arbitraries: ArbitraryTuple<Ts>, prop: Prop<Ts>, params?: fc.Parameters<Ts>): void;
export declare namespace testProp {
const only: <Ts extends any[] | [any]>(label: string, arbitraries: ArbitraryTuple<Ts>, prop: Prop<Ts>, params?: fc.Parameters<Ts> | undefined) => void;
const failing: <Ts extends any[] | [any]>(label: string, arbitraries: ArbitraryTuple<Ts>, prop: Prop<Ts>, params?: fc.Parameters<Ts> | undefined) => void;
const skip: <Ts extends any[] | [any]>(label: string, arbitraries: ArbitraryTuple<Ts>, prop: Prop<Ts>, params?: fc.Parameters<Ts> | undefined) => void;
const serial: <Ts extends any[] | [any]>(label: string, arbitraries: ArbitraryTuple<Ts>, prop: Prop<Ts>, params?: fc.Parameters<Ts> | undefined) => void;
}
export { test, fc };
declare type Prop<Context, Ts extends NonEmptyArray<any>> = (t: ExecutionContext<Context>, ...args: Ts) => ImplementationResult;
declare type PropertyTest<Context> = <Ts extends NonEmptyArray<any>>(label: string, arbitraries: ArbitraryTuple<Ts>, prop: Prop<Context, Ts>, params?: fc.Parameters<Ts>) => void;
declare type AvaModifierWhitelist = 'only' | 'failing' | 'skip' | 'serial';
export declare type PropertyTestInterface<Context> = PropertyTest<Context> & {
[Modifier in AvaModifierWhitelist]: PropertyTest<Context>;
} & {
before: BeforeInterface<Context>;
after: AfterInterface<Context>;
};
export declare const testProp: PropertyTestInterface<unknown>;

@@ -59,3 +59,3 @@ "use strict";

exports.__esModule = true;
exports.fc = exports.test = exports.testProp = void 0;
exports.testProp = exports.test = exports.fc = void 0;
var ava_1 = require("ava");

@@ -118,11 +118,16 @@ exports.test = ava_1["default"];

}
function testProp(label, arbitraries, prop, params) {
function exposeModifier(modifier) {
return function (label, arbitraries, prop, params) {
return internalTestProp(ava_1["default"][modifier], label, arbitraries, prop, params);
};
}
exports.testProp = Object.assign(function testProp(label, arbitraries, prop, params) {
internalTestProp(ava_1["default"], label, arbitraries, prop, params);
}
exports.testProp = testProp;
(function (testProp) {
testProp.only = function (label, arbitraries, prop, params) { return internalTestProp(ava_1["default"].only, label, arbitraries, prop, params); };
testProp.failing = function (label, arbitraries, prop, params) { return internalTestProp(ava_1["default"].failing, label, arbitraries, prop, params); };
testProp.skip = function (label, arbitraries, prop, params) { return internalTestProp(ava_1["default"].skip, label, arbitraries, prop, params); };
testProp.serial = function (label, arbitraries, prop, params) { return internalTestProp(ava_1["default"].serial, label, arbitraries, prop, params); };
})(testProp = exports.testProp || (exports.testProp = {}));
}, {
only: exposeModifier('only'),
failing: exposeModifier('failing'),
skip: exposeModifier('skip'),
serial: exposeModifier('serial'),
before: ava_1["default"].before,
after: ava_1["default"].after
});

@@ -1,14 +0,19 @@

import test, { ExecutionContext, ImplementationResult } from 'ava';
import test, { AfterInterface, BeforeInterface, ExecutionContext, ImplementationResult } from 'ava';
import * as fc from 'fast-check';
declare type ArbitraryTuple<Ts extends [any] | any[]> = {
export { fc, test };
declare type NonEmptyArray<A> = A[] & {
0: A;
};
declare type ArbitraryTuple<Ts extends NonEmptyArray<any>> = {
[P in keyof Ts]: fc.Arbitrary<Ts[P]>;
};
declare type Prop<Ts extends [any] | any[]> = (t: ExecutionContext, ...args: Ts) => ImplementationResult;
export declare function testProp<Ts extends [any] | any[]>(label: string, arbitraries: ArbitraryTuple<Ts>, prop: Prop<Ts>, params?: fc.Parameters<Ts>): void;
export declare namespace testProp {
const only: <Ts extends any[] | [any]>(label: string, arbitraries: ArbitraryTuple<Ts>, prop: Prop<Ts>, params?: fc.Parameters<Ts> | undefined) => void;
const failing: <Ts extends any[] | [any]>(label: string, arbitraries: ArbitraryTuple<Ts>, prop: Prop<Ts>, params?: fc.Parameters<Ts> | undefined) => void;
const skip: <Ts extends any[] | [any]>(label: string, arbitraries: ArbitraryTuple<Ts>, prop: Prop<Ts>, params?: fc.Parameters<Ts> | undefined) => void;
const serial: <Ts extends any[] | [any]>(label: string, arbitraries: ArbitraryTuple<Ts>, prop: Prop<Ts>, params?: fc.Parameters<Ts> | undefined) => void;
}
export { test, fc };
declare type Prop<Context, Ts extends NonEmptyArray<any>> = (t: ExecutionContext<Context>, ...args: Ts) => ImplementationResult;
declare type PropertyTest<Context> = <Ts extends NonEmptyArray<any>>(label: string, arbitraries: ArbitraryTuple<Ts>, prop: Prop<Context, Ts>, params?: fc.Parameters<Ts>) => void;
declare type AvaModifierWhitelist = 'only' | 'failing' | 'skip' | 'serial';
export declare type PropertyTestInterface<Context> = PropertyTest<Context> & {
[Modifier in AvaModifierWhitelist]: PropertyTest<Context>;
} & {
before: BeforeInterface<Context>;
after: AfterInterface<Context>;
};
export declare const testProp: PropertyTestInterface<unknown>;

@@ -59,2 +59,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

import * as fc from 'fast-check';
export { fc, test };
function wrapProp(arbitraries, prop, params) {

@@ -113,11 +114,16 @@ var _this = this;

}
export function testProp(label, arbitraries, prop, params) {
function exposeModifier(modifier) {
return function (label, arbitraries, prop, params) {
return internalTestProp(test[modifier], label, arbitraries, prop, params);
};
}
export var testProp = Object.assign(function testProp(label, arbitraries, prop, params) {
internalTestProp(test, label, arbitraries, prop, params);
}
(function (testProp) {
testProp.only = function (label, arbitraries, prop, params) { return internalTestProp(test.only, label, arbitraries, prop, params); };
testProp.failing = function (label, arbitraries, prop, params) { return internalTestProp(test.failing, label, arbitraries, prop, params); };
testProp.skip = function (label, arbitraries, prop, params) { return internalTestProp(test.skip, label, arbitraries, prop, params); };
testProp.serial = function (label, arbitraries, prop, params) { return internalTestProp(test.serial, label, arbitraries, prop, params); };
})(testProp || (testProp = {}));
export { test, fc };
}, {
only: exposeModifier('only'),
failing: exposeModifier('failing'),
skip: exposeModifier('skip'),
serial: exposeModifier('serial'),
before: test.before,
after: test.after
});
{
"name": "ava-fast-check",
"version": "3.0.0",
"version": "4.0.0",
"description": " Property based testing for AVA based on fast-check",

@@ -45,4 +45,4 @@ "type": "commonjs",

"prettier": "^1.19.1",
"ts-node": "^8.10.2",
"typescript": "^3.9.6"
"ts-node": "^9.0.0",
"typescript": "^4.0.3"
},

@@ -49,0 +49,0 @@ "keywords": [

@@ -6,6 +6,6 @@ # Property based testing for AVA based on [fast-check](https://github.com/dubzzz/fast-check/)

Bring the power of property based testing framework fast-check into ava.
`ava-fast-check` simplifies the integration of fast-check into ava testing framework.
Bring the power of property based testing framework fast-check into AVA.
`ava-fast-check` simplifies the integration of fast-check into AVA testing framework.
## Getting started
## Getting Started

@@ -20,3 +20,3 @@ Install `ava-fast-check` and its peer dependencies:

```javascript
```typescript
import { testProp, fc } from 'ava-fast-check';

@@ -31,13 +31,17 @@

The property is passed [`ava`'s `t` argument](https://github.com/avajs/ava/blob/master/docs/02-execution-context.md#execution-context-t-argument) for its first parameter, and the value of each arbitrary for the current test case for the rest of the parameters.
The property is passed [AVA's `t` argument](https://github.com/avajs/ava/blob/master/docs/02-execution-context.md#execution-context-t-argument) for its first parameter, and the value of each arbitrary for the current test case for the rest of the parameters.
`ava-fast-check` supports all of [`ava`'s assertions](https://github.com/avajs/ava/blob/master/docs/03-assertions.md#assertions) and like `ava`, supports synchronous and asynchronous functions, including promises, observables, and callbacks. See [`ava`'s documentation](https://github.com/avajs/ava/blob/master/docs/01-writing-tests.md#declaring-test) for more information.
`ava-fast-check` supports all of [AVA's assertions](https://github.com/avajs/ava/blob/master/docs/03-assertions.md#assertions) and like AVA, supports synchronous and asynchronous functions, including promises, observables, and callbacks. See [AVA's documentation](https://github.com/avajs/ava/blob/master/docs/01-writing-tests.md#declaring-test) for more information.
## Advanced
If you want to forward custom parameters to fast-check, `testProp` accepts an optional `fc.Parameters` ([more](https://github.com/dubzzz/fast-check/blob/master/documentation/Runners.md#runners)).
### `fast-check` Parameters
`ava-fast-check` also comes with `.only`, `.skip` and `.failing` from `ava`.
`testProp` accepts an optional `fc.Parameters` for forwarding custom parameters to `fast-check` ([more](https://github.com/dubzzz/fast-check/blob/master/documentation/Runners.md#runners)).
```javascript
### AVA Modifiers
`ava-fast-check` also comes with [`.only`], [`.serial`] [`.skip`], and [`.failing`] modifiers from AVA.
```typescript
import { testProp, fc } from 'ava-fast-check';

@@ -49,3 +53,3 @@

testProp.failing('should be skipped', [fc.fullUnicodeString()], (t, text) => {
testProp.skip('should be skipped', [fc.fullUnicodeString()], (t, text) => {
t.is([...text].length, text.length);

@@ -55,6 +59,60 @@ });

[`.only`]: https://github.com/avajs/ava/blob/master/docs/01-writing-tests.md#running-specific-tests
[`.serial`]: https://github.com/avajs/ava/blob/master/docs/01-writing-tests.md#running-tests-serially
[`.skip`]: https://github.com/avajs/ava/blob/master/docs/01-writing-tests.md#skipping-tests
[`.failing`]: https://github.com/avajs/ava/blob/master/docs/01-writing-tests.md#failing-tests
### AVA `before`/`after` Hooks
`ava-fast-check` exposes AVA's `before`/`after` [hooks]:
```typescript
import { testProp, fc } from 'ava-fast-check';
testProp.before(t => {
connectToDatabase();
});
testProp(
// ... omitted for brevity
);
testProp.after(t => {
closeDatabaseConnection();
});
```
[hooks]: https://github.com/avajs/ava/blob/master/docs/01-writing-tests.md#before--after-hooks
### AVA Execution Context
`ava-fast-check` mirror's AVA's procedure for customizing the test [execution context]:
```typescript
import { fc, testProp as anyTestProp, PropertyTestInterface } from '../src/ava-fast-check';
type TestContext = {
state: string
};
const testProp = anyTestProp as PropertyTestInterface<TestContext>;
testProp(
'should reach terminal state',
[fc.string()],
(t, received) => {
// here t is typed as ExecutionContext<TestContext>
console.log(t.context.state); // logs 'uninitialized'
// ... omitted for brevity
}
);
```
[execution context]: https://github.com/avajs/ava/blob/master/docs/02-execution-context.md
## Minimal requirements
| ava-fast-check | ava | fast-check |
| ava-fast-check | AVA | fast-check |
|----------------|-----------------------|----------------------|
| ^4.0.0 | >=3.9.0<sup>(1)</sup> | ^2.0.0<sup>(2)</sup> |
| ^3.0.0 | >=3.9.0<sup>(1)</sup> | ^2.0.0<sup>(2)</sup> |

@@ -61,0 +119,0 @@ | ^2.0.0 | >=3.9.0<sup>(1)</sup> | ^1.0.0 |

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc