SlideShare une entreprise Scribd logo
1  sur  30
Télécharger pour lire hors ligne
(Unit) Testing
in
Stefan Fochler
About Testing
About Testing
• Make sure that stuff works…
About Testing
• Make sure that stuff works…
• …even after code changes or refactoring
About Testing
• Make sure that stuff works…
• …even after code changes or refactoring
• Automation is key
About Testing
About Testing
• Unit Testing
• Verify, that isolated chunks of functionality work
• Don't worry about their dependencies
About Testing
• Unit Testing
• Verify, that isolated chunks of functionality work
• Don't worry about their dependencies
• Integration Testing
• Test user interaction and application flow
About Testing
About Testing
• Tools
• QUnit testing framework
• (async) helpers in ember-testing
• Test Runner (testem)
• Test Loader (ember-cli)
Short Demo
Helpers in Ember-QUnit
Helpers in Ember-QUnit
• moduleFor(name, description, callbacks);
• Subject: controller:application, route:index etc.
Helpers in Ember-QUnit
• moduleFor(name, description, callbacks);
• Subject: controller:application, route:index etc.
• moduleForComponent(name, description, callbacks);
• Subject: x-foo, select-2 etc.
Helpers in Ember-QUnit
• moduleFor(name, description, callbacks);
• Subject: controller:application, route:index etc.
• moduleForComponent(name, description, callbacks);
• Subject: x-foo, select-2 etc.
• moduleForModel(name, description, callbacks);
• Subject: user, table etc.
Helpers in Ember-QUnit
• moduleFor(name, description, callbacks);
• Subject: controller:application, route:index etc.
• moduleForComponent(name, description, callbacks);
• Subject: x-foo, select-2 etc.
• moduleForModel(name, description, callbacks);
• Subject: user, table etc.
• test(name, callback);
Helpers in Ember-Testing I
Helpers in Ember-Testing I
• Async
• visit(url)
• fillIn(selector, text)
• click(selector)
• keyEvent(selector, type, keyCode)
Helpers in Ember-Testing I
• Async
• visit(url)
• fillIn(selector, text)
• click(selector)
• keyEvent(selector, type, keyCode)
• Sync
• find(selector, context)
• currentPath()
• currentURL()
Helpers in Ember-Testing II
Helpers in Ember-Testing II
• Wait
• andThen(callback)
Helpers in Ember-Testing II
• Wait
• andThen(callback)
• Custom Helpers
• Ember.Test.registerHelper
• Ember.Test.registerAsyncHelper
Testing Components I
var App, component;
!
moduleForComponent('select-2', 'Select2Component', {
setup: function() {
App = startApp();
// create instance of our component
component = this.subject();
},
teardown: function() {
Ember.run(App, 'destroy');
Ember.run(component, 'destroy');
}
});
Testing Components II
test("it renders", function() {
expect(2);
!
equal(component.state, 'preRender');
!
// appends the component to the page
this.append();
!
equal(component.state, 'inDOM');
});
Testing Components III
test("it supports placeholder text", function() {
var placeholder = "unit testing rocks";
!
component.set('placeholder', placeholder);
!
this.append();
!
equal($('.select2-chosen').text(), placeholder,
"has placeholder text");
});
Testing Components IV
test("it sets value to selected object", function() {
expect(2);
this.append();
component.set('content', simpleContent);
!
// open options by clicking on the element
click('.select2-choice');
// then select an option
click('.select2-results li:nth-child(3)', 'body');
!
andThen(function() {
equal(component.get(‘value’),
simpleContent[2], "selects correct item");
equal($(‘.select2-chosen').text(),
simpleContent[2].text, "has correct text");
});
});
Testing Components V
test("it wraps the content in <pre><code>", function() {
expect(2);
// create wrapper view with template
var component = Ember.View.extend({
template: Ember.Handlebars
.compile('{{#highlight-code}}hello!{{/highlight-code}}')
}).create();
!
Ember.run(function() {
component.appendTo('#ember-testing');
});
!
ok(component.$("pre").length, "pre exists");
!
ok(component.$("pre > code").length, "pre > code exists");
});
Resources
• Ember Testing Guide http://emberjs.com/guides/testing/
• Ember-Cli Guide http://iamstef.net/ember-cli/
• Ember.js/Ember-Data tests
Thanks!

Contenu connexe

Tendances

Angular Unit Testing NDC Minn 2018
Angular Unit Testing NDC Minn 2018Angular Unit Testing NDC Minn 2018
Angular Unit Testing NDC Minn 2018Justin James
 
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
 
Intro to Unit Testing in AngularJS
Intro to Unit Testing in AngularJSIntro to Unit Testing in AngularJS
Intro to Unit Testing in AngularJSJim Lynch
 
Unit Testing JavaScript Applications
Unit Testing JavaScript ApplicationsUnit Testing JavaScript Applications
Unit Testing JavaScript ApplicationsYnon Perek
 
Angular Unit Testing from the Trenches
Angular Unit Testing from the TrenchesAngular Unit Testing from the Trenches
Angular Unit Testing from the TrenchesJustin 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
 
Unit Testing and Coverage for AngularJS
Unit Testing and Coverage for AngularJSUnit Testing and Coverage for AngularJS
Unit Testing and Coverage for AngularJSKnoldus Inc.
 
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 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
 
Testing in-python-and-pytest-framework
Testing in-python-and-pytest-frameworkTesting in-python-and-pytest-framework
Testing in-python-and-pytest-frameworkArulalan T
 
Angular Application Testing
Angular Application TestingAngular Application Testing
Angular Application TestingTroy Miles
 
Unit Testing from Setup to Deployment
Unit Testing from Setup to DeploymentUnit Testing from Setup to Deployment
Unit Testing from Setup to DeploymentMark Niebergall
 
Effective testing with pytest
Effective testing with pytestEffective testing with pytest
Effective testing with pytestHector Canto
 
You do not need automation engineer - Sqa Days - 2015 - EN
You do not need automation engineer  - Sqa Days - 2015 - ENYou do not need automation engineer  - Sqa Days - 2015 - EN
You do not need automation engineer - Sqa Days - 2015 - ENIakiv Kramarenko
 
Testing React Applications
Testing React ApplicationsTesting React Applications
Testing React Applicationsstbaechler
 
Testing akka-actors
Testing akka-actorsTesting akka-actors
Testing akka-actorsKnoldus Inc.
 
Intro to testing Javascript with jasmine
Intro to testing Javascript with jasmineIntro to testing Javascript with jasmine
Intro to testing Javascript with jasmineTimothy Oxley
 
Writing Custom Puppet Types and Providers to Manage Web-Based Applications
Writing Custom Puppet Types and Providers to Manage Web-Based ApplicationsWriting Custom Puppet Types and Providers to Manage Web-Based Applications
Writing Custom Puppet Types and Providers to Manage Web-Based ApplicationsTim Cinel
 
Py.test
Py.testPy.test
Py.testsoasme
 

Tendances (20)

Angular Unit Testing NDC Minn 2018
Angular Unit Testing NDC Minn 2018Angular Unit Testing NDC Minn 2018
Angular Unit Testing NDC Minn 2018
 
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
 
Intro to Unit Testing in AngularJS
Intro to Unit Testing in AngularJSIntro to Unit Testing in AngularJS
Intro to Unit Testing in AngularJS
 
Unit Testing JavaScript Applications
Unit Testing JavaScript ApplicationsUnit Testing JavaScript Applications
Unit Testing JavaScript Applications
 
Angular Unit Testing from the Trenches
Angular Unit Testing from the TrenchesAngular Unit Testing from the Trenches
Angular Unit Testing from the Trenches
 
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
 
Unit Testing and Coverage for AngularJS
Unit Testing and Coverage for AngularJSUnit Testing and Coverage for AngularJS
Unit Testing and Coverage for AngularJS
 
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 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
 
Testing in-python-and-pytest-framework
Testing in-python-and-pytest-frameworkTesting in-python-and-pytest-framework
Testing in-python-and-pytest-framework
 
Angular Application Testing
Angular Application TestingAngular Application Testing
Angular Application Testing
 
Unit Testing from Setup to Deployment
Unit Testing from Setup to DeploymentUnit Testing from Setup to Deployment
Unit Testing from Setup to Deployment
 
Effective testing with pytest
Effective testing with pytestEffective testing with pytest
Effective testing with pytest
 
You do not need automation engineer - Sqa Days - 2015 - EN
You do not need automation engineer  - Sqa Days - 2015 - ENYou do not need automation engineer  - Sqa Days - 2015 - EN
You do not need automation engineer - Sqa Days - 2015 - EN
 
Karma - JS Test Runner
Karma - JS Test RunnerKarma - JS Test Runner
Karma - JS Test Runner
 
Testing React Applications
Testing React ApplicationsTesting React Applications
Testing React Applications
 
Testing akka-actors
Testing akka-actorsTesting akka-actors
Testing akka-actors
 
Intro to testing Javascript with jasmine
Intro to testing Javascript with jasmineIntro to testing Javascript with jasmine
Intro to testing Javascript with jasmine
 
Writing Custom Puppet Types and Providers to Manage Web-Based Applications
Writing Custom Puppet Types and Providers to Manage Web-Based ApplicationsWriting Custom Puppet Types and Providers to Manage Web-Based Applications
Writing Custom Puppet Types and Providers to Manage Web-Based Applications
 
Py.test
Py.testPy.test
Py.test
 

Similaire à (Unit) Testing in Emberjs – Munich Ember.js Meetup July 2014

Ember testing internals with ember cli
Ember testing internals with ember cliEmber testing internals with ember cli
Ember testing internals with ember cliCory Forsyth
 
Developer testing 101: Become a Testing Fanatic
Developer testing 101: Become a Testing FanaticDeveloper testing 101: Become a Testing Fanatic
Developer testing 101: Become a Testing FanaticLB Denker
 
Test Driven Development with JavaFX
Test Driven Development with JavaFXTest Driven Development with JavaFX
Test Driven Development with JavaFXHendrik Ebbers
 
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
 
Renaissance of JUnit - Introduction to JUnit 5
Renaissance of JUnit - Introduction to JUnit 5Renaissance of JUnit - Introduction to JUnit 5
Renaissance of JUnit - Introduction to JUnit 5Jimmy Lu
 
Principles and patterns for test driven development
Principles and patterns for test driven developmentPrinciples and patterns for test driven development
Principles and patterns for test driven developmentStephen Fuqua
 
Stop coding start testing
Stop coding start testingStop coding start testing
Stop coding start testingPascal Dufour
 
An Introduction to Unit Test Using NUnit
An Introduction to Unit Test Using NUnitAn Introduction to Unit Test Using NUnit
An Introduction to Unit Test Using NUnitweili_at_slideshare
 
Automated Developer Testing: Achievements and Challenges
Automated Developer Testing: Achievements and ChallengesAutomated Developer Testing: Achievements and Challenges
Automated Developer Testing: Achievements and ChallengesTao Xie
 
Getting Started with Test-Driven Development at Longhorn PHP 2023
Getting Started with Test-Driven Development at Longhorn PHP 2023Getting Started with Test-Driven Development at Longhorn PHP 2023
Getting Started with Test-Driven Development at Longhorn PHP 2023Scott Keck-Warren
 
Property Based Testing in PHP
Property Based Testing in PHPProperty Based Testing in PHP
Property Based Testing in PHPvinaikopp
 
Leveling Up With Unit Testing - php[tek] 2023
Leveling Up With Unit Testing - php[tek] 2023Leveling Up With Unit Testing - php[tek] 2023
Leveling Up With Unit Testing - php[tek] 2023Mark Niebergall
 
UI Testing with Spec
 UI Testing with Spec UI Testing with Spec
UI Testing with SpecPharo
 
Automating Django Functional Tests Using Selenium on Cloud
Automating Django Functional Tests Using Selenium on CloudAutomating Django Functional Tests Using Selenium on Cloud
Automating Django Functional Tests Using Selenium on CloudJonghyun Park
 
QTP 10.0_Kalyan Chakravarthy.ppt
QTP 10.0_Kalyan Chakravarthy.pptQTP 10.0_Kalyan Chakravarthy.ppt
QTP 10.0_Kalyan Chakravarthy.pptKalyan Chakravarthy
 
Qt test framework
Qt test frameworkQt test framework
Qt test frameworkICS
 
Testing for Pragmatic People
Testing for Pragmatic PeopleTesting for Pragmatic People
Testing for Pragmatic Peopledavismr
 
KrishnaToolComparisionPPT.pdf
KrishnaToolComparisionPPT.pdfKrishnaToolComparisionPPT.pdf
KrishnaToolComparisionPPT.pdfQA or the Highway
 

Similaire à (Unit) Testing in Emberjs – Munich Ember.js Meetup July 2014 (20)

Ember testing internals with ember cli
Ember testing internals with ember cliEmber testing internals with ember cli
Ember testing internals with ember cli
 
Developer testing 101: Become a Testing Fanatic
Developer testing 101: Become a Testing FanaticDeveloper testing 101: Become a Testing Fanatic
Developer testing 101: Become a Testing Fanatic
 
Test Driven Development with JavaFX
Test Driven Development with JavaFXTest Driven Development with JavaFX
Test Driven Development with JavaFX
 
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)
 
Testing Angular
Testing AngularTesting Angular
Testing Angular
 
Renaissance of JUnit - Introduction to JUnit 5
Renaissance of JUnit - Introduction to JUnit 5Renaissance of JUnit - Introduction to JUnit 5
Renaissance of JUnit - Introduction to JUnit 5
 
Principles and patterns for test driven development
Principles and patterns for test driven developmentPrinciples and patterns for test driven development
Principles and patterns for test driven development
 
Stop coding start testing
Stop coding start testingStop coding start testing
Stop coding start testing
 
An Introduction to Unit Test Using NUnit
An Introduction to Unit Test Using NUnitAn Introduction to Unit Test Using NUnit
An Introduction to Unit Test Using NUnit
 
Automated Developer Testing: Achievements and Challenges
Automated Developer Testing: Achievements and ChallengesAutomated Developer Testing: Achievements and Challenges
Automated Developer Testing: Achievements and Challenges
 
Getting Started with Test-Driven Development at Longhorn PHP 2023
Getting Started with Test-Driven Development at Longhorn PHP 2023Getting Started with Test-Driven Development at Longhorn PHP 2023
Getting Started with Test-Driven Development at Longhorn PHP 2023
 
Property Based Testing in PHP
Property Based Testing in PHPProperty Based Testing in PHP
Property Based Testing in PHP
 
Leveling Up With Unit Testing - php[tek] 2023
Leveling Up With Unit Testing - php[tek] 2023Leveling Up With Unit Testing - php[tek] 2023
Leveling Up With Unit Testing - php[tek] 2023
 
UI Testing with Spec
 UI Testing with Spec UI Testing with Spec
UI Testing with Spec
 
Automating Django Functional Tests Using Selenium on Cloud
Automating Django Functional Tests Using Selenium on CloudAutomating Django Functional Tests Using Selenium on Cloud
Automating Django Functional Tests Using Selenium on Cloud
 
QTP 10.0_Kalyan Chakravarthy.ppt
QTP 10.0_Kalyan Chakravarthy.pptQTP 10.0_Kalyan Chakravarthy.ppt
QTP 10.0_Kalyan Chakravarthy.ppt
 
Qt test framework
Qt test frameworkQt test framework
Qt test framework
 
Testing for Pragmatic People
Testing for Pragmatic PeopleTesting for Pragmatic People
Testing for Pragmatic People
 
Easy mock
Easy mockEasy mock
Easy mock
 
KrishnaToolComparisionPPT.pdf
KrishnaToolComparisionPPT.pdfKrishnaToolComparisionPPT.pdf
KrishnaToolComparisionPPT.pdf
 

Dernier

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
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate AgentsRyan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate AgentsRyan Mahoney
 
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
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Visualising and forecasting stocks using Dash
Visualising and forecasting stocks using DashVisualising and forecasting stocks using Dash
Visualising and forecasting stocks using Dashnarutouzumaki53779
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 

Dernier (20)

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
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate AgentsRyan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
 
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!
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Visualising and forecasting stocks using Dash
Visualising and forecasting stocks using DashVisualising and forecasting stocks using Dash
Visualising and forecasting stocks using Dash
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 

(Unit) Testing in Emberjs – Munich Ember.js Meetup July 2014

  • 2.
  • 4. About Testing • Make sure that stuff works…
  • 5. About Testing • Make sure that stuff works… • …even after code changes or refactoring
  • 6. About Testing • Make sure that stuff works… • …even after code changes or refactoring • Automation is key
  • 8. About Testing • Unit Testing • Verify, that isolated chunks of functionality work • Don't worry about their dependencies
  • 9. About Testing • Unit Testing • Verify, that isolated chunks of functionality work • Don't worry about their dependencies • Integration Testing • Test user interaction and application flow
  • 11. About Testing • Tools • QUnit testing framework • (async) helpers in ember-testing • Test Runner (testem) • Test Loader (ember-cli)
  • 14. Helpers in Ember-QUnit • moduleFor(name, description, callbacks); • Subject: controller:application, route:index etc.
  • 15. Helpers in Ember-QUnit • moduleFor(name, description, callbacks); • Subject: controller:application, route:index etc. • moduleForComponent(name, description, callbacks); • Subject: x-foo, select-2 etc.
  • 16. Helpers in Ember-QUnit • moduleFor(name, description, callbacks); • Subject: controller:application, route:index etc. • moduleForComponent(name, description, callbacks); • Subject: x-foo, select-2 etc. • moduleForModel(name, description, callbacks); • Subject: user, table etc.
  • 17. Helpers in Ember-QUnit • moduleFor(name, description, callbacks); • Subject: controller:application, route:index etc. • moduleForComponent(name, description, callbacks); • Subject: x-foo, select-2 etc. • moduleForModel(name, description, callbacks); • Subject: user, table etc. • test(name, callback);
  • 19. Helpers in Ember-Testing I • Async • visit(url) • fillIn(selector, text) • click(selector) • keyEvent(selector, type, keyCode)
  • 20. Helpers in Ember-Testing I • Async • visit(url) • fillIn(selector, text) • click(selector) • keyEvent(selector, type, keyCode) • Sync • find(selector, context) • currentPath() • currentURL()
  • 22. Helpers in Ember-Testing II • Wait • andThen(callback)
  • 23. Helpers in Ember-Testing II • Wait • andThen(callback) • Custom Helpers • Ember.Test.registerHelper • Ember.Test.registerAsyncHelper
  • 24. Testing Components I var App, component; ! moduleForComponent('select-2', 'Select2Component', { setup: function() { App = startApp(); // create instance of our component component = this.subject(); }, teardown: function() { Ember.run(App, 'destroy'); Ember.run(component, 'destroy'); } });
  • 25. Testing Components II test("it renders", function() { expect(2); ! equal(component.state, 'preRender'); ! // appends the component to the page this.append(); ! equal(component.state, 'inDOM'); });
  • 26. Testing Components III test("it supports placeholder text", function() { var placeholder = "unit testing rocks"; ! component.set('placeholder', placeholder); ! this.append(); ! equal($('.select2-chosen').text(), placeholder, "has placeholder text"); });
  • 27. Testing Components IV test("it sets value to selected object", function() { expect(2); this.append(); component.set('content', simpleContent); ! // open options by clicking on the element click('.select2-choice'); // then select an option click('.select2-results li:nth-child(3)', 'body'); ! andThen(function() { equal(component.get(‘value’), simpleContent[2], "selects correct item"); equal($(‘.select2-chosen').text(), simpleContent[2].text, "has correct text"); }); });
  • 28. Testing Components V test("it wraps the content in <pre><code>", function() { expect(2); // create wrapper view with template var component = Ember.View.extend({ template: Ember.Handlebars .compile('{{#highlight-code}}hello!{{/highlight-code}}') }).create(); ! Ember.run(function() { component.appendTo('#ember-testing'); }); ! ok(component.$("pre").length, "pre exists"); ! ok(component.$("pre > code").length, "pre > code exists"); });
  • 29. Resources • Ember Testing Guide http://emberjs.com/guides/testing/ • Ember-Cli Guide http://iamstef.net/ember-cli/ • Ember.js/Ember-Data tests