SlideShare ist ein Scribd-Unternehmen logo
1 von 67
Downloaden Sie, um offline zu lesen
Describe’s
Full of It’s
June 2016
Jim Lynch
Hi, I’m Jim Lynch
Front-End Engineer
at Altered Image
@webWhizJim
Slides available here: 

http://www.slideshare.net/JimLynch22/describes-full-of-its
WebStorm
Ambassador
Programming Tweeter
Who is This Talk For?
• Anyone interested in unit testing.
• AngularJS developers.
• Front-End developers.
Why Test?
• To prevent regression (recurring bugs).
• To catch bugs before end users see them.
• To remove fear from refactoring.
• So you don’t have to keep testing manually.
• To document what your code should do.
• To gain a sense of confidence that you 

can never have without tests!
If You Don’t Test…
DON’T IGNORE TESTING!
Artifacts
• True, but also a clean production
build (the dist/ directory)
• When the project is over, what will
you leave behind?
• “A programmer’s deliverables should
be clean code and clean tests” 

- Pete Heard
Anatomy of a Test Suite
Anatomy of a Test Suite
Test Suite
Anatomy of a Test Suite
Test Case
Test Case
Test Suite
Anatomy of a Test Suite
Test Case
Assertion
Assertion
Assertion
Test Case
Test Suite
Anatomy of a Test Suite
Test Suite
• A collection of independent tests.
• Usually exists as it’s own file.
• Contains methods for setting
up for and tearing down unit
tests.
Test Case
Assertion
Assertion
Assertion
Test Case
Test Suite
Anatomy of a Test Suite
Test Case
• Tests a single “piece” of your
application independent of the
other code.
• A function that can either pass or
fail.
• Each case should test a
different “situation” from the
user’s perspective (BDD).
Test Case
Assertion
Assertion
Assertion
Test Case
Test Suite
Anatomy of a Test Suite
Test Case
Assertion
Assertion
Assertion
Test Case
Test Suite
Assertion
• Uses a matcher API for comparing
values 

(eg toEqual)
• Tells the test case when it should
pass and when it should fail.
• If output values for SUT (system
under test) are as expected then
behavior of SUT is as expected.
Unit testing in JavaScript
uses a peculiar syntax…
If you are ever feeling lost,
just remember that a test
suite in JavaScript is this:
A describe
full of
it’s
with some
beforeEach’s
Test Suite Anatomy for JS

Testing Frameworks
it
describeTest Suite
Test Case
Assertion expect
it
expect
expect
Building Your First Test Suite
• A test suite is simply a Javascript file.
• Karma will automatically consider *.spec.js
files to be test suites.
Step 1) Create an empty *.spec.js file.
Keep the Tests Close By
• For every .js file, make a .spec.js file right next to it.
• Test file should have exact same name 

(other than the .spec part).
• Having a root level “tests” folder is an old-school
practice and not recommended.
• Gulp scripts should recognize tests throughout
entire project directory.
Keep the Family Together
Two Lovebirds
Let’s Look
At Some Code…
describe describe(‘MyController’, function() {
})
Building Your First Test Suite
Adding a describe.
describe describe(‘MyController’, function() {
})
A name for your test suite 

(can be anything, but it should
describe what you are testing!).
Building Your First Test Suite
Adding a describe.
describe describe(‘MyController’, function() {
})
A function that takes no
arguments. This creates the
“wrapper” around your test
cases.
Building Your First Test Suite
Adding a describe.
describe
describe(‘MyController’, function() {
})
it
Building Your First Test Suite
it(‘Should do something…’, function() {
});
Adding an it.
describe
describe(‘MyController’, function() {
})
Some text that describes the
purpose of this test case. Can be
anything but usually begins with
the word should.
it
Building Your First Test Suite
it(‘Should do something…’, function() {
});
Adding an it.
describe
describe(‘MyController’, function() {
})
it
Building Your First Test Suite
it(‘Should do something…’, function() {
});
A function that takes no
arguments. The code for this
test case is contained in this
function.
Adding an it.
describe
describe(‘MyController’, function() {
})
it
Building Your First Test Suite
it(‘Should do something…’, function() {
});
Adding an assertion.
expect
expect(true).toEqual(true);
describe
describe(‘MyController’, function() {
})
it
Building Your First Test Suite
it(‘Should do something…’, function() {
});
Adding an assertion.
expect
expect(true).toEqual(true);
The expect keyword let’s the
test case know that we want to
do an assertion here.
describe
describe(‘MyController’, function() {
})
it
Building Your First Test Suite
it(‘Should do something…’, function() {
});
Adding an assertion.
expect
expect(true).toEqual(true);
The expect method takes one
argument, the variable whose
value you wish to check.
describe
describe(‘MyController’, function() {
})
it
Building Your First Test Suite
it(‘Should do something…’, function() {
});
Adding an assertion.
expect
expect(true).toEqual(true);
Depending on how you wish to
compare the two values, a
matcher method is chained
onto the end of the expect.
describe
describe(‘MyController’, function() {
})
it
Building Your First Test Suite
it(‘Should do something…’, function() {
});
Adding an assertion.
expect
expect(true).toEqual(true);
The matcher method takes one
argument. The expected value
for the variable being passed
into the expect method.
Building Your First Test Suite
You did it!
describe(‘MyController’, function() {
})
it(‘Should do something…’, function() {
});
expect(true).toEqual(true);
Ahhh, so a test suite is really just…
A describe
full of
it’s!
…with some beforeEach’s.
beforeEach
• Goes inside the describe
but outside of the it’s.
describe
it
expect
it
expect
beforeEach
beforeEach
• Gives you access to your
module, controllers,
services, etc. through DI.
beforeEach
describe(‘MyController’, function() {
})
it(‘Should do something…’, function() {
});
expect(true).toEqual(true);
beforeEach(module(‘YOUR_MODULE’));
beforeEach
beforeEach(module(‘YOUR_MODULE’));
Keyword that runs argument
before every it.
beforeEach
beforeEach(module(‘YOUR_MODULE’));
Allows you to load in
your model so that you have
access to it’s controllers,
services, filters, etc.
beforeEach
beforeEach(module(‘YOUR_MODULE’));
Replace this with the name
of your project’s module.
Injecting a Controller
with beforeEach
describe(‘MyController’, function() {
})
it(‘Should do something…’, function() {
});
expect(true).toEqual(true);
beforeEach(module(‘YOUR_MODULE’));
var myController = $controller('MyController', {})
beforeEach(inject(function(_$controller_) {
$controller = _$controller_;
}));
Injecting a Controller
with beforeEach
beforeEach(inject(function(_$controller_) {
$controller = _$controller_;
}));
A method from the angular-
mocks.js file that allows you to
inject services into your unit tests.
Injecting a Controller
with beforeEach
beforeEach(inject(function(_$controller_) {
$controller = _$controller_;
}));
Angular knows to “unwrap”, the underscores,
find corresponding provider, and give you a
reference to the service.
Q. But what’s the deal with those
underscores on either side?
Injecting a Controller
with beforeEach
beforeEach(inject(function(_$controller_) {
$controller = _$controller_;
}));
Angular knows to “unwrap”, the underscores,
find corresponding provider, and give you a
reference to the service.
Suppose you didn’t use the underscores. You want to set a variable named
$controller available inside of your “it’s” equal to the function’s argument, but the
function argument must be named $controller in order to be injected properly.
Doing this is not possible in JavaScript (outer variable is overshadowed) so the
Angular team implemented the underscore notation to work around the issue.
Injecting a Controller
with beforeEach
beforeEach(inject(function(_$controller_) {
$controller = _$controller_;
}));
You can then use this global
reference anywhere in the test suite
to instantiate controllers.
Using the Injected
Controller
var myController = $controller('MyController', {})
This var has all of the properties
and methods you defined for the
specified controller.
Using the Injected
Controller
var myController = $controller('MyController', {})
This is the global $controller
variable that was set in the
beforeEach.
Using the Injected
Controller
var myController = $controller('MyController', {})
Replace this with the name
of the controller you want
to instantiate.
Pass in any arguments to your
controller with this object.
var myController = $controller('MyController', {})
Using the Injected
Controller
The Complete Suite
describe(‘MyController’, function() {
})
it(‘Should do something…’, function() {
});
expect(true).toEqual(true);
beforeEach(module(‘YOUR_MODULE’));
var myController = $controller('MyController', {})
beforeEach(inject(function(_$controller_) {
$controller = _$controller_;
}));
A good start to a nice looking test suite:
Okay, so how do I run
these test suites?
Q )
KarmaA )
Fun Facts About Karma
• Worked with non-Angular projects as well.
• A command line test runner built to be fast.
• Integrates with practically all CI tools.
• Runs tests on all browsers (even PhantomJS).
How Does Karma Work?
• It integrates nicely with Gulp and Grunt (gulp test)
or runs on its own (karma start).
• It’s installed from npm: npm install karma
• The karma.conf.js file allows you to configure it to
run with your desired settings.
• It automatically see *.spec.js files in your project
folder as test suites.
How do I add Karma to
My Project?
Easy Way Hard(er) Way
Use a yeoman generator to
scaffold a project that already
has karma set up for you
(such as the Gulp-Angular
yeoman generator or the
Angular 2 CLI).
Install and configure it
manually.
karma-runner.github.io
Adding Karma to Your Project
And then you’re ready to start testing!
Workflow
Browsersync
Chrome Dev Tools
See Your App Running
Logs / Debugging
Runs Unit Tests on File
Changes
No need to test manually
Reminds you to write
more tests
Gulp Serve Gulp Test:Auto
Workflow
Gulp Serve Gulp Test:Auto
???
or
Workflow
Gulp Serve Gulp Test:Auto&
“Dual Shell Development”
Gulp serve in one command shell and gulp test:auto in the other.
So What’s Different for
Unit Testing Angular 2?
Not Much!
The CLI Replaces Gulp Tasks
https://cli.angular.io/
Angular 1 Angular 2
yo gulp-angular ng new / ng initNew project:
gulp serve ng serveRun locally:
gulp serve:dist ng serve —-buildRun prod build:
gulp test:auto ng test -wRun unit tests
gulp protractor ng e2eRun e2e tests
gulp build ng buildCreate prod build
In Angular 2 You Can
Still Think of a Unit
Test as…
A describe
full of
it’s
with some
beforeEach’s
A describe
full of
it’s
with some
beforeEach’s
(with a bunch of “import” statements)
A describe
full of
it’s
with some
beforeEach’s
(with a bunch of “import” statements)
(And also “beforeEachProviders”)
Example of an Angular 2 Unit Test
Thanks!
twitter.com/webWhizJim
jim@ng-nj.com
www.wisdomofjim.com
The official “Describe’s Full of
It’s” T-Shirt! Available now!
Slides available here: 

http://www.slideshare.net/
JimLynch22/describes-full-of-its
github.com/JimTheMan
www.teepublic.com/t-
shirt/468156-describes-
full-of-its-white-text

Weitere ähnliche Inhalte

Was ist angesagt?

Angular Unit Testing NDC Minn 2018
Angular Unit Testing NDC Minn 2018Angular Unit Testing NDC Minn 2018
Angular Unit Testing NDC Minn 2018Justin James
 
Unit Testing in iOS - Ninjava Talk
Unit Testing in iOS - Ninjava TalkUnit Testing in iOS - Ninjava Talk
Unit Testing in iOS - Ninjava TalkLong Weekend LLC
 
Angular Unit Testing from the Trenches
Angular Unit Testing from the TrenchesAngular Unit Testing from the Trenches
Angular Unit Testing from the TrenchesJustin James
 
Testing akka-actors
Testing akka-actorsTesting akka-actors
Testing akka-actorsKnoldus Inc.
 
Unit testing in JavaScript with Jasmine and Karma
Unit testing in JavaScript with Jasmine and KarmaUnit testing in JavaScript with Jasmine and Karma
Unit testing in JavaScript with Jasmine and KarmaAndrey Kolodnitsky
 
Unit Testing and Coverage for AngularJS
Unit Testing and Coverage for AngularJSUnit Testing and Coverage for AngularJS
Unit Testing and Coverage for AngularJSKnoldus Inc.
 
iOS Unit Testing
iOS Unit TestingiOS Unit Testing
iOS Unit Testingsgleadow
 
Client side unit tests - using jasmine & karma
Client side unit tests - using jasmine & karmaClient side unit tests - using jasmine & karma
Client side unit tests - using jasmine & karmaAdam Klein
 
AngularJS Unit Test
AngularJS Unit TestAngularJS Unit Test
AngularJS Unit TestChiew Carol
 
Advanced Jasmine - Front-End JavaScript Unit Testing
Advanced Jasmine - Front-End JavaScript Unit TestingAdvanced Jasmine - Front-End JavaScript Unit Testing
Advanced Jasmine - Front-End JavaScript Unit TestingLars Thorup
 
Front end unit testing using jasmine
Front end unit testing using jasmineFront end unit testing using jasmine
Front end unit testing using jasmineGil Fink
 
Quick Tour to Front-End Unit Testing Using Jasmine
Quick Tour to Front-End Unit Testing Using JasmineQuick Tour to Front-End Unit Testing Using Jasmine
Quick Tour to Front-End Unit Testing Using JasmineGil Fink
 
Testing in-python-and-pytest-framework
Testing in-python-and-pytest-frameworkTesting in-python-and-pytest-framework
Testing in-python-and-pytest-frameworkArulalan T
 
Jquery- One slide completing all JQuery
Jquery- One slide completing all JQueryJquery- One slide completing all JQuery
Jquery- One slide completing all JQueryKnoldus Inc.
 
Unit Test Your Database
Unit Test Your DatabaseUnit Test Your Database
Unit Test Your DatabaseDavid Wheeler
 
Understanding JavaScript Testing
Understanding JavaScript TestingUnderstanding JavaScript Testing
Understanding JavaScript TestingKissy Team
 

Was ist angesagt? (20)

Angular Unit Testing NDC Minn 2018
Angular Unit Testing NDC Minn 2018Angular Unit Testing NDC Minn 2018
Angular Unit Testing NDC Minn 2018
 
Unit Testing in iOS - Ninjava Talk
Unit Testing in iOS - Ninjava TalkUnit Testing in iOS - Ninjava Talk
Unit Testing in iOS - Ninjava Talk
 
Angular Unit Testing
Angular Unit TestingAngular Unit Testing
Angular Unit Testing
 
Angular Unit Testing from the Trenches
Angular Unit Testing from the TrenchesAngular Unit Testing from the Trenches
Angular Unit Testing from the Trenches
 
Testing akka-actors
Testing akka-actorsTesting akka-actors
Testing akka-actors
 
Unit testing in JavaScript with Jasmine and Karma
Unit testing in JavaScript with Jasmine and KarmaUnit testing in JavaScript with Jasmine and Karma
Unit testing in JavaScript with Jasmine and Karma
 
Unit Testing and Coverage for AngularJS
Unit Testing and Coverage for AngularJSUnit Testing and Coverage for AngularJS
Unit Testing and Coverage for AngularJS
 
iOS Unit Testing
iOS Unit TestingiOS Unit Testing
iOS Unit Testing
 
Client side unit tests - using jasmine & karma
Client side unit tests - using jasmine & karmaClient side unit tests - using jasmine & karma
Client side unit tests - using jasmine & karma
 
AngularJS Unit Test
AngularJS Unit TestAngularJS Unit Test
AngularJS Unit Test
 
Advanced Jasmine - Front-End JavaScript Unit Testing
Advanced Jasmine - Front-End JavaScript Unit TestingAdvanced Jasmine - Front-End JavaScript Unit Testing
Advanced Jasmine - Front-End JavaScript Unit Testing
 
Angular Unit Testing
Angular Unit TestingAngular Unit Testing
Angular Unit Testing
 
Front end unit testing using jasmine
Front end unit testing using jasmineFront end unit testing using jasmine
Front end unit testing using jasmine
 
Jasmine BDD for Javascript
Jasmine BDD for JavascriptJasmine BDD for Javascript
Jasmine BDD for Javascript
 
Quick Tour to Front-End Unit Testing Using Jasmine
Quick Tour to Front-End Unit Testing Using JasmineQuick Tour to Front-End Unit Testing Using Jasmine
Quick Tour to Front-End Unit Testing Using Jasmine
 
jasmine
jasminejasmine
jasmine
 
Testing in-python-and-pytest-framework
Testing in-python-and-pytest-frameworkTesting in-python-and-pytest-framework
Testing in-python-and-pytest-framework
 
Jquery- One slide completing all JQuery
Jquery- One slide completing all JQueryJquery- One slide completing all JQuery
Jquery- One slide completing all JQuery
 
Unit Test Your Database
Unit Test Your DatabaseUnit Test Your Database
Unit Test Your Database
 
Understanding JavaScript Testing
Understanding JavaScript TestingUnderstanding JavaScript Testing
Understanding JavaScript Testing
 

Andere mochten auch

Acreditar ou não em Deus
Acreditar ou não em DeusAcreditar ou não em Deus
Acreditar ou não em DeusHelio Cruz
 
Best Practices Portfolio Mngt
Best Practices Portfolio MngtBest Practices Portfolio Mngt
Best Practices Portfolio MngtGalit Fein
 
bba final research
bba final researchbba final research
bba final researchKinjal Desai
 
Informe de laboratorio
Informe de laboratorioInforme de laboratorio
Informe de laboratorioIevargas
 
Evaluacion formativa-o-de-procesos (1)
Evaluacion formativa-o-de-procesos (1)Evaluacion formativa-o-de-procesos (1)
Evaluacion formativa-o-de-procesos (1)Sandy Morales Alarcón
 
Técnica de la pregunta
Técnica de la preguntaTécnica de la pregunta
Técnica de la preguntaKaterin Colcha
 
التفكير العلمي وخصائصه
التفكير العلمي وخصائصهالتفكير العلمي وخصائصه
التفكير العلمي وخصائصهgogo2014
 
الهرمينوطيقا بوصفها يقظة العيش في العالَم (تجربة مارتن هيدغر في محاضرات 1923)
الهرمينوطيقا بوصفها يقظة العيش في العالَم (تجربة مارتن هيدغر في محاضرات 1923)الهرمينوطيقا بوصفها يقظة العيش في العالَم (تجربة مارتن هيدغر في محاضرات 1923)
الهرمينوطيقا بوصفها يقظة العيش في العالَم (تجربة مارتن هيدغر في محاضرات 1923)حسن قروق
 
Eridania 110 anni - Chi sa fare la marmellata?
Eridania 110 anni - Chi sa fare la marmellata?Eridania 110 anni - Chi sa fare la marmellata?
Eridania 110 anni - Chi sa fare la marmellata?Gianluca Greco
 
ISS World Prague 2010 - DPI at 40G and 100G: Moving Beyond Appliances
ISS World Prague 2010 - DPI at 40G and 100G: Moving Beyond AppliancesISS World Prague 2010 - DPI at 40G and 100G: Moving Beyond Appliances
ISS World Prague 2010 - DPI at 40G and 100G: Moving Beyond AppliancesContinuous Computing
 
الاتجاهات البحثية فى إدارة المعرفة
الاتجاهات البحثية فى إدارة المعرفةالاتجاهات البحثية فى إدارة المعرفة
الاتجاهات البحثية فى إدارة المعرفةEssam Obaid
 
Habilidades comunicativas tercer corte
Habilidades comunicativas tercer corteHabilidades comunicativas tercer corte
Habilidades comunicativas tercer corteCristhian Martinez
 

