karma-bdd-using

WebJar for karma-bdd-using

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

karma-bdd-using
Last Version

Last Version

0.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

karma-bdd-using
WebJar for karma-bdd-using
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/kristerkari/karma-bdd-using

Download karma-bdd-using

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/karma-bdd-using/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>karma-bdd-using</artifactId>
    <version>0.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/karma-bdd-using/
implementation 'org.webjars.npm:karma-bdd-using:0.1.0'
// https://jarcasting.com/artifacts/org.webjars.npm/karma-bdd-using/
implementation ("org.webjars.npm:karma-bdd-using:0.1.0")
'org.webjars.npm:karma-bdd-using:jar:0.1.0'
<dependency org="org.webjars.npm" name="karma-bdd-using" rev="0.1.0">
  <artifact name="karma-bdd-using" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='karma-bdd-using', version='0.1.0')
)
libraryDependencies += "org.webjars.npm" % "karma-bdd-using" % "0.1.0"
[org.webjars.npm/karma-bdd-using "0.1.0"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

karma-bdd-using

DRY your Karma + Jasmine or Mocha tests using the data provider pattern

A test helper for Jasmine and Mocha frameworks, inspired by this article: DRYing Up Your JavaScript Jasmine Tests With the Data Provider Pattern

Installation

npm install karma-bdd-using

and add 'bdd-using' to your Karma config frameworks:

frameworks: ['jasmine', 'bdd-using'],

Examples

Sometimes you need to write a test where all tested values are expected to have the same test result:

describe("when calling isLeap method", function() {

	it("should return true for leap years", function() {
		expect(isLeap(1976)).to.equal(true);
		expect(isLeap(1980)).to.equal(true);
		expect(isLeap(1984)).to.equal(true);
		expect(isLeap(1988)).to.equal(true);
		expect(isLeap(1992)).to.equal(true);
		expect(isLeap(1996)).to.equal(true);
	});

	it("should return false for non-leap years", function() {
		expect(isLeap(1975)).to.equal(false);
		expect(isLeap(1981)).to.equal(false);
		expect(isLeap(1985)).to.equal(false);
		expect(isLeap(1989)).to.equal(false);
		expect(isLeap(1993)).to.equal(false);
		expect(isLeap(1997)).to.equal(false);
	});	

});

With using helper you can write this instead:

describe("when calling isLeap method", function() {

	using("leap years", [1976, 1980, 1984, 1988, 1992, 1996], function(year) {
		it("should return true", function() {
			expect(isLeap(year)).to.equal(true);
		});
	});

	using("non-leap years", [1975, 1981, 1985, 1989, 1993, 1997], function(year) {
		it("should return false", function() {
			expect(isLeap(year)).to.equal(false);
		});
	});

});

And get a nicer test output:

  when calling isLeap method
    ✓ should return true (with "leap years" using "1976") 
    ✓ should return true (with "leap years" using "1980") 
    ✓ should return true (with "leap years" using "1984") 
    ✓ should return true (with "leap years" using "1988") 
    ✓ should return true (with "leap years" using "1992") 
    ✓ should return true (with "leap years" using "1996") 
    ✓ should return false (with "non-leap years" using "1975") 
    ✓ should return false (with "non-leap years" using "1981") 
    ✓ should return false (with "non-leap years" using "1985") 
    ✓ should return false (with "non-leap years" using "1989") 
    ✓ should return false (with "non-leap years" using "1993") 
    ✓ should return false (with "non-leap years" using "1997")

Versions

Version
0.1.0