SlideShare a Scribd company logo
1 of 21
Test like a pro
Mike North - Silicon Valley Ember.js Meetup - April 30, 2015
@MichaelLNorth2
Mike North
@MichaelLNorth
The Plan
3
Testing Basics
 Test types
 Test technology
Testing with Ember
 Test helpers
 Simulating an API
 Lessons learned @
Yahoo
Test Automation
 Continuous Integration
 Cross-Device testing
Testing Basics
@MichaelLNorth
Unit tests
5
Fast & Focused
Isolated
Excellent at testing
“algorithmic complexity”
Functional tests
(a.k.a. “acceptance tests)
Test behavior in context
Simulate user behavior
Often based on specs or
acceptance criteria
Integration tests
Ensure that contracts at
integration points stay in
place
NOT functional tests
“End to end test”
Check for multi-
component system
integrity
Usually very slow
@MichaelLNorth
Test types - how to test a….
6
Algorithm Unit Test
Acceptance Criteria Acceptance/Functional Test
Workflow Acceptance/Functional Test
Contract between two
components
Integration test
Total System Integrity “End to end” test
Testing with Ember
8
Testing with Ember - QUnit Modules
import Ember from 'ember';
import startApp from '../../tests/helpers/start-
app';
import { test } from 'ember-qunit';
var App;
module('Acceptance - Loader', {
beforeEach() { App = startApp(); },
afterEach() { Ember.run(App, 'destroy'); }
});
test("Load the page I'm testing", assert => {
visit('/loader');
assert.equal(Ember.$('.loader').length, 0,
'No loader showing');
click('.stop-loader-button');
andThen(() => {
assert.equal(Ember.$('.loader').length, 0,
'No loader showing');
});
});
per-test setup
and teardown
hooks
9
Testing with Ember - ember-test-helpers modules
moduleFor(name [, description [, callbacks]])
moduleForModel( … )
moduleForComponent( … )
• Setup an empty container to unit test in isolation
• Set context of view, so bindings work
moduleForComponent('my-tabs', {
needs: ['component:my-tab']
});
@MichaelLNorth
Testing with Ember - Integration Test Helpers
10
 visit(url)
 fillIn(selector, text)
 click(selector)
 keyEvent(sel, type, key)
 triggerEvent(sel, type, opts)
 find(selector, content)
 currentPath()
 currentRouteName()
 currentURL()
Async Sync
@MichaelLNorth
An example
11
Router.map(() => {
this.resource('lists', () => {
this.route('index', {path: '/'});
});
this.resource('list', {path: 'list/:id'}, () => {
this.route('show', {path: '/'});
});
});
router.js
@MichaelLNorth
Steps
Testing with Ember - Integration Test Helpers - Async
12
test('Drilling into a shopping list from the index page', assert => {
visit('/lists');
andThen(() => {
assert.equal(
currentURL(), ‘/lists',
'Should be at the index page’
);
assert.equal(
find('.list-of-lists .list-item').length, 2,
'Two shopping lists are in the index’
);
});
click('.list-of-lists .list-item:nth-child(1)');
andThen(() => {
assert.equal(currentURL(), ‘/list/1’,
'Showing the first shopping list’
);
});
console.log('Hello world!');
});
@MichaelLNorth
Testing with Ember - Simulating an API
13
trek/fakehr trek/pretender
• Resolve a pending request • Set up a fake “server”
/api/lines
/api/items?ids[]=1&ids[]=2&ids[]=3
"items": [
{"id": 1, "name": "Apple", "list": 1},
{"id": 2, "name": "Pear", "list": 1},
{"id": 3, "name": "Grape", "list": 1}
]
"lists": [
{"id": 1, "name": "Fruit", "items": [1, 2, 3]},
{"id": 2, "name": "Vegetables", "items": [4, 5, 6]}
]
@MichaelLNorth
Testing with Ember - Simulating an API
14
trek/fakehr trek/pretender
@MichaelLNorth
Testing with Ember - Simulating an API
15
/api/lines
/api/lines/1/items
trek/fakehr
Continuous Integration
@MichaelLNorth
Continuous Integration
17
Clone
Checkout
before_install
install
before_script
script
after_success after_failure
after_script
npm install; bower
install
ember test ci
setup phantomjs
2.0
mark PR
“ok”
mark PR
“failed”
@MichaelLNorth
Continuous Integration
w/ ember-try
18
kategengler/ember-try
env:
matrix:
- EMBER_TRY_SCENARIO=default
- EMBER_TRY_SCENARIO=ember-release
- EMBER_TRY_SCENARIO=ember-beta
- EMBER_TRY_SCENARIO=ember-canary
.travis.yml
matrix:
fast_finish: true
allow_failures:
- env: EMBER_TRY_SCENARIO=ember-canary
Build has passed, but this is still running!
@MichaelLNorth
Cross-Device Testing
w/ ember-cli-sauce
19
johanneswuerbach/ember-cli-sauce
@MichaelLNorth
Cross-Device Testing
w/ ember-cli-sauce
20
PROTIP: You may need to fiddle with
testem port and/or hostname to get OS X
working
{
"framework": "qunit",
"host": "lvh.me",
"port": "7000",
"test_page": "tests/index.html?hidepassed",
...
}
@MichaelLNorth21
$0
for open
source

More Related Content

What's hot

Angular Unit Testing NDC Minn 2018
Angular Unit Testing NDC Minn 2018Angular Unit Testing NDC Minn 2018
Angular Unit Testing NDC Minn 2018Justin James
 
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 Testing w/Karma and Jasmine
AngularJS Unit Testing w/Karma and JasmineAngularJS Unit Testing w/Karma and Jasmine
AngularJS Unit Testing w/Karma and Jasminefoxp2code
 
Unit Testing Express and Koa Middleware in ES2015
Unit Testing Express and Koa Middleware in ES2015Unit Testing Express and Koa Middleware in ES2015
Unit Testing Express and Koa Middleware in ES2015Morris Singer
 
Unit Testing JavaScript Applications
Unit Testing JavaScript ApplicationsUnit Testing JavaScript Applications
Unit Testing JavaScript ApplicationsYnon Perek
 
Testing Javascript with Jasmine
Testing Javascript with JasmineTesting Javascript with Jasmine
Testing Javascript with JasmineTim Tyrrell
 
Introduction to Protractor
Introduction to ProtractorIntroduction to Protractor
Introduction to ProtractorJie-Wei Wu
 
Testing in AngularJS
Testing in AngularJSTesting in AngularJS
Testing in AngularJSPeter Drinnan
 
Painless JavaScript Testing with Jest
Painless JavaScript Testing with JestPainless JavaScript Testing with Jest
Painless JavaScript Testing with JestMichał Pierzchała
 
Unit testing of java script and angularjs application using Karma Jasmine Fra...
Unit testing of java script and angularjs application using Karma Jasmine Fra...Unit testing of java script and angularjs application using Karma Jasmine Fra...
Unit testing of java script and angularjs application using Karma Jasmine Fra...Samyak Bhalerao
 
Angularjs - Unit testing introduction
Angularjs - Unit testing introductionAngularjs - Unit testing introduction
Angularjs - Unit testing introductionNir Kaufman
 
Angular Unit Testing from the Trenches
Angular Unit Testing from the TrenchesAngular Unit Testing from the Trenches
Angular Unit Testing from the TrenchesJustin James
 
Painless Javascript Unit Testing
Painless Javascript Unit TestingPainless Javascript Unit Testing
Painless Javascript Unit TestingBenjamin Wilson
 
Unit testing JavaScript: Jasmine & karma intro
Unit testing JavaScript: Jasmine & karma introUnit testing JavaScript: Jasmine & karma intro
Unit testing JavaScript: Jasmine & karma introMaurice De Beijer [MVP]
 
Unit testing JavaScript using Mocha and Node
Unit testing JavaScript using Mocha and NodeUnit testing JavaScript using Mocha and Node
Unit testing JavaScript using Mocha and NodeJosh Mock
 
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
 

What's hot (20)

Angular Unit Testing NDC Minn 2018
Angular Unit Testing NDC Minn 2018Angular Unit Testing NDC Minn 2018
Angular Unit Testing NDC Minn 2018
 
Vuejs testing
Vuejs testingVuejs testing
Vuejs 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 Testing w/Karma and Jasmine
AngularJS Unit Testing w/Karma and JasmineAngularJS Unit Testing w/Karma and Jasmine
AngularJS Unit Testing w/Karma and Jasmine
 
Unit Testing Express and Koa Middleware in ES2015
Unit Testing Express and Koa Middleware in ES2015Unit Testing Express and Koa Middleware in ES2015
Unit Testing Express and Koa Middleware in ES2015
 
Unit Testing JavaScript Applications
Unit Testing JavaScript ApplicationsUnit Testing JavaScript Applications
Unit Testing JavaScript Applications
 
Testing Javascript with Jasmine
Testing Javascript with JasmineTesting Javascript with Jasmine
Testing Javascript with Jasmine
 
Introduction to Protractor
Introduction to ProtractorIntroduction to Protractor
Introduction to Protractor
 
Testing in AngularJS
Testing in AngularJSTesting in AngularJS
Testing in AngularJS
 
Full Stack Unit Testing
Full Stack Unit TestingFull Stack Unit Testing
Full Stack Unit Testing
 
Painless JavaScript Testing with Jest
Painless JavaScript Testing with JestPainless JavaScript Testing with Jest
Painless JavaScript Testing with Jest
 
Angular Unit Testing
Angular Unit TestingAngular Unit Testing
Angular Unit Testing
 
Unit testing of java script and angularjs application using Karma Jasmine Fra...
Unit testing of java script and angularjs application using Karma Jasmine Fra...Unit testing of java script and angularjs application using Karma Jasmine Fra...
Unit testing of java script and angularjs application using Karma Jasmine Fra...
 
Angular testing
Angular testingAngular testing
Angular testing
 
Angularjs - Unit testing introduction
Angularjs - Unit testing introductionAngularjs - Unit testing introduction
Angularjs - Unit testing introduction
 
Angular Unit Testing from the Trenches
Angular Unit Testing from the TrenchesAngular Unit Testing from the Trenches
Angular Unit Testing from the Trenches
 
Painless Javascript Unit Testing
Painless Javascript Unit TestingPainless Javascript Unit Testing
Painless Javascript Unit Testing
 
Unit testing JavaScript: Jasmine & karma intro
Unit testing JavaScript: Jasmine & karma introUnit testing JavaScript: Jasmine & karma intro
Unit testing JavaScript: Jasmine & karma intro
 
Unit testing JavaScript using Mocha and Node
Unit testing JavaScript using Mocha and NodeUnit testing JavaScript using Mocha and Node
Unit testing JavaScript using Mocha and Node
 
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
 

Similar to Test like a pro with Ember.js

Getting to Grips with SilverStripe Testing
Getting to Grips with SilverStripe TestingGetting to Grips with SilverStripe Testing
Getting to Grips with SilverStripe TestingMark Rickerby
 
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
 
Oh so you test? - A guide to testing on Android from Unit to Mutation
Oh so you test? - A guide to testing on Android from Unit to MutationOh so you test? - A guide to testing on Android from Unit to Mutation
Oh so you test? - A guide to testing on Android from Unit to MutationPaul Blundell
 
Test in action week 4
Test in action   week 4Test in action   week 4
Test in action week 4Yi-Huan Chan
 
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015Codemotion
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginnersDivakar Gu
 
Oleksandr Valetskyy - Increase the quality of your code with property-based t...
Oleksandr Valetskyy - Increase the quality of your code with property-based t...Oleksandr Valetskyy - Increase the quality of your code with property-based t...
Oleksandr Valetskyy - Increase the quality of your code with property-based t...Oleksandr Valetskyy
 
Java Unit Test - JUnit
Java Unit Test - JUnitJava Unit Test - JUnit
Java Unit Test - JUnitAktuğ Urun
 
How To Test Everything
How To Test EverythingHow To Test Everything
How To Test Everythingnoelrap
 
More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)
More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)
More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)Jen Wong
 
Qtp Training
Qtp TrainingQtp Training
Qtp Trainingmehramit
 
Test Driven Development with PHPUnit
Test Driven Development with PHPUnitTest Driven Development with PHPUnit
Test Driven Development with PHPUnitMindfire Solutions
 
Workshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testingWorkshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testingVisual Engineering
 
Appium TestNG Framework and Multi-Device Automation Execution
Appium TestNG Framework and Multi-Device Automation ExecutionAppium TestNG Framework and Multi-Device Automation Execution
Appium TestNG Framework and Multi-Device Automation ExecutionpCloudy
 
Grails unit testing
Grails unit testingGrails unit testing
Grails unit testingpleeps
 

Similar to Test like a pro with Ember.js (20)

Getting to Grips with SilverStripe Testing
Getting to Grips with SilverStripe TestingGetting to Grips with SilverStripe Testing
Getting to Grips with SilverStripe Testing
 
