SlideShare a Scribd company logo
1 of 41
Download to read offline
JavaScript
Understanding Asynchronism
Gennadii Mishchevskii, Ciklum, Ukraine
whoami
• Gennadii Mishchevskii
• Senior Automation QA Engineer at Ciklum
• 4 years in the industry
• Automated back-end, front-end and mobile
• https://www.linkedin.com/in/gennadiimishchevskii/
Agenda
• Async theory
• Callback
• Promises
• Async/Await
• Quiz
Warm-up
typeof null;
typeof NaN;
NaN instanceof Number;
typeof 'string';
'string' instanceof String;
'1' + +'1';
'1' - -'1';
null > 0;
null == 0;
null >= 0;
{} + [];
true + true - false > true ** 2;
let wtf = () => {
try {
return 24;
} finally {
return 42;
}
};
wtf();
object
number
false
false
string
‘11’
2
false
false
true
0
true
42
Async theory
Order
food
Pay
Clean
after
yourself
Async theory - PHP server, Single Sync thread
Async theory - PHP server, Single Sync thread
timeline
Order
food
Pay
Clean
after
yourself
Async theory - Multithreading Java server
Async theory - Multithreading Java server
timeline Main thread Thread 1 Thread 2 Thread 3
Order
food
Pay
Clean
after
yourself
Async theory - NodeJS Async server
Async theory - NodeJS Async server
timeline Single thread
Libuv
Order
food
Pay
Clean
after
yourself
// example1.js
Async theory - Stack and heap
// stack.js, stackTrace.js, maxCallStack.js
Async theory - Full picture
// fullPicture.js
Promises - 99.99% can't solve this task
func1().then(function () {
return func2();
});
func1().then(function () {
func2();
});
func1().then(func2());
func1().then(func2);
Promises - evolution
Async/Await
Promise
Callback
Callback – why don't we love callbacks
• Callback hell
• Catching errors
• Difficult to wait for several async actions to finish
// callbackLinux.js
Promises – the rescuer
• Callback hell
• Catching errors
• Difficult to wait for several async actions to finish
Promises – the rescuer (specs)
• A promise or “thenable” is an object
that supplies a standard-
compliant .then() method.
• A pending promise may transition
into a fulfilled or rejected state.
Promises – the rescuer (specs)
• A fulfilled or rejected promise is settled, and must not transition into
any other state.
• Once a promise is settled, it must have a value (which may
be undefined). That value must not change.
• Every promise must supply a .then() method with the following
signature:
promise.then(
onFulfilled?: Function,
onRejected?: Function
) => Promise
Promises – the rescuer (specs)
• Both onFulfilled() and onRejected() are optional.​
• If the arguments supplied are not functions, they must be ignored.​
• onFulfilled() will be called after the promise is fulfilled, with the promise’s
value as the first argument.​
• onRejected() will be called after the promise is rejected, with the reason for
rejection as the first argument. The reason may be any valid JavaScript value,
but because rejections are essentially synonymous with exceptions, I
recommend using Error objects.​
Promises – the rescuer (specs)
• .then() may be called many times on the same promise. ​
• .then() must return a new promise, promise2.​
• If either onFulfilled or onRejected throws an exception e, promise2 must be
rejected with e as the reason.​
• If onFulfilled is not a function and promise1 is fulfilled, promise2 must be
fulfilled with the same value as promise1.​
• If onRejected is not a function and promise1 is rejected, promise2 must be
rejected with the same reason as promise1.​
Promises – the rescuer (create and chain)
function myRandomPromise() {
return new Promise(function (resolve, reject) {
const random = Math.random();
random < 0.5
? resolve('Yay, it worked')
: reject('Oh no, something went wrong');
})
}
myPromise()
.then(console.log)
.catch(console.log);
myRandomPromise()
.then(result => console.log(result),
error => console.log(error));
myRandomPromise()
.then(console.log,
console.log);
myRandomPromise()
.catch(console.log);
myRandomPromise()
.then(null, console.log);
Promises – the rescuer (don't forget to catch)
Promise.resolve(42)
.then(doFirst)
.then(doSecond)
.catch(console.log)
.then(doThird)
.catch(err => {
console.log(err);
return err.message;
})
.then(doFourth)
.catch(console.log);
Promises – the rescuer
(what’s gonna happen?)
function myPromise() {
return new Promise(resolve => {
Object.notExistingFunction();
resolve('Resolved');
})
}
myPromise()
.then(console.log)
.catch(console.log);
setTimeout(_ => console.log('setTimeout'));
Promises – the rescuer
(how to ruin it)
function myRandomPromise(num) {
return new Promise(function (resolve) {
resolve(Math.random());
});
}myRandomPromise().then(num => {
return myRandomPromise().then(num => {
return myRandomPromise().then(num => {
return myRandomPromise().then(num => {
return myRandomPromise().then(num => {
return myRandomPromise().then(num => {
console.log(num);
});
});
});
});
});
});
myRandomPromise()
.then(num => {
return myRandomPromise()
})
.then(num => {
return myRandomPromise()
})
.then(num => {
console.log(num);
});
// callbackedPromise.js
Async/Await – the advanced rescuer
• Callback hell
• Catching errors
• Difficult to wait for several async actions to finish
// promiseLunix.js, promise0-1.js , asyncAwaitSimple.js, asyncAwaitFlow.js , asyncAwaitLinux.js, promise2+.js
Async theory - NodeJS Async server
Async theory - NodeJS Async server
timeline Single thread
Libuv
Order
food
Pay
Clean
after
yourself
// example2.js
Quiz – 1. What will be the result
let prоm = new Promise((resolve, reject) => {
resolve('Some message');
});
prоm
.then((result) => {
console.log(result);
}, (err) => {
console.log('Errоr оccurred');
});
1. Some message
2. Errоr оccurred
3. Nothing
4. Some message
Errоr оccurred
5. Errоr оccurred
Some message
Quiz – 2. What will be the result
let prоm = new Promise((resolve, reject) => {
reject('Some message');
});
prоm
.then((result) => {
console.log(result);
}, (err) => {
console.log('Errоr оccurred: ' + err);
});
1. Some message
2. Error occurred:
3. Error occurred: Some message
4. Some message
Error occurred:
5. Nothing
Quiz – 3. What will be the result
let prоm = new Promise((resolve, reject) => {
reject('Some message');
});
prоm
.then((result) => {
console.log(result);
})
.catch(err => {
console.log('Errоr оccurred: ' + err);
});
1. Some message
2. Error occurred: undefined
3. Error occurred: Some message
4. Some message
Error occurred:
5. Error will be thrown
Quiz – 4. What will be the result
let prоm = new Promise((resolve, reject) => {
resolve('Some message');
});
prоm
.then(result => {
throw new Error(result);
}, err => {
console.log('Error occurred: ' + err)
})
.catch((err) => {
console.log('Error occurred inside: ' + err)
});
1. Error occurred: Some message
2. Error occurred inside: Some message
3. Some message
4. Nothing
5. Error will be thrown
Quiz – 5. There's an element with locator
#myId. What will be the result
console.log(element(by.css('#myId')).isPresent() === true);
console.log(element(by.css('#myId')).isPresent() === false);
1. true
true
2. false
false
3. Error
4. true
false
5. false
true
Quiz – 6. There's an element with locator
#myId and text inside 'some text'. What will be the result
element(by.css('#myId'))
.getText()
.then(value => {
return element(by.css('#myId')).getText()
.then(value2 => {
console.log(value + ' ' + value2)
});
});
1. Error
2. some text some text
3. some text Promise
4. some text undefined
5. getText getText
6. Promise Promise
Quiz – 7. There's an element with locator
#myId and text inside 'some text'. After click on element
text changes to 'Clicked'. What will be the result
let elem = element(by.css('#myId'));
let txt = elem.getText();
txt
.then(txtBefore => {
return elem.click()
.then(_ => txt)
.then(txtAfter => {
console.log(txtBefore + ' ' + txtAfter);
});
});
1. some text some text
2. some text Clicked
3. some text undefined
4. Error
5. txtBefore txtAfter
Quiz – 8. There's an element with locator
#myId and text inside 'some text'. After click on element
text changes to 'Clicked'. What will be the result
let elem = element(by.css('#myId'));
elem
.getText()
.then(txtBefore => {
return elem.click()
.then(_ => elem.getText())
.then(txtAfter => {
console.log(txtBefore + ' ' + txtAfter);
});
});
1. some text some text
2. some text Clicked
3. some text undefined
4. Error
5. txtBefore txtAfter
Quiz – 9. There's an element with locator
#myId and text inside 'some text'. After click on element
text changes to 'Clicked'. What will be the result
let elem = element(by.css('#myId'));
void async function logValues() {
let txtBefore = await elem.getText();
await elem.click();
let txtAfter = await elem.getText();
console.log(txtBefore+ ' ' + txtAfter);
}();
1. some text some text
2. some text Clicked
3. txtBefore txtAfter
4. Promise Promise
Quiz – 10. There's an element with locator
#myId and text inside 'some text'. After click on element
text changes to 'Clicked'. What will be the result
let elem = element(by.css('#myId'));
void async function logValues() {
let txtBefore = elem.getText();
await elem.click();
let txtAfter = elem.getText();
console.log(txtBefore + ' ' + txtAfter);
}();
1. some text some text
2. some text Clicked
3. txtBefore txtAfter
4. Promise Promise
Repo
https://github.com/Gennadiii/testingStage18
Repo
https://goo.gl/2no6Zc
We’ve done it!

More Related Content

What's hot

Callbacks, promises, generators - asynchronous javascript
Callbacks, promises, generators - asynchronous javascriptCallbacks, promises, generators - asynchronous javascript
Callbacks, promises, generators - asynchronous javascriptŁukasz Kużyński
 
Asynchronous programming done right - Node.js
Asynchronous programming done right - Node.jsAsynchronous programming done right - Node.js
Asynchronous programming done right - Node.jsPiotr Pelczar
 
AngularJS Testing Strategies
AngularJS Testing StrategiesAngularJS Testing Strategies
AngularJS Testing Strategiesnjpst8
 
Integrating React.js with PHP projects
Integrating React.js with PHP projectsIntegrating React.js with PHP projects
Integrating React.js with PHP projectsIgnacio Martín
 
Advanced akka features
Advanced akka featuresAdvanced akka features
Advanced akka featuresGrzegorz Duda
 
Understanding Asynchronous JavaScript
Understanding Asynchronous JavaScriptUnderstanding Asynchronous JavaScript
Understanding Asynchronous JavaScriptjnewmanux
 
Intro to Cocoa KVC/KVO and Bindings
Intro to Cocoa KVC/KVO and BindingsIntro to Cocoa KVC/KVO and Bindings
Intro to Cocoa KVC/KVO and BindingsSergio Acosta
 
The Ring programming language version 1.6 book - Part 41 of 189
The Ring programming language version 1.6 book - Part 41 of 189The Ring programming language version 1.6 book - Part 41 of 189
The Ring programming language version 1.6 book - Part 41 of 189Mahmoud Samir Fayed
 
Promises - Asynchronous Control Flow
Promises - Asynchronous Control FlowPromises - Asynchronous Control Flow
Promises - Asynchronous Control FlowHenrique Barcelos
 
Avoiding Callback Hell with Async.js
Avoiding Callback Hell with Async.jsAvoiding Callback Hell with Async.js
Avoiding Callback Hell with Async.jscacois
 
Avoiding callback hell with promises
Avoiding callback hell with promisesAvoiding callback hell with promises
Avoiding callback hell with promisesTorontoNodeJS
 
The Ring programming language version 1.4 book - Part 11 of 30
The Ring programming language version 1.4 book - Part 11 of 30The Ring programming language version 1.4 book - Part 11 of 30
The Ring programming language version 1.4 book - Part 11 of 30Mahmoud Samir Fayed
 
A Lifecycle Of Code Under Test by Robert Fornal
A Lifecycle Of Code Under Test by Robert FornalA Lifecycle Of Code Under Test by Robert Fornal
A Lifecycle Of Code Under Test by Robert FornalQA or the Highway
 
Programming Sideways: Asynchronous Techniques for Android
Programming Sideways: Asynchronous Techniques for AndroidProgramming Sideways: Asynchronous Techniques for Android
Programming Sideways: Asynchronous Techniques for AndroidEmanuele Di Saverio
 
PostgreSQL Open SV 2018
PostgreSQL Open SV 2018PostgreSQL Open SV 2018
PostgreSQL Open SV 2018artgillespie
 
Redux Sagas - React Alicante
Redux Sagas - React AlicanteRedux Sagas - React Alicante
Redux Sagas - React AlicanteIgnacio Martín
 

What's hot (20)

JavaScript Promises
JavaScript PromisesJavaScript Promises
JavaScript Promises
 
Callbacks, promises, generators - asynchronous javascript
Callbacks, promises, generators - asynchronous javascriptCallbacks, promises, generators - asynchronous javascript
Callbacks, promises, generators - asynchronous javascript
 
Akka in-action
Akka in-actionAkka in-action
Akka in-action
 
Asynchronous programming done right - Node.js
Asynchronous programming done right - Node.jsAsynchronous programming done right - Node.js
Asynchronous programming done right - Node.js
 
Akka tips
Akka tipsAkka tips
Akka tips
 
AngularJS Testing Strategies
AngularJS Testing StrategiesAngularJS Testing Strategies
AngularJS Testing Strategies
 
Integrating React.js with PHP projects
Integrating React.js with PHP projectsIntegrating React.js with PHP projects
Integrating React.js with PHP projects
 
Advanced akka features
Advanced akka featuresAdvanced akka features
Advanced akka features
 
JavaScript Promise
JavaScript PromiseJavaScript Promise
JavaScript Promise
 
Understanding Asynchronous JavaScript
Understanding Asynchronous JavaScriptUnderstanding Asynchronous JavaScript
Understanding Asynchronous JavaScript
 
Intro to Cocoa KVC/KVO and Bindings
Intro to Cocoa KVC/KVO and BindingsIntro to Cocoa KVC/KVO and Bindings
Intro to Cocoa KVC/KVO and Bindings
 
The Ring programming language version 1.6 book - Part 41 of 189
The Ring programming language version 1.6 book - Part 41 of 189The Ring programming language version 1.6 book - Part 41 of 189
The Ring programming language version 1.6 book - Part 41 of 189
 
Promises - Asynchronous Control Flow
Promises - Asynchronous Control FlowPromises - Asynchronous Control Flow
Promises - Asynchronous Control Flow
 
Avoiding Callback Hell with Async.js
Avoiding Callback Hell with Async.jsAvoiding Callback Hell with Async.js
Avoiding Callback Hell with Async.js
 
Avoiding callback hell with promises
Avoiding callback hell with promisesAvoiding callback hell with promises
Avoiding callback hell with promises
 
The Ring programming language version 1.4 book - Part 11 of 30
The Ring programming language version 1.4 book - Part 11 of 30The Ring programming language version 1.4 book - Part 11 of 30
The Ring programming language version 1.4 book - Part 11 of 30
 
A Lifecycle Of Code Under Test by Robert Fornal
A Lifecycle Of Code Under Test by Robert FornalA Lifecycle Of Code Under Test by Robert Fornal
A Lifecycle Of Code Under Test by Robert Fornal
 
Programming Sideways: Asynchronous Techniques for Android
Programming Sideways: Asynchronous Techniques for AndroidProgramming Sideways: Asynchronous Techniques for Android
Programming Sideways: Asynchronous Techniques for Android
 
PostgreSQL Open SV 2018
PostgreSQL Open SV 2018PostgreSQL Open SV 2018
PostgreSQL Open SV 2018
 
Redux Sagas - React Alicante
Redux Sagas - React AlicanteRedux Sagas - React Alicante
Redux Sagas - React Alicante
 

Similar to 4 mishchevskii - testing stage18-

MT_01_unittest_python.pdf
MT_01_unittest_python.pdfMT_01_unittest_python.pdf
MT_01_unittest_python.pdfHans Jones
 
To Err Is Human
To Err Is HumanTo Err Is Human
To Err Is HumanAlex Liu
 
Javascript Everywhere
Javascript EverywhereJavascript Everywhere
Javascript EverywherePascal Rettig
 
Java script advance-auroskills (2)
Java script advance-auroskills (2)Java script advance-auroskills (2)
Java script advance-auroskills (2)BoneyGawande
 
Altitude SF 2017: Debugging Fastly VCL 101
Altitude SF 2017: Debugging Fastly VCL 101Altitude SF 2017: Debugging Fastly VCL 101
Altitude SF 2017: Debugging Fastly VCL 101Fastly
 
Testing React hooks with the new act function
Testing React hooks with the new act functionTesting React hooks with the new act function
Testing React hooks with the new act functionDaniel Irvine
 
Unit Testing JavaScript Applications
Unit Testing JavaScript ApplicationsUnit Testing JavaScript Applications
Unit Testing JavaScript ApplicationsYnon Perek
 
Ruxmon cve 2012-2661
Ruxmon cve 2012-2661Ruxmon cve 2012-2661
Ruxmon cve 2012-2661snyff
 
Intro to Asynchronous Javascript
Intro to Asynchronous JavascriptIntro to Asynchronous Javascript
Intro to Asynchronous JavascriptGarrett Welson
 
Node.js System: The Landing
Node.js System: The LandingNode.js System: The Landing
Node.js System: The LandingHaci Murat Yaman
 
Promise: async programming hero
Promise: async programming heroPromise: async programming hero
Promise: async programming heroThe Software House
 
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 - The Whys, Whens and Hows
Unit Testing - The Whys, Whens and HowsUnit Testing - The Whys, Whens and Hows
Unit Testing - The Whys, Whens and Howsatesgoral
 
How to develop frontend quiz app using vue js
How to develop frontend quiz app using vue jsHow to develop frontend quiz app using vue js
How to develop frontend quiz app using vue jsKaty Slemon
 

Similar to 4 mishchevskii - testing stage18- (20)

Async Web QA
Async Web QAAsync Web QA
Async Web QA
 
MT_01_unittest_python.pdf
MT_01_unittest_python.pdfMT_01_unittest_python.pdf
MT_01_unittest_python.pdf
 
To Err Is Human
To Err Is HumanTo Err Is Human
To Err Is Human
 
Javascript Everywhere
Javascript EverywhereJavascript Everywhere
Javascript Everywhere
 
Java script advance-auroskills (2)
Java script advance-auroskills (2)Java script advance-auroskills (2)
Java script advance-auroskills (2)
 
Altitude SF 2017: Debugging Fastly VCL 101
Altitude SF 2017: Debugging Fastly VCL 101Altitude SF 2017: Debugging Fastly VCL 101
Altitude SF 2017: Debugging Fastly VCL 101
 
Java Performance Tuning
Java Performance TuningJava Performance Tuning
Java Performance Tuning
 
Testing React hooks with the new act function
Testing React hooks with the new act functionTesting React hooks with the new act function
Testing React hooks with the new act function
 
Unit Testing JavaScript Applications
Unit Testing JavaScript ApplicationsUnit Testing JavaScript Applications
Unit Testing JavaScript Applications
 
Ruxmon cve 2012-2661
Ruxmon cve 2012-2661Ruxmon cve 2012-2661
Ruxmon cve 2012-2661
 
Intro to Asynchronous Javascript
Intro to Asynchronous JavascriptIntro to Asynchronous Javascript
Intro to Asynchronous Javascript
 
Node.js System: The Landing
Node.js System: The LandingNode.js System: The Landing
Node.js System: The Landing
 
Akka Testkit Patterns
Akka Testkit PatternsAkka Testkit Patterns
Akka Testkit Patterns
 
Easy mock
Easy mockEasy mock
Easy mock
 
Promise: async programming hero
Promise: async programming heroPromise: async programming hero
Promise: async programming hero
 
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 - The Whys, Whens and Hows
Unit Testing - The Whys, Whens and HowsUnit Testing - The Whys, Whens and Hows
Unit Testing - The Whys, Whens and Hows
 
How to develop frontend quiz app using vue js
How to develop frontend quiz app using vue jsHow to develop frontend quiz app using vue js
How to develop frontend quiz app using vue js
 
Sane Async Patterns
Sane Async PatternsSane Async Patterns
Sane Async Patterns
 
Javascript: master this
Javascript: master thisJavascript: master this
Javascript: master this
 

More from Ievgenii Katsan

8 andrew kalyuzhin - 30 ux-advices, that will make users love you
8   andrew kalyuzhin - 30 ux-advices, that will make users love you8   andrew kalyuzhin - 30 ux-advices, that will make users love you
8 andrew kalyuzhin - 30 ux-advices, that will make users love youIevgenii Katsan
 
5 hans van loenhoud - master-class the 7 skills of highly successful teams
5   hans van loenhoud - master-class the 7 skills of highly successful teams5   hans van loenhoud - master-class the 7 skills of highly successful teams
5 hans van loenhoud - master-class the 7 skills of highly successful teamsIevgenii Katsan
 
4 alexey orlov - life of product in startup and enterprise
4   alexey orlov - life of product in startup and enterprise4   alexey orlov - life of product in startup and enterprise
4 alexey orlov - life of product in startup and enterpriseIevgenii Katsan
 
3 dmitry gomeniuk - how to make data-driven decisions in saa s products
3   dmitry gomeniuk - how to make data-driven decisions in saa s products3   dmitry gomeniuk - how to make data-driven decisions in saa s products
3 dmitry gomeniuk - how to make data-driven decisions in saa s productsIevgenii Katsan
 
7 hans van loenhoud - the problem-goal-solution trinity
7   hans van loenhoud - the problem-goal-solution trinity7   hans van loenhoud - the problem-goal-solution trinity
7 hans van loenhoud - the problem-goal-solution trinityIevgenii Katsan
 
3 denys gobov - change request specification the knowledge base or the task...
3   denys gobov - change request specification the knowledge base or the task...3   denys gobov - change request specification the knowledge base or the task...
3 denys gobov - change request specification the knowledge base or the task...Ievgenii Katsan
 
5 victoria cupet - learn to play business analysis
5   victoria cupet - learn to play business analysis5   victoria cupet - learn to play business analysis
5 victoria cupet - learn to play business analysisIevgenii Katsan
 
5 alina petrenko - key requirements elicitation during the first contact wi...
5   alina petrenko - key requirements elicitation during the first contact wi...5   alina petrenko - key requirements elicitation during the first contact wi...
5 alina petrenko - key requirements elicitation during the first contact wi...Ievgenii Katsan
 
3 karabak kuyavets transformation of business analyst to product owner
3   karabak kuyavets transformation of business analyst to product owner3   karabak kuyavets transformation of business analyst to product owner
3 karabak kuyavets transformation of business analyst to product ownerIevgenii Katsan
 
4 andrii melnykov - stakeholder management for pd ms and b-as and why it is...
4   andrii melnykov - stakeholder management for pd ms and b-as and why it is...4   andrii melnykov - stakeholder management for pd ms and b-as and why it is...
4 andrii melnykov - stakeholder management for pd ms and b-as and why it is...Ievgenii Katsan
 
3 zornitsa nikolova - the product manager between decision making and facil...
3   zornitsa nikolova - the product manager between decision making and facil...3   zornitsa nikolova - the product manager between decision making and facil...
3 zornitsa nikolova - the product manager between decision making and facil...Ievgenii Katsan
 
4 viktoriya gudym - how to effectively manage remote employees
4   viktoriya gudym - how to effectively manage remote employees4   viktoriya gudym - how to effectively manage remote employees
4 viktoriya gudym - how to effectively manage remote employeesIevgenii Katsan
 
9 natali renska - product and outsource development, how to cook 2 meals in...
9   natali renska - product and outsource development, how to cook 2 meals in...9   natali renska - product and outsource development, how to cook 2 meals in...
9 natali renska - product and outsource development, how to cook 2 meals in...Ievgenii Katsan
 
7 denis parkhomenko - from idea to execution how to make a product that cus...
7   denis parkhomenko - from idea to execution how to make a product that cus...7   denis parkhomenko - from idea to execution how to make a product that cus...
7 denis parkhomenko - from idea to execution how to make a product that cus...Ievgenii Katsan
 
6 anton vitiaz - inside the mvp in 3 days
6   anton vitiaz - inside the mvp in 3 days6   anton vitiaz - inside the mvp in 3 days
6 anton vitiaz - inside the mvp in 3 daysIevgenii Katsan
 
5 mariya popova - ideal product management. unicorns in our reality
5   mariya popova - ideal product management. unicorns in our reality5   mariya popova - ideal product management. unicorns in our reality
5 mariya popova - ideal product management. unicorns in our realityIevgenii Katsan
 
2 victor podzubanov - design thinking game
2   victor podzubanov - design thinking game2   victor podzubanov - design thinking game
2 victor podzubanov - design thinking gameIevgenii Katsan
 
3 sergiy potapov - analyst to product owner
3   sergiy potapov - analyst to product owner3   sergiy potapov - analyst to product owner
3 sergiy potapov - analyst to product ownerIevgenii Katsan
 
4 anton parkhomenko - how to make effective user research with no budget at...
4   anton parkhomenko - how to make effective user research with no budget at...4   anton parkhomenko - how to make effective user research with no budget at...
4 anton parkhomenko - how to make effective user research with no budget at...Ievgenii Katsan
 

More from Ievgenii Katsan (20)

8 andrew kalyuzhin - 30 ux-advices, that will make users love you
8   andrew kalyuzhin - 30 ux-advices, that will make users love you8   andrew kalyuzhin - 30 ux-advices, that will make users love you
8 andrew kalyuzhin - 30 ux-advices, that will make users love you
 
5 hans van loenhoud - master-class the 7 skills of highly successful teams
5   hans van loenhoud - master-class the 7 skills of highly successful teams5   hans van loenhoud - master-class the 7 skills of highly successful teams
5 hans van loenhoud - master-class the 7 skills of highly successful teams
 
4 alexey orlov - life of product in startup and enterprise
4   alexey orlov - life of product in startup and enterprise4   alexey orlov - life of product in startup and enterprise
4 alexey orlov - life of product in startup and enterprise
 
3 dmitry gomeniuk - how to make data-driven decisions in saa s products
3   dmitry gomeniuk - how to make data-driven decisions in saa s products3   dmitry gomeniuk - how to make data-driven decisions in saa s products
3 dmitry gomeniuk - how to make data-driven decisions in saa s products
 
7 hans van loenhoud - the problem-goal-solution trinity
7   hans van loenhoud - the problem-goal-solution trinity7   hans van loenhoud - the problem-goal-solution trinity
7 hans van loenhoud - the problem-goal-solution trinity
 
1 hans van loenhoud -
1   hans van loenhoud - 1   hans van loenhoud -
1 hans van loenhoud -
 
3 denys gobov - change request specification the knowledge base or the task...
3   denys gobov - change request specification the knowledge base or the task...3   denys gobov - change request specification the knowledge base or the task...
3 denys gobov - change request specification the knowledge base or the task...
 
5 victoria cupet - learn to play business analysis
5   victoria cupet - learn to play business analysis5   victoria cupet - learn to play business analysis
5 victoria cupet - learn to play business analysis
 
5 alina petrenko - key requirements elicitation during the first contact wi...
5   alina petrenko - key requirements elicitation during the first contact wi...5   alina petrenko - key requirements elicitation during the first contact wi...
5 alina petrenko - key requirements elicitation during the first contact wi...
 
3 karabak kuyavets transformation of business analyst to product owner
3   karabak kuyavets transformation of business analyst to product owner3   karabak kuyavets transformation of business analyst to product owner
3 karabak kuyavets transformation of business analyst to product owner
 
4 andrii melnykov - stakeholder management for pd ms and b-as and why it is...
4   andrii melnykov - stakeholder management for pd ms and b-as and why it is...4   andrii melnykov - stakeholder management for pd ms and b-as and why it is...
4 andrii melnykov - stakeholder management for pd ms and b-as and why it is...
 
3 zornitsa nikolova - the product manager between decision making and facil...
3   zornitsa nikolova - the product manager between decision making and facil...3   zornitsa nikolova - the product manager between decision making and facil...
3 zornitsa nikolova - the product manager between decision making and facil...
 
4 viktoriya gudym - how to effectively manage remote employees
4   viktoriya gudym - how to effectively manage remote employees4   viktoriya gudym - how to effectively manage remote employees
4 viktoriya gudym - how to effectively manage remote employees
 
9 natali renska - product and outsource development, how to cook 2 meals in...
9   natali renska - product and outsource development, how to cook 2 meals in...9   natali renska - product and outsource development, how to cook 2 meals in...
9 natali renska - product and outsource development, how to cook 2 meals in...
 
7 denis parkhomenko - from idea to execution how to make a product that cus...
7   denis parkhomenko - from idea to execution how to make a product that cus...7   denis parkhomenko - from idea to execution how to make a product that cus...
7 denis parkhomenko - from idea to execution how to make a product that cus...
 
6 anton vitiaz - inside the mvp in 3 days
6   anton vitiaz - inside the mvp in 3 days6   anton vitiaz - inside the mvp in 3 days
6 anton vitiaz - inside the mvp in 3 days
 
5 mariya popova - ideal product management. unicorns in our reality
5   mariya popova - ideal product management. unicorns in our reality5   mariya popova - ideal product management. unicorns in our reality
5 mariya popova - ideal product management. unicorns in our reality
 
2 victor podzubanov - design thinking game
2   victor podzubanov - design thinking game2   victor podzubanov - design thinking game
2 victor podzubanov - design thinking game
 
3 sergiy potapov - analyst to product owner
3   sergiy potapov - analyst to product owner3   sergiy potapov - analyst to product owner
3 sergiy potapov - analyst to product owner
 
4 anton parkhomenko - how to make effective user research with no budget at...
4   anton parkhomenko - how to make effective user research with no budget at...4   anton parkhomenko - how to make effective user research with no budget at...
4 anton parkhomenko - how to make effective user research with no budget at...
 

Recently uploaded

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
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 

Recently uploaded (20)

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
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
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
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 

4 mishchevskii - testing stage18-

  • 2. whoami • Gennadii Mishchevskii • Senior Automation QA Engineer at Ciklum • 4 years in the industry • Automated back-end, front-end and mobile • https://www.linkedin.com/in/gennadiimishchevskii/
  • 3. Agenda • Async theory • Callback • Promises • Async/Await • Quiz
  • 4. Warm-up typeof null; typeof NaN; NaN instanceof Number; typeof 'string'; 'string' instanceof String; '1' + +'1'; '1' - -'1'; null > 0; null == 0; null >= 0; {} + []; true + true - false > true ** 2; let wtf = () => { try { return 24; } finally { return 42; } }; wtf(); object number false false string ‘11’ 2 false false true 0 true 42
  • 6. Async theory - PHP server, Single Sync thread
  • 7. Async theory - PHP server, Single Sync thread timeline Order food Pay Clean after yourself
  • 8. Async theory - Multithreading Java server
  • 9. Async theory - Multithreading Java server timeline Main thread Thread 1 Thread 2 Thread 3 Order food Pay Clean after yourself
  • 10. Async theory - NodeJS Async server
  • 11. Async theory - NodeJS Async server timeline Single thread Libuv Order food Pay Clean after yourself // example1.js
  • 12. Async theory - Stack and heap // stack.js, stackTrace.js, maxCallStack.js
  • 13. Async theory - Full picture // fullPicture.js
  • 14. Promises - 99.99% can't solve this task func1().then(function () { return func2(); }); func1().then(function () { func2(); }); func1().then(func2()); func1().then(func2);
  • 16. Callback – why don't we love callbacks • Callback hell • Catching errors • Difficult to wait for several async actions to finish // callbackLinux.js
  • 17. Promises – the rescuer • Callback hell • Catching errors • Difficult to wait for several async actions to finish
  • 18. Promises – the rescuer (specs) • A promise or “thenable” is an object that supplies a standard- compliant .then() method. • A pending promise may transition into a fulfilled or rejected state.
  • 19. Promises – the rescuer (specs) • A fulfilled or rejected promise is settled, and must not transition into any other state. • Once a promise is settled, it must have a value (which may be undefined). That value must not change. • Every promise must supply a .then() method with the following signature: promise.then( onFulfilled?: Function, onRejected?: Function ) => Promise
  • 20. Promises – the rescuer (specs) • Both onFulfilled() and onRejected() are optional.​ • If the arguments supplied are not functions, they must be ignored.​ • onFulfilled() will be called after the promise is fulfilled, with the promise’s value as the first argument.​ • onRejected() will be called after the promise is rejected, with the reason for rejection as the first argument. The reason may be any valid JavaScript value, but because rejections are essentially synonymous with exceptions, I recommend using Error objects.​
  • 21. Promises – the rescuer (specs) • .then() may be called many times on the same promise. ​ • .then() must return a new promise, promise2.​ • If either onFulfilled or onRejected throws an exception e, promise2 must be rejected with e as the reason.​ • If onFulfilled is not a function and promise1 is fulfilled, promise2 must be fulfilled with the same value as promise1.​ • If onRejected is not a function and promise1 is rejected, promise2 must be rejected with the same reason as promise1.​
  • 22. Promises – the rescuer (create and chain) function myRandomPromise() { return new Promise(function (resolve, reject) { const random = Math.random(); random < 0.5 ? resolve('Yay, it worked') : reject('Oh no, something went wrong'); }) } myPromise() .then(console.log) .catch(console.log); myRandomPromise() .then(result => console.log(result), error => console.log(error)); myRandomPromise() .then(console.log, console.log); myRandomPromise() .catch(console.log); myRandomPromise() .then(null, console.log);
  • 23. Promises – the rescuer (don't forget to catch) Promise.resolve(42) .then(doFirst) .then(doSecond) .catch(console.log) .then(doThird) .catch(err => { console.log(err); return err.message; }) .then(doFourth) .catch(console.log);
  • 24. Promises – the rescuer (what’s gonna happen?) function myPromise() { return new Promise(resolve => { Object.notExistingFunction(); resolve('Resolved'); }) } myPromise() .then(console.log) .catch(console.log); setTimeout(_ => console.log('setTimeout'));
  • 25. Promises – the rescuer (how to ruin it) function myRandomPromise(num) { return new Promise(function (resolve) { resolve(Math.random()); }); }myRandomPromise().then(num => { return myRandomPromise().then(num => { return myRandomPromise().then(num => { return myRandomPromise().then(num => { return myRandomPromise().then(num => { return myRandomPromise().then(num => { console.log(num); }); }); }); }); }); }); myRandomPromise() .then(num => { return myRandomPromise() }) .then(num => { return myRandomPromise() }) .then(num => { console.log(num); }); // callbackedPromise.js
  • 26. Async/Await – the advanced rescuer • Callback hell • Catching errors • Difficult to wait for several async actions to finish // promiseLunix.js, promise0-1.js , asyncAwaitSimple.js, asyncAwaitFlow.js , asyncAwaitLinux.js, promise2+.js
  • 27. Async theory - NodeJS Async server
  • 28. Async theory - NodeJS Async server timeline Single thread Libuv Order food Pay Clean after yourself // example2.js
  • 29. Quiz – 1. What will be the result let prоm = new Promise((resolve, reject) => { resolve('Some message'); }); prоm .then((result) => { console.log(result); }, (err) => { console.log('Errоr оccurred'); }); 1. Some message 2. Errоr оccurred 3. Nothing 4. Some message Errоr оccurred 5. Errоr оccurred Some message
  • 30. Quiz – 2. What will be the result let prоm = new Promise((resolve, reject) => { reject('Some message'); }); prоm .then((result) => { console.log(result); }, (err) => { console.log('Errоr оccurred: ' + err); }); 1. Some message 2. Error occurred: 3. Error occurred: Some message 4. Some message Error occurred: 5. Nothing
  • 31. Quiz – 3. What will be the result let prоm = new Promise((resolve, reject) => { reject('Some message'); }); prоm .then((result) => { console.log(result); }) .catch(err => { console.log('Errоr оccurred: ' + err); }); 1. Some message 2. Error occurred: undefined 3. Error occurred: Some message 4. Some message Error occurred: 5. Error will be thrown
  • 32. Quiz – 4. What will be the result let prоm = new Promise((resolve, reject) => { resolve('Some message'); }); prоm .then(result => { throw new Error(result); }, err => { console.log('Error occurred: ' + err) }) .catch((err) => { console.log('Error occurred inside: ' + err) }); 1. Error occurred: Some message 2. Error occurred inside: Some message 3. Some message 4. Nothing 5. Error will be thrown
  • 33. Quiz – 5. There's an element with locator #myId. What will be the result console.log(element(by.css('#myId')).isPresent() === true); console.log(element(by.css('#myId')).isPresent() === false); 1. true true 2. false false 3. Error 4. true false 5. false true
  • 34. Quiz – 6. There's an element with locator #myId and text inside 'some text'. What will be the result element(by.css('#myId')) .getText() .then(value => { return element(by.css('#myId')).getText() .then(value2 => { console.log(value + ' ' + value2) }); }); 1. Error 2. some text some text 3. some text Promise 4. some text undefined 5. getText getText 6. Promise Promise
  • 35. Quiz – 7. There's an element with locator #myId and text inside 'some text'. After click on element text changes to 'Clicked'. What will be the result let elem = element(by.css('#myId')); let txt = elem.getText(); txt .then(txtBefore => { return elem.click() .then(_ => txt) .then(txtAfter => { console.log(txtBefore + ' ' + txtAfter); }); }); 1. some text some text 2. some text Clicked 3. some text undefined 4. Error 5. txtBefore txtAfter
  • 36. Quiz – 8. There's an element with locator #myId and text inside 'some text'. After click on element text changes to 'Clicked'. What will be the result let elem = element(by.css('#myId')); elem .getText() .then(txtBefore => { return elem.click() .then(_ => elem.getText()) .then(txtAfter => { console.log(txtBefore + ' ' + txtAfter); }); }); 1. some text some text 2. some text Clicked 3. some text undefined 4. Error 5. txtBefore txtAfter
  • 37. Quiz – 9. There's an element with locator #myId and text inside 'some text'. After click on element text changes to 'Clicked'. What will be the result let elem = element(by.css('#myId')); void async function logValues() { let txtBefore = await elem.getText(); await elem.click(); let txtAfter = await elem.getText(); console.log(txtBefore+ ' ' + txtAfter); }(); 1. some text some text 2. some text Clicked 3. txtBefore txtAfter 4. Promise Promise
  • 38. Quiz – 10. There's an element with locator #myId and text inside 'some text'. After click on element text changes to 'Clicked'. What will be the result let elem = element(by.css('#myId')); void async function logValues() { let txtBefore = elem.getText(); await elem.click(); let txtAfter = elem.getText(); console.log(txtBefore + ' ' + txtAfter); }(); 1. some text some text 2. some text Clicked 3. txtBefore txtAfter 4. Promise Promise