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

The unknown spice girl. Aka NineCollective Jasmine Testing

Embed Size (px)

Citation preview

Page 1: The unknown spice girl. Aka NineCollective Jasmine Testing

JASMINE SPICEThe unknown spice girl.

Aka NineCollective Jasmine Testing

Page 2: The unknown spice girl. Aka NineCollective Jasmine Testing

Setting up Jasmine

In Command Prompt type InstallGems.bat

Page 3: The unknown spice girl. Aka NineCollective Jasmine Testing

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: The unknown spice girl. Aka NineCollective Jasmine Testing

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: The unknown spice girl. Aka NineCollective Jasmine Testing

Getting the port number

You find the port number for localhost after you run js:server

Page 6: The unknown spice girl. Aka NineCollective Jasmine Testing

Capturing the Browser

In your browser go to localhost:port number.

Click Capture the Browser

Page 7: The unknown spice girl. Aka NineCollective Jasmine Testing

Captured Browser

Page 8: The unknown spice girl. Aka NineCollective Jasmine Testing

Run the tests

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

Page 9: The unknown spice girl. Aka NineCollective Jasmine Testing

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: The unknown spice girl. Aka NineCollective Jasmine Testing

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: The unknown spice girl. Aka NineCollective Jasmine Testing

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: The unknown spice girl. Aka NineCollective Jasmine Testing

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: The unknown spice girl. Aka NineCollective Jasmine Testing

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: The unknown spice girl. Aka NineCollective Jasmine Testing

The way we use Jasmine

We use nested Suites to test each part. descirbe({

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