Skip to content

vlazar/jasmine-def

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jasmine-def

npm version Build Status Code Climate Test Coverage devDependencies Status js-standard-style

Define lazily evaluated test data via def() and subject() functions.

Usage

Without jasmine-def

describe('old spec', function () {

  // order is important, options must be defined before subject
  beforeEach(function () {
    this.options = { foo: 'foo' };
  });

  beforeEach(function () {
    this.subject = new SomeObject(this.options)
  });

  it('works', function () {
    expect(this.options).toBeDefined();
    expect(this.subject).toBeDefined();
  });
});

With jasmine-def

describe('new shiny spec', function () {

  // order is not important, defined properties are lazy evaluated
  subject(function () {
    return new SomeObject(this.options)
  });

  def('options', function () {
    return { foo: 'foo' }
  });

  it('works', function () {
    expect(this.options).toBeDefined();
    expect(this.subject).toBeDefined();
  });
});

About

Lazy test subjects for Jasmine inspired by RSpec

Resources

License

Stars

Watchers

Forks

Packages

No packages published