All Projects → sazeracjs → Sazerac

sazeracjs / Sazerac

Licence: mit
Data-driven unit testing for Jasmine, Mocha, and Jest

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Sazerac

Redux Actions Assertions
Simplify testing of redux action and async action creators
Stars: ✭ 177 (-45.03%)
Mutual labels:  jest, unit-testing, mocha, assertions
Public
Repository for wallaby.js questions and issues
Stars: ✭ 662 (+105.59%)
Mutual labels:  jest, mocha, jasmine
Jasmine Matchers
Write Beautiful Specs with Custom Matchers for Jest and Jasmine
Stars: ✭ 552 (+71.43%)
Mutual labels:  jest, unit-testing, jasmine
eslint-config-adjunct
A reasonable collection of plugins to use alongside your main esLint configuration
Stars: ✭ 39 (-87.89%)
Mutual labels:  jasmine, mocha, jest
Enzyme Matchers
Jasmine/Jest assertions for enzyme
Stars: ✭ 881 (+173.6%)
Mutual labels:  jest, unit-testing, jasmine
angular-unit-testing-examples
Showroom for different Angular unit testing concepts
Stars: ✭ 19 (-94.1%)
Mutual labels:  unit-testing, jasmine, jest
Expect More
Curried Type Testing library, and Test Matchers for Jest
Stars: ✭ 124 (-61.49%)
Mutual labels:  jest, assertions, jasmine
Enzyme
JavaScript Testing utilities for React
Stars: ✭ 19,781 (+6043.17%)
Mutual labels:  jest, mocha, assertions
Testdeck
Object oriented testing
Stars: ✭ 206 (-36.02%)
Mutual labels:  jest, mocha, jasmine
awesome-javascript-testing
🔧 Awesome JavaScript testing resources
Stars: ✭ 28 (-91.3%)
Mutual labels:  unit-testing, mocha, jest
Snap Shot
Jest-like snapshot feature for the rest of us, works magically by finding the right caller function
Stars: ✭ 170 (-47.2%)
Mutual labels:  jest, unit-testing, mocha
tropic
🍍 Test Runner Library
Stars: ✭ 29 (-90.99%)
Mutual labels:  unit-testing, mocha, jest
Babel Plugin Tester
Utilities for testing babel plugins
Stars: ✭ 228 (-29.19%)
Mutual labels:  jest, mocha, jasmine
Rxjs Marbles
An RxJS marble testing library for any test framework
Stars: ✭ 267 (-17.08%)
Mutual labels:  jest, mocha, jasmine
jasmine-marbles
Marble testing helpers for RxJS and Jasmine
Stars: ✭ 102 (-68.32%)
Mutual labels:  unit-testing, jasmine
xv
❌ ✔️ zero-config test runner for simple projects
Stars: ✭ 588 (+82.61%)
Mutual labels:  mocha, jest
riteway-jest
Unit tests that always supply a good bug report when they fail for Jest.
Stars: ✭ 24 (-92.55%)
Mutual labels:  unit-testing, jest
patent-free-react-ecosystem-migration-plan
Patent Free React Ecosystem Migration Plan
Stars: ✭ 15 (-95.34%)
Mutual labels:  mocha, jest
angular-material-boilerplate
A straightforward and well structured boilerplate based on Google's Angular Material project.
Stars: ✭ 28 (-91.3%)
Mutual labels:  unit-testing, jasmine
react-multi-context
Manage multiple React 16 contexts with a single component.
Stars: ✭ 19 (-94.1%)
Mutual labels:  mocha, jest

Sazerac

Data-driven unit testing for JavaScript.

About

Sazerac is a library for data-driven testing in JavaScript. It works with mocha, jasmine, and jest. Using Sazerac, and the data-driven testing pattern in general, will reduce the complexity and increase readability of your test code.

Check out sazerac.js.org for docs and sazerac-example for examples.

Why Use It?

Let's say you have a function isPrime(). When given a number, it returns true or false depending on whether the number is a prime number.

function isPrime(num) {
  for(var i = 2; i < num; i++) {
    if(num % i === 0) return false;
  }
  return num > 1;
}

If you're using a framework like jasmine, your tests might look something like this:

describe('isPrime()', () => {

  describe('when given 2', () => {
    it('should return true', () => {
      assert.isTrue(isPrime(2))
    })
  })

  describe('when given 3', () => {
    it('should return true', () => {
      assert.isTrue(isPrime(3))
    })
  })

  describe('when given 4', () => {
    it('should return false', () => {
      assert.isFalse(isPrime(4))
    })
  })

  // and more ...

})

It's a lot of code to write for only 3 test cases and such a basic function!

The same tests can be defined with Sazerac as follows:

test(isPrime, () => {
  given(2).expect(true)
  given(3).expect(true)
  given(4).expect(false)
})

Sazerac runs the describe and it functions needed for these test cases. It adds reporting messages in a consistent format based on the input and output parameters. For this example, the test report ends up looking like this:

isPrime()
  when given 2
    ✓ should return true
  when given 3
    ✓ should return true
  when given 4
    ✓ should return false

Installation

Install Sazerac as an npm module and save it to your package.json file as a development dependency:

npm install sazerac --save-dev

Import the test and given helper functions into your project:

import { test, given } from 'sazerac'

Guide and API documentation

Visit sazerac.js.org.

Contributing

Yes, please do :)

Get In Touch

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].