Andere mochten auch (18)

Mensaje Divino
Mensaje DivinoMensaje Divino
Mensaje Divino
 
Acreditar ou não em Deus
Acreditar ou não em DeusAcreditar ou não em Deus
Acreditar ou não em Deus
 
El portafolio
El portafolioEl portafolio
El portafolio
 
Best Practices Portfolio Mngt
Best Practices Portfolio MngtBest Practices Portfolio Mngt
Best Practices Portfolio Mngt
 
Anexos
AnexosAnexos
Anexos
 
bba final research
bba final researchbba final research
bba final research
 
Bienvenidos
BienvenidosBienvenidos
Bienvenidos
 
Informe de laboratorio
Informe de laboratorioInforme de laboratorio
Informe de laboratorio
 
Evaluacion formativa-o-de-procesos (1)
Evaluacion formativa-o-de-procesos (1)Evaluacion formativa-o-de-procesos (1)
Evaluacion formativa-o-de-procesos (1)
 
Técnica de la pregunta
Técnica de la preguntaTécnica de la pregunta
Técnica de la pregunta
 
1. misiones-y-visiones
1. misiones-y-visiones1. misiones-y-visiones
1. misiones-y-visiones
 
التفكير العلمي وخصائصه
التفكير العلمي وخصائصهالتفكير العلمي وخصائصه
التفكير العلمي وخصائصه
 
الهرمينوطيقا بوصفها يقظة العيش في العالَم (تجربة مارتن هيدغر في محاضرات 1923)
الهرمينوطيقا بوصفها يقظة العيش في العالَم (تجربة مارتن هيدغر في محاضرات 1923)الهرمينوطيقا بوصفها يقظة العيش في العالَم (تجربة مارتن هيدغر في محاضرات 1923)
الهرمينوطيقا بوصفها يقظة العيش في العالَم (تجربة مارتن هيدغر في محاضرات 1923)
 
Eridania 110 anni - Chi sa fare la marmellata?
Eridania 110 anni - Chi sa fare la marmellata?Eridania 110 anni - Chi sa fare la marmellata?
Eridania 110 anni - Chi sa fare la marmellata?
 
ISS World Prague 2010 - DPI at 40G and 100G: Moving Beyond Appliances
ISS World Prague 2010 - DPI at 40G and 100G: Moving Beyond AppliancesISS World Prague 2010 - DPI at 40G and 100G: Moving Beyond Appliances
ISS World Prague 2010 - DPI at 40G and 100G: Moving Beyond Appliances
 
إدارة المعرفة
إدارة المعرفةإدارة المعرفة
إدارة المعرفة
 
الاتجاهات البحثية فى إدارة المعرفة
الاتجاهات البحثية فى إدارة المعرفةالاتجاهات البحثية فى إدارة المعرفة
الاتجاهات البحثية فى إدارة المعرفة
 
Habilidades comunicativas tercer corte
Habilidades comunicativas tercer corteHabilidades comunicativas tercer corte
Habilidades comunicativas tercer corte
 

Ähnlich wie Describe's Full of It's

We Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End DevelopmentWe Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End DevelopmentAll Things Open
 
Javascript tdd byandreapaciolla
Javascript tdd byandreapaciollaJavascript tdd byandreapaciolla
Javascript tdd byandreapaciollaAndrea Paciolla
 
Quick tour to front end unit testing using jasmine
Quick tour to front end unit testing using jasmineQuick tour to front end unit testing using jasmine
Quick tour to front end unit testing using jasmineGil Fink
 
Unit testing in iOS featuring OCUnit, GHUnit & OCMock
Unit testing in iOS featuring OCUnit, GHUnit & OCMockUnit testing in iOS featuring OCUnit, GHUnit & OCMock
Unit testing in iOS featuring OCUnit, GHUnit & OCMockRobot Media
 
utPLSQL: Unit Testing for Oracle PL/SQL
utPLSQL: Unit Testing for Oracle PL/SQLutPLSQL: Unit Testing for Oracle PL/SQL
utPLSQL: Unit Testing for Oracle PL/SQLSteven Feuerstein
 
谷歌 Scott-lessons learned in testability
谷歌 Scott-lessons learned in testability谷歌 Scott-lessons learned in testability
谷歌 Scott-lessons learned in testabilitydrewz lin
 
Grails unit testing
Grails unit testingGrails unit testing
Grails unit testingpleeps
 
Developer Test - Things to Know
Developer Test - Things to KnowDeveloper Test - Things to Know
Developer Test - Things to Knowvilniusjug
 
Mockito with a hint of PowerMock
Mockito with a hint of PowerMockMockito with a hint of PowerMock
Mockito with a hint of PowerMockYing Zhang
 
In search of JavaScript code quality: unit testing
In search of JavaScript code quality: unit testingIn search of JavaScript code quality: unit testing
In search of JavaScript code quality: unit testingAnna Khabibullina
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to javaciklum_ods
 
