Skip to content
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

Merged
merged 1 commit into from Jul 25, 2019
Merged

Adds tests for CreateMessage function #5

merged 1 commit into from Jul 25, 2019

Conversation

cloudify
Copy link
Contributor

No description provided.

@digitalcitizenship
Copy link

digitalcitizenship commented Jul 23, 2019

Warnings
⚠️

Please include a Pivotal story at the beginning of the PR title (see below).

⚠️

Please include a description of your PR changes.

Example of PR titles that include pivotal stories:

  • single story: [#123456] my PR title
  • multiple stories: [#123456,#123457,#123458] my PR title

New dependencies added: @types/jest, fast-check, jest and ts-jest.

@types/jest

Author: Unknown

Description: TypeScript definitions for Jest

Homepage: http://npmjs.com/package/@types/jest

Createdabout 3 years ago
Last Updatedabout 1 month ago
LicenseMIT
Maintainers1
Releases105
Direct Dependencies@types/jest-diff
README

Installation

npm install --save @types/jest

Summary

This package contains type definitions for Jest ( https://jestjs.io/ ).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/jest

Additional Details

  • Last updated: Sun, 16 Jun 2019 06:12:11 GMT
  • Dependencies: @types/jest-diff
  • Global values: afterAll, afterEach, beforeAll, beforeEach, describe, expect, fail, fdescribe, fit, it, jasmine, jest, pending, spyOn, test, xdescribe, xit, xtest

Credits

These definitions were written by Asana (https://asana.com)
// Ivo Stratev https://github.com/NoHomey, jwbay https://github.com/jwbay, Alexey Svetliakov https://github.com/asvetliakov, Alex Jover Morales https://github.com/alexjoverm, Allan Lukwago https://github.com/epicallan, Ika https://github.com/ikatyang, Waseem Dahman https://github.com/wsmd, Jamie Mason https://github.com/JamieMason, Douglas Duteil https://github.com/douglasduteil, Ahn https://github.com/ahnpnl, Josh Goldberg https://github.com/joshuakgoldberg, Jeff Lau https://github.com/UselessPickles, Andrew Makarov https://github.com/r3nya, Martin Hochel https://github.com/hotell, Sebastian Sebald https://github.com/sebald, Andy https://github.com/andys8, Antoine Brault https://github.com/antoinebrault, Jeroen Claassens https://github.com/favna, Gregor Stamać https://github.com/gstamac, ExE Boss https://github.com/ExE-Boss.

fast-check

Author: Nicolas DUBIEN

Description: Property based testing framework for JavaScript (like QuickCheck)

Homepage: https://github.com/dubzzz/fast-check#readme

Createdover 1 year ago
Last Updated22 days ago
LicenseMIT
Maintainers1
Releases52
Direct Dependenciespure-rand and tslib
Keywordsproperty-based testing, end-to-end testing, unit testing, testing, quickcheck, jscheck and jsverify
README

fast-check logo

Property based testing framework for JavaScript/TypeScript

Build Status npm version total downloads

Coverage Status dependencies Status devDependencies Status Known Vulnerabilities

PRs Welcome License Twitter

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:

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']}

MORE: Issues detected thanks of fast-check

jest

Author: Unknown

Description: Delightful JavaScript Testing.

Homepage: https://jestjs.io/

Createdover 7 years ago
Last Updatedabout 2 months ago
LicenseMIT
Maintainers6
Releases220
Direct Dependenciesimport-local and jest-cli
Keywordsava, 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

Createdalmost 3 years ago
Last Updated4 months ago
LicenseMIT
Maintainers3
Releases98
Direct Dependenciesbs-logger, buffer-from, fast-json-stable-stringify, json5, make-error, mkdirp, resolve, semver and yargs-parser
Keywordsjest, typescript, sourcemap, react and testing
README

ts-jest npm version NPM downloads Known Vulnerabilities Coverage Status Dependabot Status Build Status for linux Build Status for Windows

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

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

@cloudify cloudify force-pushed the tests branch 2 times, most recently from 899f48f to f049743 Compare July 24, 2019 04:33
@codecov-io
Copy link

codecov-io commented Jul 24, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@d7ab43b). Click here to learn what that means.
The diff coverage is 98.36%.

@@            Coverage Diff            @@
##             master       #5   +/-   ##
=========================================
  Coverage          ?   73.33%           
=========================================
  Files             ?        2           
  Lines             ?      150           
  Branches          ?       14           
=========================================
  Hits              ?      110           
  Misses            ?       40           
  Partials          ?        0

@cloudify cloudify force-pushed the tests branch 7 times, most recently from 70d9b61 to 76ad181 Compare July 25, 2019 13:59
@cloudify cloudify changed the title Adds tests Adds tests for CreateMessage function Jul 25, 2019
@lgtm-com
Copy link

lgtm-com bot commented Jul 25, 2019

This pull request introduces 1 alert when merging 5989587 into d7ab43b - view on LGTM.com

new alerts:

  • 1 for Unused variable, import, function or class

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants