Professional Documents
Culture Documents
Test-Driven Development with React and TypeScript: Building Maintainable React Applications 2nd Edition Juntao Qiu full chapter instant download
Test-Driven Development with React and TypeScript: Building Maintainable React Applications 2nd Edition Juntao Qiu full chapter instant download
Test-Driven Development with React and TypeScript: Building Maintainable React Applications 2nd Edition Juntao Qiu full chapter instant download
https://ebookmass.com/product/react-and-react-native-fifth-
edition-mikhail-sakhniuk/
https://ebookmass.com/product/%e7%8e%b0%e4%bb%a3%e5%85%a8%e6%a0%8
8%e5%bc%80%e5%8f%91-%e4%bd%bf%e7%94%a8-
typescript%e3%80%81react%e3%80%81node-
js%e3%80%81webpack-%e5%92%8c-docker-frank-zammetti/
https://ebookmass.com/product/master-react-in-5-days-become-a-
react-expert-in-under-a-week-eric-sarrion/
https://ebookmass.com/product/master-react-in-5-days-become-a-
react-expert-in-under-a-week-eric-sarrion-2/
Test-Driven Development in Go Simion
https://ebookmass.com/product/test-driven-development-in-go-
simion/
https://ebookmass.com/product/react-hooks-in-action-meap-03-john-
larsen-larsen/
https://ebookmass.com/product/hands-on-test-driven-development-
using-ruby-ruby-on-rails-and-rspec-1st-edition-greg-donald/
https://ebookmass.com/product/hands-on-test-driven-development-
using-ruby-ruby-on-rails-and-rspec-1-converted-edition-greg-
donald/
https://ebookmass.com/product/database-driven-web-development-
learn-to-operate-at-a-professional-level-with-perl-and-mysql-2nd-
edition-thomas-valentine/
Test-Driven
Development with
React and TypeScript
Building Maintainable React
Applications
—
Second Edition
—
Juntao Qiu
Test-Driven
Development with
React and TypeScript
Building Maintainable React
Applications
Second Edition
Juntao Qiu
Test-Driven Development with React and TypeScript: Building
Maintainable React Applications
Juntao Qiu
Wantirna, 3152, VIC, Australia
v
Table of Contents
vi
Table of Contents
vii
Table of Contents
viii
Table of Contents
Unit Tests����������������������������������������������������������������������������������������������������������132
Refactoring��������������������������������������������������������������������������������������������������133
Book Detail Page�����������������������������������������������������������������������������������������137
File Structure�����������������������������������������������������������������������������������������������139
Testing Data������������������������������������������������������������������������������������������������������141
User Interface Refinement��������������������������������������������������������������������������������143
Using Grid System���������������������������������������������������������������������������������������144
Handling Default Value��������������������������������������������������������������������������������������146
A Failing Test with undefined����������������������������������������������������������������������146
One Last Change?���������������������������������������������������������������������������������������������149
Summary����������������������������������������������������������������������������������������������������������150
ix
Table of Contents
x
Table of Contents
Index�������������������������������������������������������������������������������������������������259
xi
About the Author
Juntao Qiu is an accomplished software
developer renowned for his expertise
in producing high-quality and easily
maintainable code. He is committed to
helping individuals improve their code-
writing abilities and generously shares his vast
knowledge and experience through multiple
platforms, including books such as this one
and Maintainable React (Leanpub, 2022).
In addition, Juntao hosts a YouTube channel (@icodeit.juntao) where
he provides valuable insights, tips, and best practices for writing clean
code and performing refactoring. Juntao’s goal is to empower developers,
enabling them to reach their full potential and have a positive impact on
the software development industry.
xiii
About the Technical Reviewers
Jeff Friesen is a freelance teacher and
software developer with an emphasis on
Java. In addition to authoring Java I/O, NIO
and NIO.2 (Apress) and Java Threads and
the Concurrency Utilities (Apress), Jeff has
written numerous articles on Java and other
technologies (such as Android) for JavaWorld
(JavaWorld.com) – now InfoWorld (www.
infoworld.com/category/java/), informIT
(InformIT.com), Java.net (no longer in existence), SitePoint (SitePoint.
com), and other websites. Jeff can be contacted via his email address:
jefff@xplornet.ca.
xv
Acknowledgments
I am profoundly grateful to my ThoughtWorks colleagues for their
enthusiastic engagement and invaluable contributions during the
development of this book. Our project discussions were a fountain of
insight, enriching the narrative with an array of diverse perspectives. A
special acknowledgment goes to Evan Bottcher for his meticulous review
and for providing an eloquent foreword for the book.
Before embarking on the second edition, I reached out to my
newsletter (https://juntao.substack.com/) subscribers with a survey,
seeking their expectations for the new iteration. The response was
overwhelming and deeply informative – my heartfelt thanks go out to
those dedicated readers who took the time to provide their input.
I must extend my profound appreciation to the editorial team for their
indispensable support throughout the second edition’s journey. Their
expert advice has proven invaluable in refining the text, and it’s their
tireless dedication that has brought this project to fruition.
Finally, upon first sharing my book’s vision with my colleagues
at ThoughtWorks, the outpouring of valuable feedback I received –
spanning from minor typographical corrections to substantial technical
suggestions – was truly overwhelming. In particular, on a cool morning
in May 2020, I was greeted with an uplifting email from Hannah Bourke,
who not only expressed her appreciation for the book but also offered
her editing assistance as a native English speaker and fellow developer.
Her subsequent pull requests offered not just high-quality language
corrections but also insightful technical review comments from a learner’s
perspective.
xvii
Acknowledgments
xviii
Foreword 1
Sometimes, I find it hard to believe that it’s been more than two decades
since Kent Beck published Extreme Programming Explained including
Test-Driven Development (TDD) as a core practice. In the years since then,
the use of automated testing has become quite commonplace, something
that almost all developers are familiar with – however, the “Red-Green-
Refactor” cycle of TDD is often missing. The reality is that building
software test first is not easy or trivial in real-world software development
and requires deliberate practice and usually someone experienced to
learn from.
At ThoughtWorks, my role is Head of Engineering – responsible for the
quality of the software that our teams produce for and with our clients.
We set a high standard for the “internal” quality of the code we produce,
wanting it to be maintainable and extensible so that it can quickly be
changed with confidence. Test-Driven Development is a default practice
in ThoughtWorks – our experience shows that the practice leads to better
software design and good confidence from a comprehensive automated
test suite.
In my years at ThoughtWorks, I’ve seen the phenomenal rise in the
importance of JavaScript and browser applications. In 2010, we advised
that the industry should treat JavaScript as a first-class language (www.
thoughtworks.com/radar/languages-and-frameworks/javascript-
as-a-first-class-language) on the ThoughtWorks Technology Radar,
applying all of the same engineering rigor as other platforms. As one of
the authors of the Technology Radar, I’ve seen and helped document the
explosion of tooling and frameworks in JavaScript, many of which have
been related to the area of test automation.
xix
Foreword 1
Evan Bottcher
March 2021
xx
Foreword 2
Landing in the middle of a React project that had very low test coverage,
in a team that had aspirations to improve it, but without a clear strategy
of how to go about it, I struggled to find resources that stepped out how to
approach testing for a frontend project. I couldn’t find a clear explanation
of how to implement Test-Driven Development for a UI, let alone
specifically for React. This book couldn’t have come at a better time.
There are a plethora of different testing methodologies and libraries
available just for React. The ones you choose will depend on many
things. This book doesn’t prescribe a particular solution but establishes
the purpose of tests in driving out specifications and suggests an overall
approach, with practical guidance and examples. Juntao provides a
holistic explanation of the purpose and implementation of Test-Driven
Development for React, demonstrating the benefits of moving testing
earlier in the process, improving the robustness and design of our code.
Juntao’s years of experience, his eagerness and passion for learning
and sharing his knowledge in a didactic way, help to make this a relevant,
practical, and engaging guide to follow and have given me confidence in
my own testing strategies.
Hannah Bourke
March 2021
xxi
Introduction
This comprehensive book is your ultimate guide to mastering Test-Driven
Development (TDD) in the context of React and TypeScript. Whether you're
a seasoned developer seeking to refine your skills or a newcomer eager to
embrace industry-standard practices, this book caters to all levels of expertise.
Spanning a wide range of topics, each chapter in this book is
thoughtfully designed to provide you with a deep understanding of TDD
principles and their application in real-world scenarios. Let's take a
glimpse into the chapters and their role in your learning journey:
xxiii
Introduction
By following along with each chapter, you'll not only acquire the
knowledge and skills to excel in TDD but also experience the benefits
firsthand. Faster feedback cycles, improved code quality, enhanced
collaboration, and the confidence to make changes and add new features
are just a few of the advantages you'll gain.
Are you ready to embark on a transformative journey toward
becoming a more confident, efficient, and skilled developer? Test-Driven
Development with React and TypeScript: Building Maintainable React
Applications is your comprehensive companion. Let the power of TDD
guide your development process, elevate your coding skills, and lay the
foundation for a successful career in software development. Get ready to
dive in and unlock the full potential of TDD in your React projects.
xxiv
Another random document with
no related content on Scribd:
Plays of the Sea 111
PASCAL, BLAISE Pensées and The Provincial Letters
164
PATER, WALTER The Renaissance 86
PATER, WALTER Marius the Epicurean 90
PEARSON, EDMUND Studies in Murder 113
PEPYS, SAMUEL Samuel Pepys’ Diary 103
PETRONIUS ARBITER The Satyricon 156
PLATO The Republic 153
PLATO The Philosophy of Plato 181
POE, EDGAR ALLAN Best Tales 82
POLO, MARCO The Travels of Marco Polo 196
PORTER, KATHERINE ANNE Flowering Judas 88
PREVOST, ANTOINE Manon Lescaut 85
PROUST, MARCEL Cities of the Plain 220
PROUST, MARCEL The Captive 120
PROUST, MARCEL The Guermantes Way 213
PROUST, MARCEL Swann’s Way 59
PROUST, MARCEL Within a Budding Grove 172
RABELAIS Gargantua and Pantagruel 4
READE, CHARLES The Cloister and the Hearth 62
REED, JOHN Ten Days that Shook the World 215
RENAN, ERNEST The Life of Jesus 140
ROSTAND, EDMOND Cyrano de Bergerac 154
RUSSELL, BERTRAND Selected Papers of Bertrand Russell
137
SAROYAN, WILLIAM The Daring Young Man on the Flying
Trapeze 92
SCHOPENHAUER The Philosophy of Schopenhauer 52
SCHREINER, OLIVE The Story of an African Farm 132
SHEEAN, VINCENT Personal History 32
SMOLLETT, TOBIAS Humphry Clinker 159
SPINOZA The Philosophy of Spinoza 60
STEINBECK, JOHN In Dubious Battle 115
STEINBECK, JOHN The Grapes of Wrath 148
STEINBECK, JOHN Tortilla Flat 216
STEINBECK, JOHN Of Mice and Men 29
STENDHAL The Charterhouse of Parma 150
STENDHAL The Red and the Black 157
STERNE, LAURENCE Tristram Shandy 147
STOKER, BRAM Dracula 31
STONE, IRVING Lust for Life 11
STRACHEY, LYTTON Eminent Victorians 212
SUDERMANN, HERMANN The Song of Songs 162
SUETONIUS Lives of the Twelve Caesars 188
SWIFT, JONATHAN Gulliver’s Travels, A Tale of a Tub, The
Battle of the Books 100
SWINBURNE, CHARLES Poems 23
SYMONDS, JOHN A. The Life of Michelangelo 49
TCHEKOV, ANTON Short Stories 50
TCHEKOV, ANTON Sea Gull, Cherry Orchard, Three
Sisters, etc. 171
THACKERAY, WILLIAM Henry Esmond 80
THACKERAY, WILLIAM Vanity Fair 131
THOMPSON, FRANCIS Complete Poems 38
THOREAU, HENRY DAVID Walden and Other Writings 155
THUCYDIDES The Complete Writings of 58
TOLSTOY, LEO Anna Karenina 37
TOMLINSON, H. M. The Sea and the Jungle 99
TROLLOPE, ANTHONY Barchester Towers and The Warden 41
TURGENEV, IVAN Fathers and Sons 21
VAN LOON, HENDRIK W. Ancient Man 105
VEBLEN, THORSTEIN The Theory of the Leisure Class 63
VIRGIL’S WORKS Including The Aeneid, Eclogues, and
Georgics 75
VOLTAIRE Candide 47
WALPOLE, HUGH Fortitude 178
WALTON, IZAAK The Compleat Angler 26
WEBB, MARY Precious Bane 219
WELLS, H. G. Tono Bungay 197
WHITMAN, WALT Leaves of Grass 97
WILDE, OSCAR Dorian Gray, De Profundis 1
WILDE, OSCAR The Plays of Oscar Wilde 83
WILDE, OSCAR Poems and Fairy Tales 84
WOOLF, VIRGINIA Mrs. Dalloway 96
WOOLF, VIRGINIA To the Lighthouse 217
YEATS, W. B. Irish Fairy and Folk Tales 44
YOUNG, G. F. The Medici 179
ZOLA, EMILE Nana 142
ZWEIG, STEFAN Amok (In Collected German Stories
108)
Many are illustrated and some of them are over 1200 pages long.
1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside
the United States, check the laws of your country in addition to
the terms of this agreement before downloading, copying,
displaying, performing, distributing or creating derivative works
based on this work or any other Project Gutenberg™ work. The
Foundation makes no representations concerning the copyright
status of any work in any country other than the United States.
1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if
you provide access to or distribute copies of a Project
Gutenberg™ work in a format other than “Plain Vanilla ASCII” or
other format used in the official version posted on the official
Project Gutenberg™ website (www.gutenberg.org), you must, at
no additional cost, fee or expense to the user, provide a copy, a
means of exporting a copy, or a means of obtaining a copy upon
request, of the work in its original “Plain Vanilla ASCII” or other
form. Any alternate format must include the full Project
Gutenberg™ License as specified in paragraph 1.E.1.
• You pay a royalty fee of 20% of the gross profits you derive from
the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”
• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.
1.F.
Most people start at our website which has the main PG search
facility: www.gutenberg.org.