Testeando Componentes de Vue.js con Jest
Testeando Componentes de Vue.js con Jest
Una guía concisa y práctica para testear componentes de Vue.js usando Jest y la librería oficial vue-test-utils
Sobre este libro
☝ Esta es la traducción al Castellano del libro original "Testing Vue.js components with Jest", de Alex Jover Morales (Vue.js core team partner). Traducido por Paul Melero, Web developer y revisado por el propio Alex Jover.
Vue.js fue el framework que más gente marcó en 2018 como "desearía aprender" (fuente). Su crecimiento en el último año ha seguido aumentando fuertemente y no es de extrañar, dado lo productivo y flexible que es. Probablemente lo hayas usado ya, pero... ¿Has hecho testing de Vue.js?
Los tests unitarios de frameworks modernos de Javascript basados en componentes no siempre son sencillos. Los componentes se comunican unos con otros y el navegador añade una capa de UI, lo que hace que todo sea dependiente mientras que nosotros queremos testear los componentes de manera aislada. Nuestras test suites deberían darnos la confianza confianza suficiente para que nuestras codebases sean mantenibles y si podemos pedir algo más es que se ejecuten de manera rápida! ⚡
En este libro, enseñamos, de manera práctica, cómo testear componentes de Vue.js y aprovecharnos de las funcionalidades del framework de testing Jest. Te guiará por el testeo de conceptos básicos como estado local, props, estructura y estilos; e iremos avanzando testeando diferentes aspectos del comportamiento de componentes de Vue.js. También verás cómo aplicar las técnicas del snapshot testing, shallow rendering, simulación de dependencias de módulos externos y muchas cosas más; para hacer de manera correcta, limpia y rápida el unit testing de nuestras aplicaciones de Vue.js.
🚀 Testeando componentes e Vue.js con Jest. 🚀
Table of Contents
-
1. Escribe tu Primer Test Unitario de un Componente de Vue.js con Jest
- Set up de un proyecto de ejemplo
- Testeando un Componente
- Testeando con @vue/test-utils
-
2. Testear Componentes Anidados de Vue.js en Jest
- Añadir un Componente de Mensaje
- Testeamos el componente padre ListaMensajes con los hijos Mensaje
-
3. Testing de Estilos y Estructura de Componentes Vue.js en Jest
- El Objeto Wrapper
- Resumiendo
-
4. Testeo de Propiedades (Props) y Custom Events en Componentes Vue.js con Jest
- Propiedades
- Eventos Custom
- Resumiendo
-
5. Testear Computed Properties y Watchers en Componentes Vue.js con Jest
- Computed Properties
- Watchers
- Conclusión
-
6. Testear Métodos y Dependencias Mock en Vue.js con Jest
- Simular Dependencias de Módulos Externos
- Dejando los Mocks Externalizados
- Conclusión
-
7. Testeo de Slots en Vue.js con Jest
- Reescribimos ListaMensajes con slots
-
$children
and$slots
- Testeando Slots
- Testeando Named Slots
- Testeando las Especificaciones de Slots en su Contexto
- Conclusión
-
8. Expandir la Configuración de Jest con Alias de Módulos
- Alias de Webpack
- Alias Múltiples
- Otras soluciones
- Conclusión
Authors have earned$9,886,858writing, publishing and selling on Leanpub, earning 80% royalties while saving up to 25 million pounds of CO2 and up to 46,000 trees.
Más información sobre cómo escribir en Leanpub
Leanpub incondicional, sin riesgo, 100% de felicidad garantizada
Durante los primeros 45 días de compra, puedes obtener un reembolso del 100% de cualquier compra Leanpub, en dos clics. Procesamos las restituciones manualmente, así que puede tomarse unos días en aparecer. Véase términos completos.
Actualizaciones gratis. Libre de DRM.
¡Si compras un libro Leanpub obtienes actualizaciones gratis siempre y cuando el autor actualice el libro! Varios autores usan Leanpub para publicar sus libros en progreso mientras los escriben. Todos los lectores obtienen actualizaciones gratis, independientemente de cuándo compraron el libro o cuánto pagaron (incluyendo si fue gratis).
La mayoría de los libros Leanpub se encuentran disponibles en PDF (para computadores), EPUB (para teléfonos y tabletas) y MOBI (para Kindle). Los formatos que un libro incluye se muestran en la esquina superior derecha de esta página.
Finalmente, los libros Leanpub no tienen ninguna de las cosas sin sentido sobre protección de copia DRM, así que puedes leerlos fácilmente en cualquier dispositivo que se soporta.
Aprende más sobre los formatos de Leanpub y dónde puedes leerlos
Top Books
C++ Best Practices
Jason TurnerLevel up your C++, get the tools working for you, eliminate common problems, and move on to more exciting things!
OpenIntro Statistics
David Diez, Christopher Barr, Mine Cetinkaya-Rundel, and OpenIntroA complete foundation for Statistics, also serving as a foundation for Data Science.
Leanpub revenue supports OpenIntro (US-based nonprofit) so we can provide free desk copies to teachers interested in using OpenIntro Statistics in the classroom and expand the project to support free textbooks in other subjects.
More resources: openintro.org.
Functional Design and Architecture
Alexander GraninSoftware Design in Functional Programming, Design Patterns and Practices, Methodologies and Application Architectures. How to build real software in Haskell with less efforts and low risks. The first complete source of knowledge.
Atomic Kotlin
Bruce Eckel and Svetlana IsakovaFor both beginning and experienced programmers! From the author of the multi-award-winning Thinking in C++ and Thinking in Java together with a member of the Kotlin language team comes a book that breaks the concepts into small, easy-to-digest "atoms," along with exercises supported by hints and solutions directly inside IntelliJ IDEA!
R Programming for Data Science
Roger D. PengThis book brings the fundamentals of R programming to you, using the same material developed as part of the industry-leading Johns Hopkins Data Science Specialization. The skills taught in this book will lay the foundation for you to begin your journey learning data science. Printed copies of this book are available through Lulu.
I am a Software Engineer and I am in Charge
Alexis Monville and Michael DoyleI am a Software Engineer and I am in Charge is a real-world, practical book that helps you increase your impact and satisfaction at work no matter who you work with.
In the book, we will follow Sandrine, a fictional character who learns to think in a new way enabling her to take a different course of action.
C++20
Rainer GrimmC++20 is the next big C++ standard after C++11. As C++11 did it, C++20 changes the way we program modern C++. This change is, in particular, due to the big four of C++20: ranges, coroutines, concepts, and modules.
Invest In Digital Health - The Medical Futurist's Guide
Dr. Bertalan MeskoArtificial Intelligence and Digital Health are booming. In this book, we explain why now it's a good time to invest in Digital Health and give recommendations on where to invest by looking at the top 24 technological trends we find the most promising.
Ansible for DevOps
Jeff GeerlingAnsible is a simple, but powerful, server and configuration management tool. Learn to use Ansible effectively, whether you manage one server—or thousands.
The Hundred-Page Machine Learning Book
Andriy BurkovEverything you really need to know in Machine Learning in a hundred pages.
Top Bundles
- #1
Software Architecture for Developers: Volumes 1 & 2 - Technical leadership and communication
2 Books
"Software Architecture for Developers" is a practical and pragmatic guide to modern, lightweight software architecture, specifically aimed at developers. You'll learn:The essence of software architecture.Why the software architecture role should include coding, coaching and collaboration.The things that you really need to think about before... - #2
CCIE Service Provider Ultimate Study Bundle
2 Books
Piotr Jablonski, Lukasz Bromirski, and Nick Russo have joined forces to deliver the only CCIE Service Provider training resource you'll ever need. This bundle contains a detailed and challenging collection of workbook labs, plus an extensively detailed technical reference guide. All of us have earned the CCIE Service Provider certification... - #3
The Future of Digital Health
6 Books
We put together the most popular books from The Medical Futurist to provide a clear picture about the major trends shaping the future of medicine and healthcare. Digital health technologies, artificial intelligence, the future of 20 medical specialties, big pharma, data privacy and how technology giants such as Amazon or Google want to conquer... - #4
Cisco CCNA 200-301 Complet
4 Books
Ce lot comprend les quatre volumes du guide préparation à l'examen de certification Cisco CCNA 200-301. - #5
Modern Management Made Easy
3 Books
Read all three Modern Management Made Easy books. Learn to manage yourself, lead and serve others, and lead the organization. - #6
CCDE Practical Studies (All labs)
3 Books
CCDE lab - #7
Modern C++ by Nicolai Josuttis
2 Books
- #8
"The C++ Standard Library" and "Concurrency with Modern C++"
2 Books
Get my books "The C++ Standard Library" and "Concurrency with Modern C++" in a bundle. The first book gives you the details you should know about the C++ standard library; the second one dives deeper into concurrency with modern C++. In sum, you get more than 600 pages full of modern C++ and about 250 source files presenting the standard library... - #9
Linux Administration Complet
4 Books
Ce lot comprend les quatre volumes du Guide Linux Administration :Linux Administration, Volume 1, Administration fondamentale : Guide pratique de préparation aux examens de certification LPIC 1, Linux Essentials, RHCSA et LFCS. Administration fondamentale. Introduction à Linux. Le Shell. Traitement du texte. Arborescence de fichiers. Sécurité... - #10
Advanced Product Management
3 Books
Get The Art of Strategy, Product Discovery and Lean Product Management with a 20% discount.