Skip to content

Scoped Shared Examples

Compare
Choose a tag to compare
@stalniy stalniy released this 16 Jul 10:39
· 350 commits to master since this release

The main purpose of this release was to add scoping to sharedExamplesFor. Previously that function defined shared examples globally, from this release it defines them in scope of suite where it was called.

Features

  • shared-examples: adds support for scoping
describe('Array', () => {
  subject(() => [1, 2, 3])

  sharedExamplesFor('a collection', () => {
     it('has 3 items', () => expect($subject).to.have.length(3))
  })

  includeExamplesFor('a collection')
})

describe('Set', () => {
  subject(() => new Set([1, 2, 3]))

  sharedExamplesFor('a collection', () => {
     it('has 3 items', () => expect($subject.size).to.equal(3))
  })

  includeExamplesFor('a collection')
})