Unit Testing with the JavaScript API2019 Esri Developer Summit Palm Springs -- Presentation, 2019...

23
George Bochenek Randy Jones @bosshenek @randysjones Unit Testing with the JavaScript API

Transcript of Unit Testing with the JavaScript API2019 Esri Developer Summit Palm Springs -- Presentation, 2019...

Page 1: Unit Testing with the JavaScript API2019 Esri Developer Summit Palm Springs -- Presentation, 2019 Esri Developer Summit Palm Springs, Unit Testing with the JavaScript API Created Date

George Bochenek Randy Jones@bosshenek @randysjones

Unit Testing with the JavaScript API

Page 2: Unit Testing with the JavaScript API2019 Esri Developer Summit Palm Springs -- Presentation, 2019 Esri Developer Summit Palm Springs, Unit Testing with the JavaScript API Created Date

Last Year’s Talk

• A Lot of Vocabulary• Tons of Tools

Page 3: Unit Testing with the JavaScript API2019 Esri Developer Summit Palm Springs -- Presentation, 2019 Esri Developer Summit Palm Springs, Unit Testing with the JavaScript API Created Date

This Year’s Talk

• Some Ground Rules• All the Demos

Page 4: Unit Testing with the JavaScript API2019 Esri Developer Summit Palm Springs -- Presentation, 2019 Esri Developer Summit Palm Springs, Unit Testing with the JavaScript API Created Date

Write Code

Write Test

Write code, break test

Rewrite Test

How do we Test?

Page 5: Unit Testing with the JavaScript API2019 Esri Developer Summit Palm Springs -- Presentation, 2019 Esri Developer Summit Palm Springs, Unit Testing with the JavaScript API Created Date

Write Test

Test Fails

Write code till passes

Refactor

Test Driven Development

Page 6: Unit Testing with the JavaScript API2019 Esri Developer Summit Palm Springs -- Presentation, 2019 Esri Developer Summit Palm Springs, Unit Testing with the JavaScript API Created Date

Rule #1:

Don’t Test Other People’s Code

Page 7: Unit Testing with the JavaScript API2019 Esri Developer Summit Palm Springs -- Presentation, 2019 Esri Developer Summit Palm Springs, Unit Testing with the JavaScript API Created Date

Rule #2:

Prioritize

Page 8: Unit Testing with the JavaScript API2019 Esri Developer Summit Palm Springs -- Presentation, 2019 Esri Developer Summit Palm Springs, Unit Testing with the JavaScript API Created Date

https://www.slideshare.net/abagmar/anand-bagmar-behavior-driven-testing-bdt-in-agile

Page 9: Unit Testing with the JavaScript API2019 Esri Developer Summit Palm Springs -- Presentation, 2019 Esri Developer Summit Palm Springs, Unit Testing with the JavaScript API Created Date

Nightmare Test Pyramid

Bugs

A single functional test thathasn’t passed in three years

Page 10: Unit Testing with the JavaScript API2019 Esri Developer Summit Palm Springs -- Presentation, 2019 Esri Developer Summit Palm Springs, Unit Testing with the JavaScript API Created Date

Rule #3:EncapsulateEncapsulateEncapsulate

Page 11: Unit Testing with the JavaScript API2019 Esri Developer Summit Palm Springs -- Presentation, 2019 Esri Developer Summit Palm Springs, Unit Testing with the JavaScript API Created Date

Easy to Test=

Easy to Maintain

Page 12: Unit Testing with the JavaScript API2019 Esri Developer Summit Palm Springs -- Presentation, 2019 Esri Developer Summit Palm Springs, Unit Testing with the JavaScript API Created Date

TestFromTheStartFlickr Photo by nostri-imago https://flic.kr/p/8XF4BL shared under a Creative Commons (BY) license

Page 13: Unit Testing with the JavaScript API2019 Esri Developer Summit Palm Springs -- Presentation, 2019 Esri Developer Summit Palm Springs, Unit Testing with the JavaScript API Created Date

https://github.com/Esri/arcgis-js-cli

