jasmine spice

14
JASMINE SPICE The unknown spice girl. Aka NineCollective Jasmine Testing

Upload: otis

Post on 24-Feb-2016

114 views

Category:

Documents


0 download

DESCRIPTION

The unknown spice girl. Aka NineCollective Jasmine Testing. Jasmine Spice. Setting up Jasmine. In Command Prompt type InstallGems.bat. Rebuilding for test run. If you make changes to or create a new viewModel run rake asset:compress in Git Bash. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Jasmine Spice

JASMINE SPICEThe unknown spice girl.

Aka NineCollective Jasmine Testing

Page 2: Jasmine Spice

Setting up Jasmine In Command Prompt type

InstallGems.bat

Page 3: Jasmine Spice

Rebuilding for test run If you make changes to or create a new

viewModel run rake asset:compress in Git Bash. This will later be done automatically.

Page 4: Jasmine Spice

Run the test server To set up the server and run the tests

type rake js:server. This will run the test server.

Page 5: Jasmine Spice

Getting the port number You find the port number for localhost

after you run js:server

Page 6: Jasmine Spice

Capturing the Browser In your browser go to localhost:port

number. Click Capture the Browser

Page 7: Jasmine Spice

Captured Browser

Page 8: Jasmine Spice

Run the tests Type rake js:run in a different Git Bash

to run the tests.

Page 9: Jasmine Spice

Auto running Jasmine tests on file change

Instead of rake js:run you can do rake js:auto to run the tests automatically if you have growl installed

Must have Growl installed and running. www.growlforwindows.com

Page 10: Jasmine Spice

Setting up a Spec It() sets up a spec for testing. To create a Spec you would type

it(‘Meaningful Description’ function () { code to run goes inside here.})

Inside the Spec you would use expect( Item to Test ) . Matcher to use.

You can disable a Spec by using xit() instead of it().

Page 11: Jasmine Spice

Setting up a Suite Group your specs into suites. To set up a Suite you use describe(). The suite set up looks like this

describe( ‘Suite name’, function () { Then a call do the different Specs you will be testing }).

The Suite name will be reported when Spec is ran.

Suites are ran in the order that the describe calls are made.

Page 12: Jasmine Spice

Setting up a Suite (cont.) You can call variables within a describe

block that are accessible by the Specs If you create a global variable it will not

be reset between each Spec call. To initialize a variable between each

Spec use beforeEach(). Suites can be nested. You can disable a Suite by using

xdescribe() instead of describe().

Page 13: Jasmine Spice

Matchers Matchers are used to test a certain

outcome. You can define your own Matchers to

assert a more specific expectation. A matcher function gets the value from

this.actual. You can pass as many arguments as

you want into the function call. It returns a Boolean value.

Page 14: Jasmine Spice

The way we use Jasmine We use nested Suites to test each part. descirbe({

Describe({○ Describe({○ })})