Good Cypress Test Syntax

preview_player
Показать описание
This video shows an example of good testing practices where the test confirms the values on the page, rather than computes them from the data shown by the page. The final tests control the data in the application and simply confirm the page works. The tests are short and elegant

// these tests are written to show better testing practices
// 1: do not trust the data from the page
// 2: do not compute the result, know what to expect
// 3: control the page by typing our values
it('checks the page', function () {
})

it('handles empty inputs', function () {
})

it('adds the given numbers', function () {
})

Рекомендации по теме
Комментарии
Автор

Cannot agree more, tests shouldn't be approached the programming way, the Quality Assurance way should always meet expectation of the web application.

TBVnBIX
Автор

"Unfortunately, in this blog post he uses my example..."
It was at this moment he knew....he fucked up :)

dasabaja
Автор

When I see "the test should not compute" - I click a 👍

TuxujPes
Автор

Hmm, but these tests look good and work good only if you know the values a priori 🤔if the values are dynamic you can't live without aliases. Or am I wrong?

Henrijs
Автор

As someone who never knew Ruby and is still somewhat new to JavaScript, I find it humorous that anyone would consider the Ruby syntax more intuitive, especially after you stripped out the aliases from the example. Don't get me wrong; JavaScript is not especially intuitive to the uninitiated, especially since we've evolved to use callbacks everywhere, but with any programming language there's going to be a learning curve.

Also, attempts to make programming languages more readable often result in a complete mess. One such example is Robot Framework (like anything, fine if you're used to it, please don't take this personally) which uses bizarre conventions in order make the syntax resemble English sentences. My personal take: great in theory; an unreadable jumble of special cases in practice.

ja