Laravel Unit Testing
Laravel Unit TestingLaravel Unit Testing
Laravel Unit Testing
 
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
 
Selenium and The Grinder
Selenium and The GrinderSelenium and The Grinder
Selenium and The Grinder
 
Oh so you test? - A guide to testing on Android from Unit to Mutation
Oh so you test? - A guide to testing on Android from Unit to MutationOh so you test? - A guide to testing on Android from Unit to Mutation
Oh so you test? - A guide to testing on Android from Unit to Mutation
 
Test in action week 4
Test in action   week 4Test in action   week 4
Test in action week 4
 
Good Practices On Test Automation
Good Practices On Test AutomationGood Practices On Test Automation
Good Practices On Test Automation
 
Clean tests good tests
Clean tests   good testsClean tests   good tests
Clean tests good tests
 
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
 
Oleksandr Valetskyy - Increase the quality of your code with property-based t...
Oleksandr Valetskyy - Increase the quality of your code with property-based t...Oleksandr Valetskyy - Increase the quality of your code with property-based t...
Oleksandr Valetskyy - Increase the quality of your code with property-based t...
 
Struts2 - 101
Struts2 - 101Struts2 - 101
Struts2 - 101
 
Java Unit Test - JUnit
Java Unit Test - JUnitJava Unit Test - JUnit
Java Unit Test - JUnit
 
How To Test Everything
How To Test EverythingHow To Test Everything
How To Test Everything
 
More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)
More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)
More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)
 
Qtp Training
Qtp TrainingQtp Training
Qtp Training
 
Test Driven Development with PHPUnit
Test Driven Development with PHPUnitTest Driven Development with PHPUnit
Test Driven Development with PHPUnit
 
Workshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testingWorkshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testing
 
Appium TestNG Framework and Multi-Device Automation Execution
Appium TestNG Framework and Multi-Device Automation ExecutionAppium TestNG Framework and Multi-Device Automation Execution
Appium TestNG Framework and Multi-Device Automation Execution
 
Grails unit testing
Grails unit testingGrails unit testing
Grails unit testing
 

More from Mike North

Web Security: A Primer for Developers
Web Security: A Primer for DevelopersWeb Security: A Primer for Developers
Web Security: A Primer for DevelopersMike North
 
A Debugging Adventure: Journey through Ember.js Glue
A Debugging Adventure: Journey through Ember.js GlueA Debugging Adventure: Journey through Ember.js Glue
A Debugging Adventure: Journey through Ember.js GlueMike North
 
Anatomy of a Progressive Web App
Anatomy of a Progressive Web AppAnatomy of a Progressive Web App
Anatomy of a Progressive Web AppMike North
 
Web and Native: Bridging the Gap
Web and Native: Bridging the GapWeb and Native: Bridging the Gap
Web and Native: Bridging the GapMike North
 
The Road to Native Web Components
The Road to Native Web ComponentsThe Road to Native Web Components
The Road to Native Web ComponentsMike North
 
Enemy of the state
Enemy of the stateEnemy of the state
Enemy of the stateMike North
 
Phoenix for Rubyists - Rubyconf Brazil 2016
Phoenix for Rubyists - Rubyconf Brazil 2016Phoenix for Rubyists - Rubyconf Brazil 2016
Phoenix for Rubyists - Rubyconf Brazil 2016Mike North
 
Phoenix for Rubyists
Phoenix for RubyistsPhoenix for Rubyists
Phoenix for RubyistsMike North
 
Write Once, Run Everywhere - Ember.js Munich
Write Once, Run Everywhere - Ember.js MunichWrite Once, Run Everywhere - Ember.js Munich
Write Once, Run Everywhere - Ember.js MunichMike North
 
Delightful UX for Distributed Systems
Delightful UX for Distributed SystemsDelightful UX for Distributed Systems
Delightful UX for Distributed SystemsMike North
 
Modern, Scalable, Ambitious apps with Ember.js
Modern, Scalable, Ambitious apps with Ember.jsModern, Scalable, Ambitious apps with Ember.js
Modern, Scalable, Ambitious apps with Ember.jsMike North
 
Ember addons, served three ways
Ember addons, served three waysEmber addons, served three ways
Ember addons, served three waysMike North
 
CI/CD and Asset Serving for Single Page Apps
CI/CD and Asset Serving for Single Page AppsCI/CD and Asset Serving for Single Page Apps
CI/CD and Asset Serving for Single Page AppsMike North
 