Developer Tests - Things to Know (Vilnius JUG)
Developer Tests - Things to Know (Vilnius JUG)Developer Tests - Things to Know (Vilnius JUG)
Developer Tests - Things to Know (Vilnius JUG)vilniusjug
 
An Introduction to AngularJs Unittesting
An Introduction to AngularJs UnittestingAn Introduction to AngularJs Unittesting
An Introduction to AngularJs UnittestingInthra onsap
 
Testing in AngularJS
Testing in AngularJSTesting in AngularJS
Testing in AngularJSPeter Drinnan
 
Testing with VS2010 - A Bugs Life
Testing with VS2010 - A Bugs LifeTesting with VS2010 - A Bugs Life
Testing with VS2010 - A Bugs LifePeter Gfader
 
Web technologies-course 12.pptx
Web technologies-course 12.pptxWeb technologies-course 12.pptx
Web technologies-course 12.pptxStefan Oprea
 
JAVASCRIPT TDD(Test driven Development) & Qunit Tutorial
JAVASCRIPT TDD(Test driven Development) & Qunit TutorialJAVASCRIPT TDD(Test driven Development) & Qunit Tutorial
JAVASCRIPT TDD(Test driven Development) & Qunit TutorialAnup Singh
 

Ähnlich wie Describe's Full of It's (20)

Test driven development
Test driven developmentTest driven development
Test driven development
 
We Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End DevelopmentWe Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End Development
 
Javascript tdd byandreapaciolla
Javascript tdd byandreapaciollaJavascript tdd byandreapaciolla
Javascript tdd byandreapaciolla
 
TDD & BDD
TDD & BDDTDD & BDD
TDD & BDD
 
Quick tour to front end unit testing using jasmine
Quick tour to front end unit testing using jasmineQuick tour to front end unit testing using jasmine
Quick tour to front end unit testing using jasmine
 
Unit testing in iOS featuring OCUnit, GHUnit & OCMock
Unit testing in iOS featuring OCUnit, GHUnit & OCMockUnit testing in iOS featuring OCUnit, GHUnit & OCMock
Unit testing in iOS featuring OCUnit, GHUnit & OCMock
 
utPLSQL: Unit Testing for Oracle PL/SQL
utPLSQL: Unit Testing for Oracle PL/SQLutPLSQL: Unit Testing for Oracle PL/SQL
utPLSQL: Unit Testing for Oracle PL/SQL
 
谷歌 Scott-lessons learned in testability
谷歌 Scott-lessons learned in testability谷歌 Scott-lessons learned in testability
谷歌 Scott-lessons learned in testability
 
Grails unit testing
Grails unit testingGrails unit testing
Grails unit testing
 
Developer Test - Things to Know
Developer Test - Things to KnowDeveloper Test - Things to Know
Developer Test - Things to Know
 
Mockito with a hint of PowerMock
Mockito with a hint of PowerMockMockito with a hint of PowerMock
Mockito with a hint of PowerMock
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
In search of JavaScript code quality: unit testing
In search of JavaScript code quality: unit testingIn search of JavaScript code quality: unit testing
In search of JavaScript code quality: unit testing
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to java
 
Developer Tests - Things to Know (Vilnius JUG)
Developer Tests - Things to Know (Vilnius JUG)Developer Tests - Things to Know (Vilnius JUG)
Developer Tests - Things to Know (Vilnius JUG)
 
An Introduction to AngularJs Unittesting
An Introduction to AngularJs UnittestingAn Introduction to AngularJs Unittesting
An Introduction to AngularJs Unittesting
 
Testing in AngularJS
Testing in AngularJSTesting in AngularJS
Testing in AngularJS
 
Testing with VS2010 - A Bugs Life
Testing with VS2010 - A Bugs LifeTesting with VS2010 - A Bugs Life
Testing with VS2010 - A Bugs Life
 
Web technologies-course 12.pptx
Web technologies-course 12.pptxWeb technologies-course 12.pptx
Web technologies-course 12.pptx
 
JAVASCRIPT TDD(Test driven Development) & Qunit Tutorial
JAVASCRIPT TDD(Test driven Development) & Qunit TutorialJAVASCRIPT TDD(Test driven Development) & Qunit Tutorial
JAVASCRIPT TDD(Test driven Development) & Qunit Tutorial
 

Kürzlich hochgeladen

Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 

Kürzlich hochgeladen (20)

Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 

