Migration from version 1.x
to 2.x
of fast-check should be pretty straightforward as no major breaking changes have been released.
Nonetheless as some of the changes may break existing code, a major bump has been required.
The following documentation describes what has to be updated and how in case you encounter some troubles during this migration.
Most of the time the migration will just require to run one of the following commands:
# For yarn users
yarn add fast-check@^2.0.0 --dev
# For npm users
npm install [email protected] --save-dev
The kebab-case attribute with_deleted_keys
has been removed. You should now use its camel-case version withDeletedKeys
.
fc.record(
{
first_name: fc.string(),
last_name: fc.string(),
age: fc.nat(),
}, {
--- with_deleted_keys: true
+++ withDeletedKeys: true
})
Associated Pull Requests: #749
In the previous major, fc.constantFrom
was not typing tuples properly and refused to compile some calls.
As an example, the following was not compiling:
fc.constantFrom(false, null, undefined, 0)
It required the user to explicitely specify the type:
/// In version 1.x.x
fc.constantFrom<boolean | null | number>(false, null, 0)
/// In version 2.x.x
fc.constantFrom(false, null, 0)
// or with an explicit typing
fc.constantFrom<(boolean | null | number)[]>(false, null, 0)
If you explicitely typed some calls, fc.constantFrom<T>
should be updated into fc.constantFrom
- without any generic - or fc.constantFrom<T[]>
.
Associated Pull Requests: #747
The typing for the constraints that can be applied to configure fc.object
and fc.anything
has been moved: ObjectConstraints.Settings
is now ObjectConstraints
.
All the static methods that were previously defined onto ObjectConstraints
are now fully internal.
Associated Pull Requests: #755
In the previous major, fast-check was building a specific bundle for browsers. This bundle was easily fetch-able from CDNs like unpkg.
Example of bundled version of fast-check: https://unpkg.com/browse/[email protected]/lib/bundle.js
In version 2.x.x, we removed the build for browser bundles. Some CDNs will not be able to serve fast-check properly due to this change.
If the browsers you are targeting are compatible with esm-modules, you can import fast-check from pika as follow:
<script type="module">
import fc from "https://cdn.skypack.dev/fast-check";
// code...
</script>
Alternatively, you can easily build the lib/bundle.js
file that was provided by fast-check by running the following command-line - here we assume that you declared fast-check as a dependency of your project in the package.json
.
npx -p browserify browserify node_modules/fast-check/lib/fast-check.js --s fastcheck > node_modules/fast-check/lib/bundle.js
You can also produce a minified version of the bundle by running:
npx -p browserify -p terser -c "browserify node_modules/fast-check/lib/fast-check.js --s fastcheck | terser -c -m > node_modules/fast-check/lib/bundle.js"
For support of older browsers, you may have a look to babelify.
Associated Pull Requests: #756
Support for versions of ES standard below 2017 has been removed.
If you are still using - and not transpiling towards your target - a version of Node or of the browser that does not support ES2017, you can either keep using fast-check 1.x.x or have a look into babel and related projects such as babelify.
Associated Pull Requests: #748
Support for versions of TypeScript below 3.2 has been removed.
If you are still using a version of TypeScript <3.2, you should keep using the version 1.x.x of fast-check.
Associated Pull Requests: #750