Introduction to
Jasmine and Karma
I am Brendon Body
I am here because I am passionate about programming.
You can find me at www.brendonbody.com or
@DormeoES
Hello!
2
“
Quality is never an accident; it is
always the result of intelligent
effort
- John Ruskin
3
This talk
TOPICS
1. Setup: Jasmine/Karma
2. Simple tests
3. Environmental tests
4. AJAX tests
5. CI Server
6. Conclusion
4
Setup
Getting setup with Karma and Jasmine
1
5
Tools/Frameworks
◉ Karma: test runner which handles the test
framework and browser setups
◉ Jasmine: JavaScript unit testing library
◉ Jasmine AJAX: helper for Jasmine to intercept
AJAX calls
◉ Headless Chrome: Chrome run without a UI
6
Process Map
7
◉ Initialize NPM
◉ Initialize Karma
◉ Setup Folders
Setup Jasmine/Karma
8
Simple Tests
Simple input and output code tests
2
9
Environment Tests
Environmental altering code tests
3
10
◉ Fast: tests must be run fast, reducing feedback loop
and can be run a lot
◉ Independent: tests aren’t reliant on each other
◉ Repeatable: can be run many times, different times,
different systems and yield same result
◉ Self-validating: doesn’t need a human to validate
◉ Thorough: should cover a representative set of use
cases (not just code coverage)
FIRST Principle
11
AJAX Tests
Stubbing remote call tests
4
12
CI Server
Automate the repetitive
5
13
Conclusion
Ending this fun
6
14
Any questions?
Leave questions below in the comments and I
will try to answer them!
Thanks!
15

Introduction to Jasmine/Karma