Describe's Full of It's

  • 2. Hi, I’m Jim Lynch Front-End Engineer at Altered Image @webWhizJim Slides available here: 
 http://www.slideshare.net/JimLynch22/describes-full-of-its WebStorm Ambassador Programming Tweeter
  • 3. Who is This Talk For? • Anyone interested in unit testing. • AngularJS developers. • Front-End developers.
  • 4. Why Test? • To prevent regression (recurring bugs). • To catch bugs before end users see them. • To remove fear from refactoring. • So you don’t have to keep testing manually. • To document what your code should do. • To gain a sense of confidence that you 
 can never have without tests!
  • 5. If You Don’t Test… DON’T IGNORE TESTING!
  • 6. Artifacts • True, but also a clean production build (the dist/ directory) • When the project is over, what will you leave behind? • “A programmer’s deliverables should be clean code and clean tests” 
 - Pete Heard
  • 7. Anatomy of a Test Suite
  • 8. Anatomy of a Test Suite Test Suite
  • 9. Anatomy of a Test Suite Test Case Test Case Test Suite
  • 10. Anatomy of a Test Suite Test Case Assertion Assertion Assertion Test Case Test Suite
  • 11. Anatomy of a Test Suite Test Suite • A collection of independent tests. • Usually exists as it’s own file. • Contains methods for setting up for and tearing down unit tests. Test Case Assertion Assertion Assertion Test Case Test Suite
  • 12. Anatomy of a Test Suite Test Case • Tests a single “piece” of your application independent of the other code. • A function that can either pass or fail. • Each case should test a different “situation” from the user’s perspective (BDD). Test Case Assertion Assertion Assertion Test Case Test Suite
  • 13. Anatomy of a Test Suite Test Case Assertion Assertion Assertion Test Case Test Suite Assertion • Uses a matcher API for comparing values 
 (eg toEqual) • Tells the test case when it should pass and when it should fail. • If output values for SUT (system under test) are as expected then behavior of SUT is as expected.
  • 14. Unit testing in JavaScript uses a peculiar syntax…
  • 15. If you are ever feeling lost, just remember that a test suite in JavaScript is this:
  • 16. A describe full of it’s with some beforeEach’s
  • 17. Test Suite Anatomy for JS
 Testing Frameworks it describeTest Suite Test Case Assertion expect it expect expect
  • 18. Building Your First Test Suite • A test suite is simply a Javascript file. • Karma will automatically consider *.spec.js files to be test suites. Step 1) Create an empty *.spec.js file.
  • 19. Keep the Tests Close By • For every .js file, make a .spec.js file right next to it. • Test file should have exact same name 
 (other than the .spec part). • Having a root level “tests” folder is an old-school practice and not recommended. • Gulp scripts should recognize tests throughout entire project directory.
  • 20. Keep the Family Together
  • 23. describe describe(‘MyController’, function() { }) Building Your First Test Suite Adding a describe.
  • 24. describe describe(‘MyController’, function() { }) A name for your test suite 
 (can be anything, but it should describe what you are testing!). Building Your First Test Suite Adding a describe.
  • 25. describe describe(‘MyController’, function() { }) A function that takes no arguments. This creates the “wrapper” around your test cases. Building Your First Test Suite Adding a describe.
  • 26. describe describe(‘MyController’, function() { }) it Building Your First Test Suite it(‘Should do something…’, function() { }); Adding an it.
  • 27. describe describe(‘MyController’, function() { }) Some text that describes the purpose of this test case. Can be anything but usually begins with the word should. it Building Your First Test Suite it(‘Should do something…’, function() { }); Adding an it.
  • 28. describe describe(‘MyController’, function() { }) it Building Your First Test Suite it(‘Should do something…’, function() { }); A function that takes no arguments. The code for this test case is contained in this function. Adding an it.
  • 29. describe describe(‘MyController’, function() { }) it Building Your First Test Suite it(‘Should do something…’, function() { }); Adding an assertion. expect expect(true).toEqual(true);
  • 30. describe describe(‘MyController’, function() { }) it Building Your First Test Suite it(‘Should do something…’, function() { }); Adding an assertion. expect expect(true).toEqual(true); The expect keyword let’s the test case know that we want to do an assertion here.
  • 31. describe describe(‘MyController’, function() { }) it Building Your First Test Suite it(‘Should do something…’, function() { }); Adding an assertion. expect expect(true).toEqual(true); The expect method takes one argument, the variable whose value you wish to check.
  • 32. describe describe(‘MyController’, function() { }) it Building Your First Test Suite it(‘Should do something…’, function() { }); Adding an assertion. expect expect(true).toEqual(true); Depending on how you wish to compare the two values, a matcher method is chained onto the end of the expect.
  • 33. describe describe(‘MyController’, function() { }) it Building Your First Test Suite it(‘Should do something…’, function() { }); Adding an assertion. expect expect(true).toEqual(true); The matcher method takes one argument. The expected value for the variable being passed into the expect method.
  • 34. Building Your First Test Suite You did it! describe(‘MyController’, function() { }) it(‘Should do something…’, function() { }); expect(true).toEqual(true); Ahhh, so a test suite is really just…
  • 35. A describe full of it’s! …with some beforeEach’s.
  • 36. beforeEach • Goes inside the describe but outside of the it’s. describe it expect it expect beforeEach beforeEach • Gives you access to your module, controllers, services, etc. through DI.
  • 37. beforeEach describe(‘MyController’, function() { }) it(‘Should do something…’, function() { }); expect(true).toEqual(true); beforeEach(module(‘YOUR_MODULE’));
  • 39. beforeEach beforeEach(module(‘YOUR_MODULE’)); Allows you to load in your model so that you have access to it’s controllers, services, filters, etc.
  • 41. Injecting a Controller with beforeEach describe(‘MyController’, function() { }) it(‘Should do something…’, function() { }); expect(true).toEqual(true); beforeEach(module(‘YOUR_MODULE’)); var myController = $controller('MyController', {}) beforeEach(inject(function(_$controller_) { $controller = _$controller_; }));
  • 42. Injecting a Controller with beforeEach beforeEach(inject(function(_$controller_) { $controller = _$controller_; })); A method from the angular- mocks.js file that allows you to inject services into your unit tests.
  • 43. Injecting a Controller with beforeEach beforeEach(inject(function(_$controller_) { $controller = _$controller_; })); Angular knows to “unwrap”, the underscores, find corresponding provider, and give you a reference to the service. Q. But what’s the deal with those underscores on either side?
  • 44. Injecting a Controller with beforeEach beforeEach(inject(function(_$controller_) { $controller = _$controller_; })); Angular knows to “unwrap”, the underscores, find corresponding provider, and give you a reference to the service. Suppose you didn’t use the underscores. You want to set a variable named $controller available inside of your “it’s” equal to the function’s argument, but the function argument must be named $controller in order to be injected properly. Doing this is not possible in JavaScript (outer variable is overshadowed) so the Angular team implemented the underscore notation to work around the issue.
  • 45. Injecting a Controller with beforeEach beforeEach(inject(function(_$controller_) { $controller = _$controller_; })); You can then use this global reference anywhere in the test suite to instantiate controllers.
  • 46. Using the Injected Controller var myController = $controller('MyController', {}) This var has all of the properties and methods you defined for the specified controller.
  • 47. Using the Injected Controller var myController = $controller('MyController', {}) This is the global $controller variable that was set in the beforeEach.
  • 48. Using the Injected Controller var myController = $controller('MyController', {}) Replace this with the name of the controller you want to instantiate.
  • 49. Pass in any arguments to your controller with this object. var myController = $controller('MyController', {}) Using the Injected Controller
  • 50. The Complete Suite describe(‘MyController’, function() { }) it(‘Should do something…’, function() { }); expect(true).toEqual(true); beforeEach(module(‘YOUR_MODULE’)); var myController = $controller('MyController', {}) beforeEach(inject(function(_$controller_) { $controller = _$controller_; })); A good start to a nice looking test suite:
  • 51. Okay, so how do I run these test suites? Q ) KarmaA )
  • 52. Fun Facts About Karma • Worked with non-Angular projects as well. • A command line test runner built to be fast. • Integrates with practically all CI tools. • Runs tests on all browsers (even PhantomJS).
  • 53. How Does Karma Work? • It integrates nicely with Gulp and Grunt (gulp test) or runs on its own (karma start). • It’s installed from npm: npm install karma • The karma.conf.js file allows you to configure it to run with your desired settings. • It automatically see *.spec.js files in your project folder as test suites.
  • 54. How do I add Karma to My Project?
  • 55. Easy Way Hard(er) Way Use a yeoman generator to scaffold a project that already has karma set up for you (such as the Gulp-Angular yeoman generator or the Angular 2 CLI). Install and configure it manually. karma-runner.github.io Adding Karma to Your Project And then you’re ready to start testing!
  • 56. Workflow Browsersync Chrome Dev Tools See Your App Running Logs / Debugging Runs Unit Tests on File Changes No need to test manually Reminds you to write more tests Gulp Serve Gulp Test:Auto
  • 57. Workflow Gulp Serve Gulp Test:Auto ??? or
  • 59. “Dual Shell Development” Gulp serve in one command shell and gulp test:auto in the other.
  • 60. So What’s Different for Unit Testing Angular 2? Not Much!
  • 61. The CLI Replaces Gulp Tasks https://cli.angular.io/ Angular 1 Angular 2 yo gulp-angular ng new / ng initNew project: gulp serve ng serveRun locally: gulp serve:dist ng serve —-buildRun prod build: gulp test:auto ng test -wRun unit tests gulp protractor ng e2eRun e2e tests gulp build ng buildCreate prod build
  • 62. In Angular 2 You Can Still Think of a Unit Test as…
  • 63. A describe full of it’s with some beforeEach’s
  • 64. A describe full of it’s with some beforeEach’s (with a bunch of “import” statements)
  • 65. A describe full of it’s with some beforeEach’s (with a bunch of “import” statements) (And also “beforeEachProviders”)
  • 66. Example of an Angular 2 Unit Test
  • 67. Thanks! twitter.com/webWhizJim jim@ng-nj.com www.wisdomofjim.com The official “Describe’s Full of It’s” T-Shirt! Available now! Slides available here: 
 http://www.slideshare.net/ JimLynch22/describes-full-of-its github.com/JimTheMan www.teepublic.com/t- shirt/468156-describes- full-of-its-white-text