JASMINE SPICEThe unknown spice girl.
Aka NineCollective Jasmine Testing
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. This will later be done automatically.
Run the test server To set up the server and run the tests
type rake js:server. This will run the test server.
Getting the port number You find the port number for localhost
after you run js:server
Capturing the Browser In your browser go to localhost:port
number. Click Capture the Browser
Captured Browser
Run the tests Type rake js:run in a different Git Bash
to run the tests.
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
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().
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.
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().
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.
The way we use Jasmine We use nested Suites to test each part. descirbe({
Describe({○ Describe({○ })})