Testing Vue.js Components with Jest
暫譯: 使用 Jest 測試 Vue.js 元件

Morales, Alex Jover

  • 出版商: Packt Publishing
  • 出版日期: 2019-10-17
  • 售價: $1,180
  • 貴賓價: 9.5$1,121
  • 語言: 英文
  • 頁數: 88
  • 裝訂: Quality Paper - also called trade paper
  • ISBN: 1839219688
  • ISBN-13: 9781839219689
  • 相關分類: Vue.js
  • 海外代購書籍(需單獨結帳)

買這商品的人也買了...

相關主題

商品描述

Unit testing in modern component-based JavaScript frameworks is not straightforward. You need a test suite that is reliable and runs quickly. Components are connected to one another, and the browser adds a layer of UI, which makes everything inter-dependent while we test components in isolation. Jest is a fully-featured JavaScript testing framework that will do all your work for you.

 

This book shows you how to test Vue.js components easily and take advantage of the fully-featured Jest testing framework with the aid of practical examples. You'll learn the different testing styles and their structures. You'll also explore how your Vue.js components respond to various tests. You'll see how to apply techniques such as snapshot testing, shallow rendering, module dependency mocking, and module aliasing to make your tests smooth and clean.

 

By the end of this book, you'll know all about testing your components by utilizing the features of Jest.

  • Set up a Vue-test project to get started with Jest
  • Unit test your components using techniques such as shallow rendering
  • Gain insights into how to test the reactive parts in the logic of the Vue.js components
  • Explore how to test deeply rendered Vue.js components
  • Perform easy and quick tests with module dependency mocking, module aliasing, and more
  • Know-how and when to use snapshot testing

商品描述(中文翻譯)

單元測試在現代基於組件的 JavaScript 框架中並不簡單。您需要一個可靠且運行快速的測試套件。組件彼此相連,瀏覽器增加了一層 UI,這使得在測試組件時一切都相互依賴,而我們卻希望能夠獨立測試組件。Jest 是一個功能齊全的 JavaScript 測試框架,可以為您完成所有工作。

本書將向您展示如何輕鬆測試 Vue.js 組件,並利用功能齊全的 Jest 測試框架,通過實用的範例來輔助您。您將學習不同的測試風格及其結構。您還將探索您的 Vue.js 組件如何響應各種測試。您將看到如何應用快照測試(snapshot testing)、淺層渲染(shallow rendering)、模組依賴模擬(module dependency mocking)和模組別名(module aliasing)等技術,使您的測試流暢且乾淨。

在本書結束時,您將了解如何利用 Jest 的功能來測試您的組件。

- 設置一個 Vue-test 專案以開始使用 Jest
- 使用淺層渲染等技術對您的組件進行單元測試
- 獲得如何測試 Vue.js 組件邏輯中反應式部分的見解
- 探索如何測試深層渲染的 Vue.js 組件
- 通過模組依賴模擬、模組別名等進行簡單快速的測試
- 知道何時以及如何使用快照測試