-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds tests for CreateMessage function #5
Conversation
Example of PR titles that include pivotal stories:
New dependencies added: @types/jestAuthor: Unknown Description: TypeScript definitions for Jest Homepage: http://npmjs.com/package/@types/jest
|
Created | over 1 year ago |
Last Updated | 22 days ago |
License | MIT |
Maintainers | 1 |
Releases | 52 |
Direct Dependencies | pure-rand and tslib |
Keywords | property-based testing, end-to-end testing, unit testing, testing, quickcheck, jscheck and jsverify |
README
Property based testing framework for JavaScript/TypeScript
Getting started
Hands-on tutorial and definition of Property Based Testing: 🏁 see tutorial.
Property based testing frameworks check the truthfulness of properties. A property is a statement like: for all (x, y, ...) such as precondition(x, y, ...) holds property(x, y, ...) is true.
Install the module with: npm install fast-check --save-dev
Example of integration in mocha:
const fc = require('fast-check');
// Code under test
const contains = (text, pattern) => text.indexOf(pattern) >= 0;
// Properties
describe('properties', () => {
// string text always contains itself
it('should always contain itself', () => {
fc.assert(fc.property(fc.string(), text => contains(text, text)));
});
// string a + b + c always contains b, whatever the values of a, b and c
it('should always contain its substrings', () => {
fc.assert(fc.property(fc.string(), fc.string(), fc.string(), (a,b,c) => contains(a+b+c, b)));
});
});
In case of failure, the test raises a red flag. Its output should help you to diagnose what went wrong in your implementation. Example with a failing implementation of contain:
1) should always contain its substrings
Error: Property failed after 1 tests (seed: 1527422598337, path: 0:0): ["","",""]
Shrunk 1 time(s)
Got error: Property failed by returning false
Hint: Enable verbose mode in order to have the list of all failing values encountered during the run
Integration with other test frameworks:
ava,
jasmine,
jest,
mocha
and
tape.
More examples:
simple examples,
fuzzing
and
against various algorithms.
Useful documentations:
- 🏁 Introduction to Property Based & Hands On
- 🐣 Built-in arbitraries
- 🔧 Custom arbitraries
- 🏃♂️ Property based runners
- 💥 Tips
- 🔍 Generated documentation
Why should I migrate to fast-check?
fast-check has initially been designed in an attempt to cope with limitations I encountered while using other property based testing frameworks designed for JavaScript:
- Types: strong and up-to-date types - thanks to TypeScript
- Extendable: easy
map
method to derive existing arbitraries while keeping shrink [more] - some frameworks ask the user to provide both a->b and b->a mappings in order to keep a shrinker - Extendable: kind of flatMap-operation called
chain
[more] - able to bind the output of an arbitrary as input of another one while keeping the shrink working - Extendable: precondition checks with
fc.pre(...)
[more] - filtering invalid entries can be done directly inside the check function if needed - Smart: ability to shrink on
fc.oneof
[more] - surprisingly some frameworks don't - Smart: biased by default [more] - by default it generates both small and large values, making it easier to dig into counterexamples without having to tweak a size parameter manually
- Debug: verbose mode [more] - easier troubleshooting with verbose mode enabled
- Debug: replay directly on the minimal counterexample [more] - no need to replay the whole sequence, you get directly the counterexample
- Debug: custom examples in addition of generated ones [more] - no need to duplicate the code to play the property on custom examples
- Debug: logger per predicate run [more] - simplify your troubleshoot with fc.context and its logging feature
- Unique: model based approach [more][article] - use the power of property based testing to test UI, APIs or state machines
For more details, refer to the documentation in the links above.
Issues found by fast-check in famous packages
fast-check has been able to find some unexpected behaviour among famous npm packages. Here are some of the errors detected using fast-check:
js-yaml
Issue detected: enabling !!int: binary
style when dumping negative integers produces invalid content [more]
Code example: yaml.dump({toto: -10}, {styles:{'!!int':'binary'}})
produces toto: 0b-1010
not toto: -0b1010
query-string
Issue detected: enabling the bracket
setting when exporting arrays containing null values produces an invalid output for the parser [more]
Code example:
m.stringify({bar: ['a', null, 'b']}, {arrayFormat: 'bracket'}) //=> "bar[]=a&bar&bar[]=b"
m.parse('bar[]=a&bar&bar[]=b', {arrayFormat: 'bracket'}) //=> {bar: [null, 'b']}
jest
Author: Unknown
Description: Delightful JavaScript Testing.
Homepage: https://jestjs.io/
Created | over 7 years ago |
Last Updated | about 2 months ago |
License | MIT |
Maintainers | 6 |
Releases | 220 |
Direct Dependencies | import-local and jest-cli |
Keywords | ava, babel, coverage, easy, expect, facebook, immersive, instant, jasmine, jest, jsdom, mocha, mocking, painless, qunit, runner, sandboxed, snapshot, tap, tape, test, testing, typescript and watch |
README
Jest
🃏 Delightful JavaScript Testing
-
👩🏻💻 Developer Ready: Complete and ready to set-up JavaScript testing solution. Works out of the box for any React project.
-
🏃🏽 Instant Feedback: Failed tests run first. Fast interactive mode can switch between running all tests or only test files related to changed files.
-
📸 Snapshot Testing: Jest can capture snapshots of React trees or other serializable values to simplify UI testing.
Read More: https://jestjs.io/
ts-jest
Author: Kulshekhar Kabra
Description: A preprocessor with source maps support to help use TypeScript with Jest
Homepage: https://kulshekhar.github.io/ts-jest
Created | almost 3 years ago |
Last Updated | 4 months ago |
License | MIT |
Maintainers | 3 |
Releases | 98 |
Direct Dependencies | bs-logger , buffer-from , fast-json-stable-stringify , json5 , make-error , mkdirp , resolve , semver and yargs-parser |
Keywords | jest, typescript, sourcemap, react and testing |
README
ts-jest
ts-jest
is a TypeScript preprocessor with source map support for Jest that lets you use Jest to test projects written in TypeScript.
It supports all features of TypeScript including type-checking. Read more about Babel7 + preset-typescript
vs TypeScript (and ts-jest
).
We are not doing semantic versioning and 23.10 is a re-write, run npm i -D ts-jest@"<23.10.0" to go back to the previous version |
---|
View the online documentation (usage & technical)
Ask for some help in the ts-jest
community of Slack
We're looking for collaborators! Want to help improve ts-jest
?
Getting Started
These instructions will get you setup to use ts-jest
in your project. For more detailed documentation, please check online documentation.
using npm | using yarn | |
---|---|---|
Prerequisites | npm i -D jest typescript |
yarn add --dev jest typescript |
Installing | npm i -D ts-jest @types/jest |
yarn add --dev ts-jest @types/jest |
Creating config | npx ts-jest config:init |
yarn ts-jest config:init |
Running tests | npm t or npx jest |
yarn test or yarn jest |
Built With
- TypeScript - JavaScript that scales
- Jest - Delightful JavaScript Testing
ts-jest
- Jest processor for TypeScript (yes,ts-jest
uses itself for its tests)
Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
Versioning
We DO NOT use SemVer for versioning. Tho you can think about SemVer when reading our version, except our major number follows the one of Jest. For the versions available, see the tags on this repository.
Authors/maintainers
- Kulshekhar Kabra - kulshekhar
- Gustav Wengel - GeeWee
- Ahn - ahnpnl
- Huafu Gandon - huafu
See also the list of contributors who participated in this project.
License
This project is licensed under the MIT License - see the LICENSE.md file for details
Generated by 🚫 dangerJS
899f48f
to
f049743
Compare
Codecov Report
@@ Coverage Diff @@
## master #5 +/- ##
=========================================
Coverage ? 73.33%
=========================================
Files ? 2
Lines ? 150
Branches ? 14
=========================================
Hits ? 110
Misses ? 40
Partials ? 0 |
70d9b61
to
76ad181
Compare
This pull request introduces 1 alert when merging 5989587 into d7ab43b - view on LGTM.com new alerts:
|
No description provided.