Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering Angular Test-Driven Development

You're reading from   Mastering Angular Test-Driven Development Build high-quality Angular apps with step-by-step instructions and practical examples

Arrow left icon
Product type Paperback
Published in Oct 2024
Publisher Packt
ISBN-13 9781805126089
Length 246 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Ezéchiel Amen AGBLA Ezéchiel Amen AGBLA
Author Profile Icon Ezéchiel Amen AGBLA
Ezéchiel Amen AGBLA
Arrow right icon
View More author details
Toc

Table of Contents (18) Chapters Close

Preface 1. Part 1: Getting Started with Test-Driven Development in Angular
2. Chapter 1: Taking Your First Steps with TDD FREE CHAPTER 3. Chapter 2: Using Jasmine and Karma to Test Angular Applications 4. Part 2: Writing Effective Unit Tests
5. Chapter 3: Writing Effective Unit Tests for Angular Components, Services, and Directives 6. Chapter 4: Mocking and Stubbing Dependencies in Angular Tests 7. Chapter 5: Testing Angular Pipes, Forms, and Reactive Programming 8. Part 3: End-to-End Testing
9. Chapter 6: Exploring End-to-End Testing with Protractor, Cypress, and Playwright 10. Chapter 7: Understanding Cypress and its Role in End-to-End Tests for Web Applications 11. Chapter 8: Writing Effective End-to-End Component Tests with Cypress 12. Part 4: Continuous Integration and Continuous Deployment for Angular Applications
13. Chapter 9: Understanding Continuous Integration and Continuous Deployment (CI/CD) 14. Chapter 10: Best Practices and Patterns for Angular TDD 15. Chapter 11: Refactoring and Improving Angular Code through TDD 16. Index 17. Other Books You May Enjoy

Writing your first E2E test

Once Cypress has been properly configured for E2E testing, we can get down to business. Let’s take a look at how to write our first E2E test:

  1. Now that Cypress is installed and configured, you can start writing your first test. You can click on Create new spec in this interface as shown in Figure 7.11:
Figure 7.11 – Spec creation interface in Cypress

Figure 7.11 – Spec creation interface in Cypress

  1. After doing that, you can see in Figure 7.12 a new file named spec.cy.ts, created in the e2e folder of your project’s cypress folder:

Figure 7.12 – Spec file

Figure 7.12 – Spec file

This file contains the following:

Figure 7.13 – The source code of our spec file

Figure 7.13 – The source code of our spec file

  1. Now, you may be faced with a surprise when you return to the browser where the E2E test is launched as shown in Figure 7.14:
Figure 7.14 – The E2E test failed due to a compilation error

Figure 7.14 – The E2E test failed due to a compilation error...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image