Company
Date Published
Author
Gleb Bahmutov
Word count
2770
Language
English
Hacker News points
None

Summary

The blog post by Gleb Bahmutov provides an in-depth guide on using Cypress to test native HTML `<select>` elements and the popular Select2 library, which enhances these elements with additional HTML markup. It explains how to utilize the Cypress `.select` command to interact with single and multiple value `<select>` elements, highlighting the need for deep equality checks when verifying selected values. The post also covers how Select2 modifies the original `<select>` element, making it necessary to use the `force: true` option to interact with it through Cypress. Additionally, it demonstrates techniques for selecting values by typing, handling multiple selections, removing items, and programmatically retrieving selected items using Select2's API. The blog emphasizes understanding the additional markup introduced by Select2 for effective testing, providing practical examples and solutions for overcoming challenges such as retry-ability issues when fetching data via AJAX.