No Reminders, Part II

No Reminders, Part II

Here is the original No Reminders blog post. There is more about the song there.

I have a two-part job today

Really I think that it would be better for me to move on with the actual testing for Cypress.

But I wanted to read through these two docs:
And I know that I should probably do this so here I am. Even though coding is probably more important than reading. 

Maybe I'll miss something if I don't read it so let me do this please anyway.

Let's Start with the "Intro to Cypress" bit first...

Who knows how it will go...

In Cypress, you can query elements by SELECTOR...

  • cy.get('.my-selector')
"Cypress leverages jQuery's powerful selector engine to help make tests familiar and readable for modern web developers."

Querying by text content

You can use cy.contains to find an element by its text content. "This is helpful when writing tests from the perspective of a user interacting with your app."

They don't know about the classes of individual elements or the types. They just can only see, what they can see.

Cypress Gives Your app "a window of time to finish whatever it may be doing"

This is known as a "timeout". Cypress will give your web app a certain amount of time to load stuff before saying that it has "failed". The drawback of this is that it may take your tests longer to fail if they were gonna fail anyway - so only use as long as you need!!! 

A screenshot from the first Cypress doc.
A screenshot from the first Cypress doc.

Cypress automatically retries its tests, until either:
  • The desired element is found.
  • A set timeout is reached.

Assertions

Assertions.

Assertions.


"Assertions let you do things like ensuring an element is visible or has a particular attribute."

"Assertions are commands that ENABLE YOU TO DESCRIBE THE DESIRED STATE OF YOUR APPLICATION. CYPRESS WILL AUTOMATICALLY WAIT UNTIL LYOUR ELEMENTS REACH THIS STATE, OR FAIL THE TEST IF THE ASSERTIONS DON'T PASS. Here's a quick look at assertions in action:"


"In each of these examples, it's important to note that Cypress will automatically wait until these assertions pass. 

This prevents you from having to know or care about the PRECISE MOMENT your elements eventually DO reach this state."

But WHY?

Subject Management

A new Cypress chain always starts with cy.[command] .

Chat GPT says: "Each cypress command yields a value, establishing what commands can be called next." The website says: "What is yielded by the command establishes what other commands can be called next (chained)".




And then there's this. 

This relates pretty well to some of the tests I looked at with my Engineering Manager this morning :)))



???!!

Core Concept

"Cypress commands to not return their subjects, they yield them."







I UNDERSTAND NOTHING. OMG. I UNDERSTAND NOTHING RIGHT NOW. OMG, OMG OH MY GOODNESS.

I am LOST. 

I give up on Aliases at least for now. Hey man. At least I know that they exist...

??!

EH?

Eh?


I think that I am going on holiday... right now.

The Cypress Command Queue

That is something to read about... from another day.

Assertions

From ChatGPT: 

Assertions describe the desired state of elements, objects, and the application in Cypress.

Cypress stands out with automatic retry of assertions, acting like guards ensuring the application reaches the expected state.

Or as this picture from the docs says:

Or this:

Examples with Pseudocode

The docs use lots of examples of pseudocode for showing how you can assert, before actually translating that into tests.

When To Assert

"Sometimes the best test may make no assertions at all." Or as Chat says: "Not all tests need explicit assertions".


Okay so... go on...

Timeouts... 

There's more on timeouts there... and about stuff like that... but I can't do it. I just can't do it.

Writing Your First Test in Cypress

Okay I am exhausted let me look at ChatGPT first. Oh no it's an actual tutorial oh no you want me to do it. ARRRGH.


Then this:




Comments

Popular posts from this blog

Hello World

Yosemite

Two Lines of Thought, Makes Me Wonder What I'm Missing