Page 14: Unit Testing with the JavaScript API2019 Esri Developer Summit Palm Springs -- Presentation, 2019 Esri Developer Summit Palm Springs, Unit Testing with the JavaScript API Created Date

FixYourLegacy

Flickr Photo by nostri-imago https://flic.kr/p/8XF4BL shared under a Creative Commons (BY) license

Page 15: Unit Testing with the JavaScript API2019 Esri Developer Summit Palm Springs -- Presentation, 2019 Esri Developer Summit Palm Springs, Unit Testing with the JavaScript API Created Date

https://github.com/Esri/enterprise-build-sample-js

Page 16: Unit Testing with the JavaScript API2019 Esri Developer Summit Palm Springs -- Presentation, 2019 Esri Developer Summit Palm Springs, Unit Testing with the JavaScript API Created Date

Can IReact?(or Angularor Emberor new-trendy-framework)

Flickr Photo by nostri-imago https://flic.kr/p/8XF4BL shared under a Creative Commons (BY) license

Page 17: Unit Testing with the JavaScript API2019 Esri Developer Summit Palm Springs -- Presentation, 2019 Esri Developer Summit Palm Springs, Unit Testing with the JavaScript API Created Date

What About Web AppBuilder?

https://github.com/gbochenek/esri-wab-build

Page 18: Unit Testing with the JavaScript API2019 Esri Developer Summit Palm Springs -- Presentation, 2019 Esri Developer Summit Palm Springs, Unit Testing with the JavaScript API Created Date

Separate Your Code

https://github.com/Esri/generator-esri-appbuilder-js

Web AppBuilderDev Edition

generate

watch Copywidget

git

create

Page 19: Unit Testing with the JavaScript API2019 Esri Developer Summit Palm Springs -- Presentation, 2019 Esri Developer Summit Palm Springs, Unit Testing with the JavaScript API Created Date

Related Talks

Web AppBuilder for ArcGIS: Advanced Development Tools and Techniques• TODAY // 5:30 – 6:30• Catalina / Medera• George Bochenek / Gavin Rehkemper

Page 20: Unit Testing with the JavaScript API2019 Esri Developer Summit Palm Springs -- Presentation, 2019 Esri Developer Summit Palm Springs, Unit Testing with the JavaScript API Created Date

ArcGIS JS CLIhttps://github.com/Esri/arcgis-js-cli

Legacy App Samplehttps://github.com/Esri/enterprise-build-sample-js

Nearby App - Reacthttps://github.com/Esri/nearby-javascript

Web AppBuilder Resourceshttps://github.com/gbochenek/wab-test-example

The Clean Code Talks -> Unit Testinghttps://www.youtube.com/watch?v=wEhu57pih5w

2018 Talk – Javascript Applications for the Enterprise: Test More, Work Lesshttps://www.youtube.com/watch?v=amEMQk5iY5c&t=8s

Resources

Page 21: Unit Testing with the JavaScript API2019 Esri Developer Summit Palm Springs -- Presentation, 2019 Esri Developer Summit Palm Springs, Unit Testing with the JavaScript API Created Date

Intern – Test Runner & Frameworkhttps://theintern.io/

Karma – Test Runnerhttp://karma-runner.github.io/latest/index.html

SinonJS – Spies, Stubs, Mockshttps://sinonjs.org/

TS Mockito – Strongly Typed Mocking Libraryhttps://github.com/NagRock/ts-mockito

Jasmine – Test Frameworkhttps://jasmine.github.io/

Tooling

Page 22: Unit Testing with the JavaScript API2019 Esri Developer Summit Palm Springs -- Presentation, 2019 Esri Developer Summit Palm Springs, Unit Testing with the JavaScript API Created Date
Page 23: Unit Testing with the JavaScript API2019 Esri Developer Summit Palm Springs -- Presentation, 2019 Esri Developer Summit Palm Springs, Unit Testing with the JavaScript API Created Date

Complete answersand select “Submit”

Scroll down to find the feedback section

Select the session you attended

Download the Esri Events app and find your event

Please Take Our Survey on the App