gleb bahmutovThis video shows how one can use cypress-recurse to validate an unknown number of slides in the carousel. We will collect all slide captions, until they start repeating. Bonus: the carousel has animation duration, so the test needs to "wait" until the slide changes. I am using the plugin "cypress-recurse" to implement this Cypress test, http://github.com/bahmutov/cypress-recurse
Test Carousel Captionsgleb bahmutov2025-09-24 | This video shows how one can use cypress-recurse to validate an unknown number of slides in the carousel. We will collect all slide captions, until they start repeating. Bonus: the carousel has animation duration, so the test needs to "wait" until the slide changes. I am using the plugin "cypress-recurse" to implement this Cypress test, http://github.com/bahmutov/cypress-recurseCypress-diff Plugin Demogleb bahmutov2025-10-08 | This video shows the plugin github.com/elaichenkov/cypress-diff that can better format the expected and actual values in the Cypress error messages in case the assertion fails. It does not simply show the values, but highlights the difference in parts of the value.Check Each Image To Have An Alt Attributegleb bahmutov2025-10-07 | This video shows the recipe glebbahmutov.com/cypress-examples/recipes/each-example.html First, it uses a "cy.each" command to confirm the "alt" attribute for each image. Then it shows an alternative solution using jQuery pseudo selectors.Check Page Accessibility Using wick-a11y Plugingleb bahmutov2025-10-07 | This video shows how to confirm the web page is accessible using the Cypress plugin github.com/sclavijosuero/wick-a11y The exercise is part of the course "Testing The Swag Store" from https://cypress.tips/coursesTest The Window.Print() Method From Cypressgleb bahmutov2025-10-03 | You can stub window.print method from your Cypress end-to-end tests to avoid the system print dialog popup. Later, you can confirm that this stubbed method was called in response to the user actions. For more Cypress functional spies and stubs examples, see glebbahmutov.com/cypress-examples/commands/spies-stubs-clocks.htmlConfirming Multiple Data- Values Using DOM Element DataSet Propertygleb bahmutov2025-09-27 | You can check multiple HTML "data-..." properties using the built-in DOM element's "dataset" property. One tip: you would need to convert the value into a plain object. This video shows how to do so with retries enabled. Tip: use cypress-map plugin for easier chains. Find the full "Dataset" recipe at glebbahmutov.com/cypress-examplesAccumulator And Cypress-Recurse Plugingleb bahmutov2025-09-26 | This video shows how to use an accumulator feature in the cypress-recurse plugin command and to "reduce" the strings into a set of slide captions. The refactoring starts with the carousel test shown in the previous video "Test Carousel Captions" youtu.be/sNw86J1M-go and gets rid of the local variable "captions". Find the plugin at github.com/bahmutov/cypress-recursecy.mapChain Custom Command Examplesgleb bahmutov2025-09-16 | cy.mapChain command lets you iterate over data or elements and perform Cypress commands for each item. The yielded results are automatically collected into a single array that is passed to the next Cypress command or assertion. Find this example and more at github.com/bahmutov/cypress-mapConvert An Application Sync Method To Async To Test Its Timing Effectsgleb bahmutov2025-09-12 | This video shows how we can simulate "slow" method call "localStorage.getItem" by converting our application loader into an asynchronous method using "Promise.resolve", then stubbing the "localStorage.getItem" with specific argument using a Cypress Bluebird delayed promise. The loading element now stays for the specific duration and easy to test. Find more Cypress method stubbing examples at glebbahmutov.com/cypress-examples/recipes/stub-call-through.htmlCheck If Cypress Has An Alias Before Getting Itgleb bahmutov2025-09-05 | This video shows a trick to Cypress that involves checking the internal state of the test runner to find if an alias has been defined. During a Cypress test trying to use "cy.get(aliasName)" before the alias has been defined causes an immediate test failure. Luckily, we can check the "Cypress.state().aliases" object to see if it has the property "aliasName" defined before using "cy.get".Custom Cypress HTML Should Look Assertiongleb bahmutov2025-09-04 | Cypress-map plugin github.com/bahmutov/cypress-map has the new "should look (html)" assertion that verifies partial HTML tree against the current subject. Check the video for how it works and how powerful it can work. The full recipe is at glebbahmutov.com/cypress-examplesThe Difference Between Cypress Commands cy.find And cy.filtergleb bahmutov2025-09-03 | This video shows the difference between cy.find and cy.filter commands using a list example. In short: cy.filter filters the current subject elements, while cy.find returns new child elements found from the current subject. Find the full recipe at glebbahmutov.com/cypress-examplesUse cy.filter Command To Filter Elements By Child Element Presencegleb bahmutov2025-08-30 | We can use the cy.filter command to filter DOM elements by the presence of some child elements. For example, to find all LI elements that have an element inside with class "new", we can do the following (this example also verifies the element's own text)
// confirm 2 new elements cy.get('li').filter(':has(.new)').should('have.length', 2) // confirm the elements without "new" label // have specific tet cy.get('li') .filter(':not(:has(.new))') .map('childNodes.0.nodeValue') .mapInvoke('trim') .should('deep.equal', ['Grapes', 'Pears'])
Find this recipe at glebbahmutov.com/cypress-examplesCypress cy.filter Command Attribute Examplesgleb bahmutov2025-08-30 | This video shows using "cy.filter" command with attribute selector, plus ":not" pseudo-selector and existence assertions. Find the full recipe at glebbahmutov.com/cypress-examplesCypress v15 Release With The New Experimental Studio: First Lookgleb bahmutov2025-08-20 | Cypress v15 release http://on.cypress.io/changelog#15-0-0 has the revamped experimental studio with built-in editor support cypress.io/blog/cypress-15-the-foundation-for-whats-next I take this for a spin and come out unimpressed. Using VSCode with inline Copilot suggestions is a much better and faster way of writing new tests, in my opinion. Check out my courses on "Cypress + Copilot" and "Cypress + Cursor" for my AI suggestions https://cypress.tips/coursesConditional Detailsgleb bahmutov2025-08-14 | This video shows an example of conditional testing: - if the details element is open, close it and confirm the text is removed from DOM - if the details element is closed, open it and confirm the text is visible to the user Find the full recipe at glebbahmutov.com/cypress-examplesText Variantsgleb bahmutov2025-08-13 | This video shows how I check the text inside an element if that text could be one of several variants (for example, it could be either the full user name or a short display name). Find the full recipe at glebbahmutov.com/cypress-examplesThe Difference Between cy.get And cy.find Commandsgleb bahmutov2025-08-05 | People often use "cy.get" command inside a longer chain of Cypress command - but they meant to use the cy.find command. - cy.get is the top-level parent command which starts to search _again_ from the top of the document - cy.find is the child command that searches only inside the current subject Find this recipe and lots more Cypress examples at glebbahmutov.com/cypress-examplesPartial Value Matchgleb bahmutov2025-07-09 | This video shows how one can verify a _part_ of the input element's value using Cypress syntax. We can get the value (with retries) and match the string expression using plain Chai assertions. Find the full recipe at glebbahmutov.com/cypress-examplesGitHub Copilot Instructions For Pull Request Reviewsgleb bahmutov2025-06-26 | This video shows my Copilot instructions file that helps review the code both locally in VSCode and at github.com when requesting a copilot review. In my specific case, the review ensures that all front-end elements showing application data, like a username have meaningful "data-testid" attributes following the glebbahmutov.com/blog/how-i-add-test-ids advice.
Find more Copilot tips and tricks in my course at https://cypress.tips/coursesChai-each Plugin Examplegleb bahmutov2025-06-22 | This video shows how we can test each string against a regular expression using the chai-each plugin shorthand notation. Find the full source code at glebbahmutov.com/cypress-examples
The full example gets all shown LI elements, extracts the inner text from each LI element, then verifies that each string matches a regular expression.Text Changes And The Static Aliasgleb bahmutov2025-06-20 | This video shows how to confirm that the application changes the element's text after clicking on the button. It also shows a subtle bug when using an alias to store the original text: the alias should have the option "type: static" to avoid re-evaluating the query and getting the modified text. Find the full solution code at my site glebbahmutov.com/cypress-examplesFind One Element With Exact Text Matchgleb bahmutov2025-06-12 | This video shows how one can find an element with precise text in Cypress tests You can use "cy.contains" query with a regular expression or "cy.findOne" helper from cypress-map plugin. Find the full recipe at glebbahmutov.com/cypress-examplesArray Includes A Primitive Value And Checking Multiple Network Callsgleb bahmutov2025-06-04 | This video shows 3 Cypress tests: - checking if an array contains the given primitive value with retries - checking multiple intercepts - checking multiple intercepts with flattened objects Find the full recipe at glebbahmutov.com/cypress-examples/recipes/array-includes-a-primitive-value.html Find Cypress network testing course at https://cypress.tips/courses/network-testingMock The Location Href Propertygleb bahmutov2025-05-20 | This video shows how we can "mock" the protected browser object "location" and intercept the assignment "location.href = ..." made by the application. Find the full example in the blog post glebbahmutov.com/blog/mock-location-href The example source code at github.com/bahmutov/with-window If you want to learn more about Cypress network testing, check out the online course https://cypress.tips/courses/network-testingCheck CSS Resourcesgleb bahmutov2025-05-16 | This video shows how to check if the page loads every CSS resource successfully using Cypress E2E test. Since we don't know the exact number of CSS resources, we must check all of them. We can spy on "*.css" resources and check the state and status code of each intercepted call. I am using plugin github.com/bahmutov/cypress-map to write a shorter test. Find the full lesson in the course "Cypress Network Testing Exercises" online at https://cypress.tips/courses/network-testingChecking HEAD link elementsgleb bahmutov2025-05-13 | This video shows a Cypress E2E test that checks multiple "link" elements - the `rel` attribute value should be restricted to certain values - the `crossorigin` attribute should always equal to `anonymous` - the `href` value should be a valid URL Find the full source code at glebbahmutov.com/cypress-examplesSpy On Constructor Functiongleb bahmutov2025-05-06 | This video shows how to use Sinon and Sinon-Chai bundled with Cypress to verify the application code calls "new Constructor..." function. Find the full recipe at glebbahmutov.com/cypress-examplesCypress Horizontal Scroll Examplegleb bahmutov2025-05-02 | This video shows how to check the horizontal scroll position and how to change it using the Cypress command cy.scrollTo Find the full recipe at my "Cypress Examples" site glebbahmutov.com/cypress-examplesIntroducing The cy.elements Query Command From Cypress-map Plugingleb bahmutov2025-04-22 | Often we need to find a list of elements on the page and then check the text contents of sub children in each one. This is what the custom query command "cy.elements" from the plugin cypress-map was meant to do: just give it the parent selector plus the children selectors and it yields an array of arrays of strings you can check. See the plugin docs at github.com/bahmutov/cypress-mapAdd Page HTML To Fix A Cypress Test Error Using Cursor AIgleb bahmutov2025-04-19 | This is a small tip for Cursor / Copilot / other AI users. When dealing with a Cypress error, add the current rendered page HTML to the prompt to quickly find the source of the error. This video is one of the many videos from my hands-on course "Cursor AI For Cypress Testing" at https://cypress.tips/coursesUse GitHub Copilot Agent To Add JSConfig File For Cypress Specsgleb bahmutov2025-04-15 | This video shows the Copilot Agent mode replacing all "reference types" comments in the Cypress specs with "jsconfig.json" file that loads the 3rd party types. For more, see my online course "Write Cypress Tests Using GitHub Copilot" at https://cypress.tips/courses Also read the blog post "Convert Cypress Specs from JavaScript to TypeScript" glebbahmutov.com/blog/cypress-js-to-tsGitHub Copilot Agent Modegleb bahmutov2025-04-10 | This video shows code and Cypress test refactoring across multiple files using the GitHub Copilot experimental Agent mode. Find more "Cypress and Copilot" information and lessons in my course at https://cypress.tips/coursesDemo Of The New cy.press Command In Cypress v14.3.0gleb bahmutov2025-04-09 | Cypress v14.3.0 includes the new cy.press command that send the native "Tab" key press to the window and lets you navigate the DOM elements in the "tabindex" order. In this video, I write a Cypress test that fills the login form using "cy.press" and "should be focused" assertions. - source code at github.com/bahmutov/cypress-press-example - Cursor and network testing courses at https://cypress.tips/coursesAdd Number Of Team Players Cypress Plus Cursor Examplegleb bahmutov2025-04-04 | In this video, I add a small feature to my "Gametime" application using Cypress test-driven development and Cursor AI. Find the pull request at github.com/bahmutov/gametime/pull/34 If you want to learn "Cypress + Cursor", check out my online course at https://cypress.tips/courses99% Code Coverage In 9 Minutesgleb bahmutov2025-04-02 | This video shows how I combine plugins github.com/bahmutov/cypress-code-coverage and github.com/bahmutov/cypress-rest-easy to instrument an app on the fly and write Cypress tests following the code coverage report. Cursor IDE provides a boost of speed by correctly inferring the tests I want to write. Find the full source code in the repo github.com/bahmutov/called-urls-examples/tree/demo-cc. Find an entire course on writing Cypress tests using Cursor at my site https://cypress.tips/coursescypress-rest-easy Plugin Introductiongleb bahmutov2025-03-27 | This video shows the cypress-rest-easy plugin in action, serving a mock REST api right inside a Cypress end-to-end test. Find the plugin at github.com/bahmutov/cypress-rest-easy and a blog post about it at glebbahmutov.com/blog/rest-easyGitHub Copilot Vs Cursor AI: Change Comments Into Commands Examplegleb bahmutov2025-03-21 | In this video I am showing how VSCode GH Copilot helps me modify several comments into log calls. Then I show the same refactoring using Cursor AI. What we want to do in the spec file is change each comment into a cy.log command: // comment here cy.log("comment here") GH Copilot does not really help, while Cursor AI makes this transformation super quick. I plan to look into Cursor AI in the future, so stay tuned: - youtube.com/glebbahmutov - linkedin.com/in/bahmutov - https://bsky.app/profile/bahmutov.bsky.social - https://cypress.tips/coursesTesting Nested TanStack Routegleb bahmutov2025-03-21 | This video shows how one can test a nested route in TanStack using the same fixture data. We can define multiple Cypress intercepts, one to load the entire list, another to load a particular object. Find the full source code at github.com/bahmutov/my-router-appTesting Data Preload In TanStack Routergleb bahmutov2025-03-17 | TanStack router preloads the component's data by default when the user hovers over the link to the component. This test confirms the network request on hover. Find the full source code in github.com/bahmutov/my-router-appTest How TanStack Router Refreshes Stale Datagleb bahmutov2025-03-17 | This video shows an E2E Cypress test that confirms that TanStack router does not request the data update if the data has been fetched within its "staleTime" parameter. The test also confirms that if the data is older than the "staleTime" parameter, TanStack makes a network call to refresh it. Tip: we use cy.clock and cy.tick commands to fast forward the application clock to make the test run within 1 second. Find the test at github.com/bahmutov/my-router-app and more Cypress network testing examples in my course https://cypress.tips/courses/network-testingTesting The TanStack Router Stale Then Revalidate Fetching Using Cypressgleb bahmutov2025-03-16 | This video show how you can confirm that the Tanstack Router is showing the stale data for a route component while fetching the new data from the server. Find the full source code at github.com/bahmutov/my-router-app and if you want to practice Cypress network testing commands, check out my online course https://cypress.tips/courses/network-testingStub The Method That Returns The Data To TanStack Routergleb bahmutov2025-03-15 | Cypress E2E tests can mock network calls or method calls, as long as we have the reference to the object being called. In this example, I mock the "EmployeesAPI.get" method my route component is making to load a list of employees. Find the full source code in the repo github.com/bahmutov/my-router-app and see more "cy.stub" examples at glebbahmutov.com/cypress-examples/commands/spies-stubs-clocks.htmlUse Cypress Network Stub With TanStack Routergleb bahmutov2025-03-14 | This video shows how you can use Cypress E2E test and cy.intercept network stub to supply data to the TanStack Router component. Such test avoids a need for a separate "local API" server. Find more such tests for this application at github.com/bahmutov/my-router-app and more Cypress network testing lessons in my course https://cypress.tips/courses/network-testingcypress-plugin-steps Demogleb bahmutov2025-03-13 | This video shows the plugin npmjs.com/package/cypress-plugin-steps in action: installation, defining sections and steps, and how the plugin shows the steps in the Command Log. Bonus: the plugin adds text with the completed steps to the error message if the test fails. Plugin made by @filip_hric For more about this plugin, read the blog post "Cypress Steps Plugin" glebbahmutov.com/blog/cypress-steps-plugin For more videos on Cypress plugins, check out my course https://cypress.tips/courses/cypress-pluginsCypress realHover Vs jQuery Show Methodgleb bahmutov2025-03-11 | If you need to click on an element that becomes visible on hover, you can either use the "cy.realHover" native command from the plugin github.com/dmtrKovalenko/cypress-real-events or call the jQuery "show" method to make the element visible and clickable.Custom Should Read Assertion From Cypress-map Plugingleb bahmutov2025-03-11 | This video shows a custom "read" assertion that checks the text of a single or multiple elements using strings or regular expressions: cy.get('li').should('read', [ 'Write code', 'Add tests', /^Pay \$\d+ fine$/, ]) The assertion is part of my "cypress-map" plugin github.com/bahmutov/cypress-map and the full recipe I am showing in this video is at glebbahmutov.com/cypress-examples/recipes/should-read.htmlCypress Custom Commands With Multiple DOM Snapshotsgleb bahmutov2025-03-09 | This video shows how to write Cypress custom commands with multiple DOM snapshots showing the app in different stages. We will use "Cypress.log" to create a log instance and then call "log.snapshot" to create instant DOM snapshots. Two things to remember: - log.snapshot is a synchronous method call, so we want to make sure it runs after the previous Cypress command finishes. Use "cy.then(callback)" for this - call log.end to signal the official end to the custom command logging Find the full recipe at glebbahmutov.com/cypress-examplesTest CSS Property :user-invalid Using Cypress E2E Testgleb bahmutov2025-03-04 | This video shows the new CSS property ":user-invalid" that is available in the latest browsers. This property is turned on when the user has interacted with an input field, removed the focus, and the field does not pass its validations. - more about the CSS property at developer.mozilla.org/en-US/docs/Web/CSS/:user-invalid - this full example at glebbahmutov.com/cypress-examples/recipes/user-invalid-form-validation.html part of glebbahmutov.com/cypress-examples - I used the "cypress-real-events" plugin to type into the field to trigger the CSS state github.com/dmtrKovalenko/cypress-real-events - to get the "::before" CSS object, I used helper queries from the github.com/bahmutov/cypress-map pluginThe Possess Assertion From cypress-map Plugingleb bahmutov2025-02-08 | This video shows how you can validate a complex object using the "possess" assertion from the plugin github.com/bahmutov/cypress-map Find the full source code at glebbahmutov.com/cypress-examples/recipes/dont-change-the-subject.html