Skip to content

Instantly share code, notes, and snippets.

@basti1302
Last active March 1, 2018 13:17
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save basti1302/5051200 to your computer and use it in GitHub Desktop.
Save basti1302/5051200 to your computer and use it in GitHub Desktop.
An example of a parameterized test suite using the Jasmine BDD framework for JavaScript. This example is in CoffeeScript.
describe "The suit", ->
beforeEach ->
console.log('non-parameterized#beforeEach')
afterEach ->
console.log('non-parameterized#afterEach')
it "should execute specs in the non-parameterized part", ->
console.log('spec in non-parameterized')
expect(true).toBe(true)
parameterized = (param) ->
describe "The parameterized sub-suit (" + param + ")", ->
beforeEach ->
console.log('parameterized#beforeEach')
afterEach ->
console.log('parameterized#afterEach')
it "should execute specs in the parameterized part", ->
console.log('spec in parameterized')
expect(true).toBe(true)
it "should be parameterizable", ->
console.log('parameter: ' + param)
expect(param).toMatch(/[AB]/)
parameterized('A')
parameterized('B')
> jasmine-node spec --coffee --verbose --match "parameterizable.*"
non-parameterized#beforeEach
spec in non-parameterized
non-parameterized#afterEach
non-parameterized#beforeEach
parameterized#beforeEach
spec in parameterized
parameterized#afterEach
non-parameterized#afterEach
non-parameterized#beforeEach
parameterized#beforeEach
parameter: A
parameterized#afterEach
non-parameterized#afterEach
non-parameterized#beforeEach
parameterized#beforeEach
spec in parameterized
parameterized#afterEach
non-parameterized#afterEach
non-parameterized#beforeEach
parameterized#beforeEach
parameter: B
parameterized#afterEach
non-parameterized#afterEach
The suit
should execute specs in the non-parameterized part
The parameterized sub-suit (A)
should execute specs in the parameterized part
should be parameterizable
The parameterized sub-suit (B)
should execute specs in the parameterized part
should be parameterizable
Finished in 0.022 seconds
5 tests, 5 assertions, 0 failures
@jesslilly
Copy link

Awesome. I implemented the same in javascript.

@sinsunsan
Copy link

Thanks for lazy people the javascript traduction

https://gist.github.com/sinsunsan/cb1779b3b83a33fe8446bf27ef7f6149

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment