SlideShare uma empresa Scribd logo
1 de 22
Baixar para ler offline
Using Zone.js
@opichals
HPE Service Virtualization
hpsv.cz
What is this about
2
– zones
– zone.js
– examples
– hands on
– practical use
Heard of zones?
3
anyone?
Used zones?
4
somebody...
What is a zone
5
Execution context
Something like a Thread-local storage like feature in JavaScript
History
6
– In the web world they came from the Dart language
– zone.js is a port of the Dart approach to JavaScript
– Used in Angular 2
Example
zone.fork().run(function () {
zone.inTheZone = true;
setTimeout(function () {
console.log('in the zone: ' + !!zone.inTheZone);
}, 0);
});
console.log('in the zone: ' + !!zone.inTheZone);
7
zone.fork().run(function () {
stacks.push(getStack())
setTimeout(function () {
stacks.push(getStack())
stacks.forEach(console.log)
}, 0);
});
Long Stack Trace Zone Example
8
Hands on
9
Hands on - Recap
10
Frontend Integration and End to End Testing
– Long Stack Trace Zone
– WTF Zone
– Timing Zone
How does it work
11
It wraps every async browser API with a zone.wrap
setTimeout, setInterval, XHR, Promise, MutationObserver
Real World Use
12
Frontend Integration and End to End Testing
– React application
– Protractor
– Tracks ng-1.x digest
– Real browsers
– Selenium
Protractor Test
13
describe('Lab', function() {
it('Should be able to start/stop lab', function() {
const lab = $('*[data-component="Lab"]');
const runButton = lab.element(by.css('*[data-button="Play"]'));
intoView( runButton).click();
// async actions happening in the browser (XHRs, CSS transitions, etc.)
expect(lab.element(by.cssContainingText('*', 'Started')). isPresent()).toBeTruthy();
const stopButton = lab.element(by.css('*[data-button="Stop"]'));
intoView( stopButton).click();
// async actions happening in the browser (XHRs, CSS transitions, etc.)
expect(lab.element(by.cssContainingText('*', 'Stopped')). isPresent()).toBeTruthy();
});
});
React - Protractor Integration
14
React - Protractor Integration
15
// Angular provides Protractor with a very minimal API which it uses before
// any webdriver wrapped call
window.angular = {
// hook for `github.com/angular/protractor/lib/clientsidescripts.js: waitForAngular`
getTestability: function() {
return {
whenStable: function(fn) {
// call fn() when digest is stable
}
}
},
// dummy Protractor required stuff
module: function() {
var module = { config: function() { return module; } };
return module;
},
resumeBootstrap : function() {}
}
angular.getTestability().whenStable(fn)
16
Straightforward with zone.js
Invoke the whenStable fn() callback when all the zone tasks are finished
Protractor Test Flow
17
describe('Lab', function() {
it('Should be able to start/stop lab', function() {
const lab = $('*[data-component="Lab"]');
const runButton = lab.element(by.css('*[data-button="Play"]'));
intoView( runButton).click(); // Promise
// Protractor calls whenStable() in the from within the next isPresent() call
expect(lab.element(by.cssContainingText('*', 'Started')). isPresent()).toBeTruthy();
const stopButton = lab.element(by.css('*[data-button="Stop"]'));
intoView( stopButton).click(); // Promise
// Protractor calls whenStable() in the from within the next isPresent() call
expect(lab.element(by.cssContainingText('*', 'Stopped')). isPresent()).toBeTruthy();
});
});
Protractor Testing Demo
18
Protractor Testing Demo - Recap
19
– React Application
– CSS Transitions
– Protractor
More Information
20
zone.js README
– Brian Ford’s presentation @ng-conf 2014
Angular 2 NgZone
Dart Zones
Questions
21
Thank you!
HPE Service Virtualization virtual reality for distributed apps
22
Want to join a an agile frontend team?
Key technologies
– ES6+ / TypeScript / Java
– React
– Redux
– Redux-sagas
– Protractor
Have a look at hpsv.cz
Send CVs via email to stop@hpe.com or contact me @opichals

Mais conteúdo relacionado

Mais procurados

Concurrency in Golang
Concurrency in GolangConcurrency in Golang
Concurrency in GolangOliver N
 
Deep Dive async/await in Unity with UniTask(EN)
Deep Dive async/await in Unity with UniTask(EN)Deep Dive async/await in Unity with UniTask(EN)
Deep Dive async/await in Unity with UniTask(EN)Yoshifumi Kawai
 
OTcl and C++ linkages in NS2
OTcl and C++ linkages in NS2OTcl and C++ linkages in NS2
OTcl and C++ linkages in NS2Pradeep Kumar TS
 
Go concurrency
Go concurrencyGo concurrency
Go concurrencysiuyin
 
libuv, NodeJS and everything in between
libuv, NodeJS and everything in betweenlibuv, NodeJS and everything in between
libuv, NodeJS and everything in betweenSaúl Ibarra Corretgé
 
Functional Reactive Programming with RxJS
Functional Reactive Programming with RxJSFunctional Reactive Programming with RxJS
Functional Reactive Programming with RxJSstefanmayer13
 
Global Interpreter Lock: Episode III - cat < /dev/zero > GIL;
Global Interpreter Lock: Episode III - cat < /dev/zero > GIL;Global Interpreter Lock: Episode III - cat < /dev/zero > GIL;
Global Interpreter Lock: Episode III - cat < /dev/zero > GIL;Tzung-Bi Shih
 
function* - ES6, generators, and all that (JSRomandie meetup, February 2014)
function* - ES6, generators, and all that (JSRomandie meetup, February 2014)function* - ES6, generators, and all that (JSRomandie meetup, February 2014)
function* - ES6, generators, and all that (JSRomandie meetup, February 2014)Igalia
 
Demystifying the Go Scheduler
Demystifying the Go SchedulerDemystifying the Go Scheduler
Demystifying the Go Schedulermatthewrdale
 
Comparison nodejs frameworks using Polls API
Comparison nodejs frameworks using Polls APIComparison nodejs frameworks using Polls API
Comparison nodejs frameworks using Polls APILadislav Prskavec
 

Mais procurados (20)

Go on!
Go on!Go on!
Go on!
 
OpenMP
OpenMPOpenMP
OpenMP
 
Event loop
Event loopEvent loop
Event loop
 
ECMA Script
ECMA ScriptECMA Script
ECMA Script
 
Concurrency in Golang
Concurrency in GolangConcurrency in Golang
Concurrency in Golang
 
Deep Dive async/await in Unity with UniTask(EN)
Deep Dive async/await in Unity with UniTask(EN)Deep Dive async/await in Unity with UniTask(EN)
Deep Dive async/await in Unity with UniTask(EN)
 
OTcl and C++ linkages in NS2
OTcl and C++ linkages in NS2OTcl and C++ linkages in NS2
OTcl and C++ linkages in NS2
 
Go concurrency
Go concurrencyGo concurrency
Go concurrency
 
libuv, NodeJS and everything in between
libuv, NodeJS and everything in betweenlibuv, NodeJS and everything in between
libuv, NodeJS and everything in between
 
Sorter
SorterSorter
Sorter
 
Functional Reactive Programming with RxJS
Functional Reactive Programming with RxJSFunctional Reactive Programming with RxJS
Functional Reactive Programming with RxJS
 
Stack switching for fun and profit
Stack switching for fun and profitStack switching for fun and profit
Stack switching for fun and profit
 
ocelot
ocelotocelot
ocelot
 
Global Interpreter Lock: Episode III - cat < /dev/zero > GIL;
Global Interpreter Lock: Episode III - cat < /dev/zero > GIL;Global Interpreter Lock: Episode III - cat < /dev/zero > GIL;
Global Interpreter Lock: Episode III - cat < /dev/zero > GIL;
 
Coroutines in Kotlin
Coroutines in KotlinCoroutines in Kotlin
Coroutines in Kotlin
 
Full Stack Clojure
Full Stack ClojureFull Stack Clojure
Full Stack Clojure
 
AMC Minor Technical Issues
AMC Minor Technical IssuesAMC Minor Technical Issues
AMC Minor Technical Issues
 
function* - ES6, generators, and all that (JSRomandie meetup, February 2014)
function* - ES6, generators, and all that (JSRomandie meetup, February 2014)function* - ES6, generators, and all that (JSRomandie meetup, February 2014)
function* - ES6, generators, and all that (JSRomandie meetup, February 2014)
 
Demystifying the Go Scheduler
Demystifying the Go SchedulerDemystifying the Go Scheduler
Demystifying the Go Scheduler
 
Comparison nodejs frameworks using Polls API
Comparison nodejs frameworks using Polls APIComparison nodejs frameworks using Polls API
Comparison nodejs frameworks using Polls API
 

Destaque

Destaque (7)

Slides -the_bridges_transition_model
Slides  -the_bridges_transition_modelSlides  -the_bridges_transition_model
Slides -the_bridges_transition_model
 
ITZ in Recycled Aggregate Concrete presentation
ITZ in Recycled Aggregate Concrete  presentationITZ in Recycled Aggregate Concrete  presentation
ITZ in Recycled Aggregate Concrete presentation
 
AzovDevMeetup 2016 | Angular 2: обзор | Александр Шевнин
AzovDevMeetup 2016 | Angular 2: обзор | Александр ШевнинAzovDevMeetup 2016 | Angular 2: обзор | Александр Шевнин
AzovDevMeetup 2016 | Angular 2: обзор | Александр Шевнин
 
Zones power point
Zones power pointZones power point
Zones power point
 
Concrete cloth - its uses and applications
Concrete cloth - its uses and applicationsConcrete cloth - its uses and applications
Concrete cloth - its uses and applications
 
Node Foundation Membership Overview 20160907
Node Foundation Membership Overview 20160907Node Foundation Membership Overview 20160907
Node Foundation Membership Overview 20160907
 
Zinnov Zones for IoT Services 2017
Zinnov Zones for IoT Services 2017Zinnov Zones for IoT Services 2017
Zinnov Zones for IoT Services 2017
 

Semelhante a Using zone.js

ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015Michiel Borkent
 
JavaScript Multithread or Single Thread.pptx
JavaScript Multithread or Single Thread.pptxJavaScript Multithread or Single Thread.pptx
JavaScript Multithread or Single Thread.pptxRAHITNATH
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing UpDavid Padbury
 
Server side JavaScript: going all the way
Server side JavaScript: going all the wayServer side JavaScript: going all the way
Server side JavaScript: going all the wayOleg Podsechin
 
Zone.js 2017
Zone.js 2017Zone.js 2017
Zone.js 2017Jia Li
 
用 Go 語言打造多台機器 Scale 架構
用 Go 語言打造多台機器 Scale 架構用 Go 語言打造多台機器 Scale 架構
用 Go 語言打造多台機器 Scale 架構Bo-Yi Wu
 
Java util concurrent
Java util concurrentJava util concurrent
Java util concurrentRoger Xia
 
Asynchronous programming done right - Node.js
Asynchronous programming done right - Node.jsAsynchronous programming done right - Node.js
Asynchronous programming done right - Node.jsPiotr Pelczar
 
golang_getting_started.pptx
golang_getting_started.pptxgolang_getting_started.pptx
golang_getting_started.pptxGuy Komari
 
Job Queue in Golang
Job Queue in GolangJob Queue in Golang
Job Queue in GolangBo-Yi Wu
 
Aplicações assíncronas no Android com
Coroutines & Jetpack
Aplicações assíncronas no Android com
Coroutines & JetpackAplicações assíncronas no Android com
Coroutines & Jetpack
Aplicações assíncronas no Android com
Coroutines & JetpackNelson Glauber Leal
 
Aplicações assíncronas no Android com
Coroutines & Jetpack
Aplicações assíncronas no Android com
Coroutines & JetpackAplicações assíncronas no Android com
Coroutines & Jetpack
Aplicações assíncronas no Android com
Coroutines & JetpackNelson Glauber Leal
 
Go and Uber’s time series database m3
Go and Uber’s time series database m3Go and Uber’s time series database m3
Go and Uber’s time series database m3Rob Skillington
 
.NET Multithreading/Multitasking
.NET Multithreading/Multitasking.NET Multithreading/Multitasking
.NET Multithreading/MultitaskingSasha Kravchuk
 
NDC Sydney 2019 - Async Demystified -- Karel Zikmund
NDC Sydney 2019 - Async Demystified -- Karel ZikmundNDC Sydney 2019 - Async Demystified -- Karel Zikmund
NDC Sydney 2019 - Async Demystified -- Karel ZikmundKarel Zikmund
 
Think Async: Asynchronous Patterns in NodeJS
Think Async: Asynchronous Patterns in NodeJSThink Async: Asynchronous Patterns in NodeJS
Think Async: Asynchronous Patterns in NodeJSAdam L Barrett
 
Jdk 7 4-forkjoin
Jdk 7 4-forkjoinJdk 7 4-forkjoin
Jdk 7 4-forkjoinknight1128
 

Semelhante a Using zone.js (20)

ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015
 
JavaScript Multithread or Single Thread.pptx
JavaScript Multithread or Single Thread.pptxJavaScript Multithread or Single Thread.pptx
JavaScript Multithread or Single Thread.pptx
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
 
Server side JavaScript: going all the way
Server side JavaScript: going all the wayServer side JavaScript: going all the way
Server side JavaScript: going all the way
 
Zone.js 2017
Zone.js 2017Zone.js 2017
Zone.js 2017
 
用 Go 語言打造多台機器 Scale 架構
用 Go 語言打造多台機器 Scale 架構用 Go 語言打造多台機器 Scale 架構
用 Go 語言打造多台機器 Scale 架構
 
Java util concurrent
Java util concurrentJava util concurrent
Java util concurrent
 
Asynchronous programming done right - Node.js
Asynchronous programming done right - Node.jsAsynchronous programming done right - Node.js
Asynchronous programming done right - Node.js
 
JS everywhere 2011
JS everywhere 2011JS everywhere 2011
JS everywhere 2011
 
golang_getting_started.pptx
golang_getting_started.pptxgolang_getting_started.pptx
golang_getting_started.pptx
 
Job Queue in Golang
Job Queue in GolangJob Queue in Golang
Job Queue in Golang
 
Aplicações assíncronas no Android com
Coroutines & Jetpack
Aplicações assíncronas no Android com
Coroutines & JetpackAplicações assíncronas no Android com
Coroutines & Jetpack
Aplicações assíncronas no Android com
Coroutines & Jetpack
 
Node js lecture
Node js lectureNode js lecture
Node js lecture
 
Aplicações assíncronas no Android com
Coroutines & Jetpack
Aplicações assíncronas no Android com
Coroutines & JetpackAplicações assíncronas no Android com
Coroutines & Jetpack
Aplicações assíncronas no Android com
Coroutines & Jetpack
 
Go and Uber’s time series database m3
Go and Uber’s time series database m3Go and Uber’s time series database m3
Go and Uber’s time series database m3
 
.NET Multithreading/Multitasking
.NET Multithreading/Multitasking.NET Multithreading/Multitasking
.NET Multithreading/Multitasking
 
NDC Sydney 2019 - Async Demystified -- Karel Zikmund
NDC Sydney 2019 - Async Demystified -- Karel ZikmundNDC Sydney 2019 - Async Demystified -- Karel Zikmund
NDC Sydney 2019 - Async Demystified -- Karel Zikmund
 
oojs
oojsoojs
oojs
 
Think Async: Asynchronous Patterns in NodeJS
Think Async: Asynchronous Patterns in NodeJSThink Async: Asynchronous Patterns in NodeJS
Think Async: Asynchronous Patterns in NodeJS
 
Jdk 7 4-forkjoin
Jdk 7 4-forkjoinJdk 7 4-forkjoin
Jdk 7 4-forkjoin
 

Último

Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
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
 
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
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
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
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
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.
 
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
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
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
 
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
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 

Último (20)

Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
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 ☂️
 
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
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.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...
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
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...
 
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
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
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
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
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
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 

Using zone.js

  • 1. Using Zone.js @opichals HPE Service Virtualization hpsv.cz
  • 2. What is this about 2 – zones – zone.js – examples – hands on – practical use
  • 5. What is a zone 5 Execution context Something like a Thread-local storage like feature in JavaScript
  • 6. History 6 – In the web world they came from the Dart language – zone.js is a port of the Dart approach to JavaScript – Used in Angular 2
  • 7. Example zone.fork().run(function () { zone.inTheZone = true; setTimeout(function () { console.log('in the zone: ' + !!zone.inTheZone); }, 0); }); console.log('in the zone: ' + !!zone.inTheZone); 7
  • 8. zone.fork().run(function () { stacks.push(getStack()) setTimeout(function () { stacks.push(getStack()) stacks.forEach(console.log) }, 0); }); Long Stack Trace Zone Example 8
  • 10. Hands on - Recap 10 Frontend Integration and End to End Testing – Long Stack Trace Zone – WTF Zone – Timing Zone
  • 11. How does it work 11 It wraps every async browser API with a zone.wrap setTimeout, setInterval, XHR, Promise, MutationObserver
  • 12. Real World Use 12 Frontend Integration and End to End Testing – React application – Protractor – Tracks ng-1.x digest – Real browsers – Selenium
  • 13. Protractor Test 13 describe('Lab', function() { it('Should be able to start/stop lab', function() { const lab = $('*[data-component="Lab"]'); const runButton = lab.element(by.css('*[data-button="Play"]')); intoView( runButton).click(); // async actions happening in the browser (XHRs, CSS transitions, etc.) expect(lab.element(by.cssContainingText('*', 'Started')). isPresent()).toBeTruthy(); const stopButton = lab.element(by.css('*[data-button="Stop"]')); intoView( stopButton).click(); // async actions happening in the browser (XHRs, CSS transitions, etc.) expect(lab.element(by.cssContainingText('*', 'Stopped')). isPresent()).toBeTruthy(); }); });
  • 14. React - Protractor Integration 14
  • 15. React - Protractor Integration 15 // Angular provides Protractor with a very minimal API which it uses before // any webdriver wrapped call window.angular = { // hook for `github.com/angular/protractor/lib/clientsidescripts.js: waitForAngular` getTestability: function() { return { whenStable: function(fn) { // call fn() when digest is stable } } }, // dummy Protractor required stuff module: function() { var module = { config: function() { return module; } }; return module; }, resumeBootstrap : function() {} }
  • 16. angular.getTestability().whenStable(fn) 16 Straightforward with zone.js Invoke the whenStable fn() callback when all the zone tasks are finished
  • 17. Protractor Test Flow 17 describe('Lab', function() { it('Should be able to start/stop lab', function() { const lab = $('*[data-component="Lab"]'); const runButton = lab.element(by.css('*[data-button="Play"]')); intoView( runButton).click(); // Promise // Protractor calls whenStable() in the from within the next isPresent() call expect(lab.element(by.cssContainingText('*', 'Started')). isPresent()).toBeTruthy(); const stopButton = lab.element(by.css('*[data-button="Stop"]')); intoView( stopButton).click(); // Promise // Protractor calls whenStable() in the from within the next isPresent() call expect(lab.element(by.cssContainingText('*', 'Stopped')). isPresent()).toBeTruthy(); }); });
  • 19. Protractor Testing Demo - Recap 19 – React Application – CSS Transitions – Protractor
  • 20. More Information 20 zone.js README – Brian Ford’s presentation @ng-conf 2014 Angular 2 NgZone Dart Zones
  • 22. HPE Service Virtualization virtual reality for distributed apps 22 Want to join a an agile frontend team? Key technologies – ES6+ / TypeScript / Java – React – Redux – Redux-sagas – Protractor Have a look at hpsv.cz Send CVs via email to stop@hpe.com or contact me @opichals