Skip to content

Instantly share code, notes, and snippets.

@goldbergyoni
Created December 26, 2018 14:14
Show Gist options
  • Select an option

  • Save goldbergyoni/f540207418b3768a9280fcdb54ff5e4b to your computer and use it in GitHub Desktop.

Select an option

Save goldbergyoni/f540207418b3768a9280fcdb54ff5e4b to your computer and use it in GitHub Desktop.
property based testing
require('mocha-testcheck').install();
const {expect} = require('chai');
const faker = require('faker');
describe('Product service', () => {
describe('Adding new', () => {
//this will run 100 times with different random properties
check.it('Add new product with random yet valid properties, always successful',
gen.int, gen.string, (id, name) => {
expect(addNewProduct(id, name).status).to.equal('approved');
});
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment