- Experience some of the differences between clean/good and unclean/bad JS
- Learn Jasmine as a tool to help you write BDD JS specs
Bad js is at times very hard to debug
- Don't leave unused variables dangling in the wind
- Don't use a variable without defining it first with the
var
keyword - Don't use
==
when you should use===
- Don't make two libraries override each others' functionality by putting crap in global scope
- Keep your cyclomatic complexity down to a minimum
- Have your functions do one thing well
- Don't write assignments in
if
andfor
equality checks - Don't assume braces
Forllow the Simple section of the installation instructions here: Sublime Package Control Installation Instructions
CRUCIAL: First, run node -v
in your terminal. This should output the version of node on your machine. If you don't have nodejs
installed:
- ON MAC: In your terminal, run this:
brew install node
- ON LINUX: In your terminal, run this:
apt-get install nodejs
Follow the Sublime Package Manager section of the instructions here: JSHint Gutter Installation Instructions
- If you have Sublime Text 3:, enable Automatically linting on edit or save
- If you have Sublime Text 2, enable Automatically linting on save
In RSpec, what 2 arguments do the describe
, it
methods take?
Like in RSpec with ruby, in Jasmine with JS, which is based on RSpec, describe
and it
are functions
that are applied to/take two arguments. With RSpec, the second argument is a block; with Jasmine, the second argument is an anonymous function
.
A test suite begins with describe
, with two parameters:
- A
string
giving the test suite a name - An anonymous
function
that implements the test suite