User percieved performance
User percieved performanceUser percieved performance
User percieved performanceMike North
 
User-percieved performance
User-percieved performanceUser-percieved performance
User-percieved performanceMike North
 
Write Once, Run Everywhere
Write Once, Run EverywhereWrite Once, Run Everywhere
Write Once, Run EverywhereMike North
 
Compose all the things (Wicked Good Ember 2015)
Compose all the things (Wicked Good Ember 2015)Compose all the things (Wicked Good Ember 2015)
Compose all the things (Wicked Good Ember 2015)Mike North
 
Async JavaScript in ES7
Async JavaScript in ES7Async JavaScript in ES7
Async JavaScript in ES7Mike North
 
Modern Web UI - Web components
Modern Web UI - Web componentsModern Web UI - Web components
Modern Web UI - Web componentsMike North
 

More from Mike North (19)

Web Security: A Primer for Developers
Web Security: A Primer for DevelopersWeb Security: A Primer for Developers
Web Security: A Primer for Developers
 
A Debugging Adventure: Journey through Ember.js Glue
A Debugging Adventure: Journey through Ember.js GlueA Debugging Adventure: Journey through Ember.js Glue
A Debugging Adventure: Journey through Ember.js Glue
 
Anatomy of a Progressive Web App
Anatomy of a Progressive Web AppAnatomy of a Progressive Web App
Anatomy of a Progressive Web App
 
Web and Native: Bridging the Gap
Web and Native: Bridging the GapWeb and Native: Bridging the Gap
Web and Native: Bridging the Gap
 
The Road to Native Web Components
The Road to Native Web ComponentsThe Road to Native Web Components
The Road to Native Web Components
 
Enemy of the state
Enemy of the stateEnemy of the state
Enemy of the state
 
Phoenix for Rubyists - Rubyconf Brazil 2016
Phoenix for Rubyists - Rubyconf Brazil 2016Phoenix for Rubyists - Rubyconf Brazil 2016
Phoenix for Rubyists - Rubyconf Brazil 2016
 
Phoenix for Rubyists
Phoenix for RubyistsPhoenix for Rubyists
Phoenix for Rubyists
 
Write Once, Run Everywhere - Ember.js Munich
Write Once, Run Everywhere - Ember.js MunichWrite Once, Run Everywhere - Ember.js Munich
Write Once, Run Everywhere - Ember.js Munich
 
Delightful UX for Distributed Systems
Delightful UX for Distributed SystemsDelightful UX for Distributed Systems
Delightful UX for Distributed Systems
 
Modern, Scalable, Ambitious apps with Ember.js
Modern, Scalable, Ambitious apps with Ember.jsModern, Scalable, Ambitious apps with Ember.js
Modern, Scalable, Ambitious apps with Ember.js
 
Ember addons, served three ways
Ember addons, served three waysEmber addons, served three ways
Ember addons, served three ways
 
CI/CD and Asset Serving for Single Page Apps
CI/CD and Asset Serving for Single Page AppsCI/CD and Asset Serving for Single Page Apps
CI/CD and Asset Serving for Single Page Apps
 
User percieved performance
User percieved performanceUser percieved performance
User percieved performance
 
User-percieved performance
User-percieved performanceUser-percieved performance
User-percieved performance
 
Write Once, Run Everywhere
Write Once, Run EverywhereWrite Once, Run Everywhere
Write Once, Run Everywhere
 
Compose all the things (Wicked Good Ember 2015)
Compose all the things (Wicked Good Ember 2015)Compose all the things (Wicked Good Ember 2015)
Compose all the things (Wicked Good Ember 2015)
 
Async JavaScript in ES7
Async JavaScript in ES7Async JavaScript in ES7
Async JavaScript in ES7
 
Modern Web UI - Web components
Modern Web UI - Web componentsModern Web UI - Web components
Modern Web UI - Web components
 

Recently uploaded

Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 

Recently uploaded (20)

E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 

Test like a pro with Ember.js

  • 1. Test like a pro Mike North - Silicon Valley Ember.js Meetup - April 30, 2015
  • 3. @MichaelLNorth The Plan 3 Testing Basics  Test types  Test technology Testing with Ember  Test helpers  Simulating an API  Lessons learned @ Yahoo Test Automation  Continuous Integration  Cross-Device testing
  • 5. @MichaelLNorth Unit tests 5 Fast & Focused Isolated Excellent at testing “algorithmic complexity” Functional tests (a.k.a. “acceptance tests) Test behavior in context Simulate user behavior Often based on specs or acceptance criteria Integration tests Ensure that contracts at integration points stay in place NOT functional tests “End to end test” Check for multi- component system integrity Usually very slow
  • 6. @MichaelLNorth Test types - how to test a…. 6 Algorithm Unit Test Acceptance Criteria Acceptance/Functional Test Workflow Acceptance/Functional Test Contract between two components Integration test Total System Integrity “End to end” test
  • 8. 8 Testing with Ember - QUnit Modules import Ember from 'ember'; import startApp from '../../tests/helpers/start- app'; import { test } from 'ember-qunit'; var App; module('Acceptance - Loader', { beforeEach() { App = startApp(); }, afterEach() { Ember.run(App, 'destroy'); } }); test("Load the page I'm testing", assert => { visit('/loader'); assert.equal(Ember.$('.loader').length, 0, 'No loader showing'); click('.stop-loader-button'); andThen(() => { assert.equal(Ember.$('.loader').length, 0, 'No loader showing'); }); }); per-test setup and teardown hooks
  • 9. 9 Testing with Ember - ember-test-helpers modules moduleFor(name [, description [, callbacks]]) moduleForModel( … ) moduleForComponent( … ) • Setup an empty container to unit test in isolation • Set context of view, so bindings work moduleForComponent('my-tabs', { needs: ['component:my-tab'] });
  • 10. @MichaelLNorth Testing with Ember - Integration Test Helpers 10  visit(url)  fillIn(selector, text)  click(selector)  keyEvent(sel, type, key)  triggerEvent(sel, type, opts)  find(selector, content)  currentPath()  currentRouteName()  currentURL() Async Sync
  • 11. @MichaelLNorth An example 11 Router.map(() => { this.resource('lists', () => { this.route('index', {path: '/'}); }); this.resource('list', {path: 'list/:id'}, () => { this.route('show', {path: '/'}); }); }); router.js
  • 12. @MichaelLNorth Steps Testing with Ember - Integration Test Helpers - Async 12 test('Drilling into a shopping list from the index page', assert => { visit('/lists'); andThen(() => { assert.equal( currentURL(), ‘/lists', 'Should be at the index page’ ); assert.equal( find('.list-of-lists .list-item').length, 2, 'Two shopping lists are in the index’ ); }); click('.list-of-lists .list-item:nth-child(1)'); andThen(() => { assert.equal(currentURL(), ‘/list/1’, 'Showing the first shopping list’ ); }); console.log('Hello world!'); });
  • 13. @MichaelLNorth Testing with Ember - Simulating an API 13 trek/fakehr trek/pretender • Resolve a pending request • Set up a fake “server” /api/lines /api/items?ids[]=1&ids[]=2&ids[]=3 "items": [ {"id": 1, "name": "Apple", "list": 1}, {"id": 2, "name": "Pear", "list": 1}, {"id": 3, "name": "Grape", "list": 1} ] "lists": [ {"id": 1, "name": "Fruit", "items": [1, 2, 3]}, {"id": 2, "name": "Vegetables", "items": [4, 5, 6]} ]
  • 14. @MichaelLNorth Testing with Ember - Simulating an API 14 trek/fakehr trek/pretender
  • 15. @MichaelLNorth Testing with Ember - Simulating an API 15 /api/lines /api/lines/1/items trek/fakehr
  • 17. @MichaelLNorth Continuous Integration 17 Clone Checkout before_install install before_script script after_success after_failure after_script npm install; bower install ember test ci setup phantomjs 2.0 mark PR “ok” mark PR “failed”
  • 18. @MichaelLNorth Continuous Integration w/ ember-try 18 kategengler/ember-try env: matrix: - EMBER_TRY_SCENARIO=default - EMBER_TRY_SCENARIO=ember-release - EMBER_TRY_SCENARIO=ember-beta - EMBER_TRY_SCENARIO=ember-canary .travis.yml matrix: fast_finish: true allow_failures: - env: EMBER_TRY_SCENARIO=ember-canary Build has passed, but this is still running!
  • 20. @MichaelLNorth Cross-Device Testing w/ ember-cli-sauce 20 PROTIP: You may need to fiddle with testem port and/or hostname to get OS X working { "framework": "qunit", "host": "lvh.me", "port": "7000", "test_page": "tests/index.html?hidepassed", ... }