Nell’iperspazio con Rocket: il Framework Web di Rust!
Up & running with jasmine
1. Up & Running with Jasmine
unit testing JavaScript
Md. Kamarul Kawnayeen
2. Preface
I’m assuming that you write your test code first, before writing your production
code. And when we are talking about a language like JavaScript, we have no
way to ignore unit testing. It has no static typing, no way to make a specific
variable or method private, so many different vendor (like chrome, safari, firefox
etc). If something went wrong, we just don’t know what went wrong.
Here I’ll show how to up & running with Jasmine for testing your JavaScript
code.
12. create a new directory scripts and within that directory
create two new js file, math.js & math-spec.js
math.js is our source file & math-spec.js is our spec file
13. As we are good developers :) , so we should write our test
code first. Open math-spec.js & write this simple test code.
describe(string, callback_function) and it(string,
callback_function) are two functions of Jasmine framework.
check details about them here.