Jasmine - Behaviour-driven Development

17
Jasmine by Mireia Sangalo @MyPitit

Transcript of Jasmine - Behaviour-driven Development

Page 1: Jasmine - Behaviour-driven Development

Jasmine

by Mireia Sangalo

@MyPitit

Page 2: Jasmine - Behaviour-driven Development

1. What is Jasmine

2. How to set up Jasmine?

3. How it works?

4. Matchers

Agenda

Page 3: Jasmine - Behaviour-driven Development

1. What is Jasmine

2. How to set up Jasmine?

3. How it works?

4. Matchers

Agenda

Page 4: Jasmine - Behaviour-driven Development

1. What is Jasmine

• Jasmine is a Behaviour-driven Development (BDD)

• Jasmine is a framework for testing JavaScript

• It doesn't need the DOM

• Can run anywhere JavaScript can run

Page 5: Jasmine - Behaviour-driven Development

1. What is Jasmine

2. How to set up Jasmine?

3. How it works?

4. Matchers

Agenda

Page 6: Jasmine - Behaviour-driven Development

2. How to set up Jasmine?

• Go to: https://github.com/jasmine/jasmine/releases

• Download jasmine-standalone-2.4.1.zip

Page 7: Jasmine - Behaviour-driven Development

The zip file includes:

• SpecRunner.html file

• spec folder

• src folder

• lib

Page 8: Jasmine - Behaviour-driven Development

SpecRunner.html

Page 9: Jasmine - Behaviour-driven Development

SpecRunner.html

Page 10: Jasmine - Behaviour-driven Development

Hands on!

https://github.com/FAC-QMUL/TDD/tree/master/TDD/Jasmine

Page 11: Jasmine - Behaviour-driven Development

1. What is Jasmine

2. How to set up Jasmine?

3. How it works?

4. Matchers

Agenda

Page 12: Jasmine - Behaviour-driven Development

3. How it worksJasmine tests are split up into suites:

• suites describe a group of your tests

• suites takes a string (with a description of your tests) and a function which defines the tests.

Page 13: Jasmine - Behaviour-driven Development

Example of a suite:

describe("the function we're going to test", function() {

// more code goes here

})

Page 14: Jasmine - Behaviour-driven Development

1. What is Jasmine

2. How to set up Jasmine?

3. How it works?

4. Matchers

Agenda

Page 15: Jasmine - Behaviour-driven Development

3. Matchers- The different Matchers:

• toEqual

• toBe

- Example:

it("and has a positive case", function() {

expect(true).toBe(true);

});

Page 16: Jasmine - Behaviour-driven Development

Hands On!

Page 17: Jasmine - Behaviour-driven Development

Questions?