Gleb Bahmutov PRO
JavaScript ninja, image processing expert, software quality fanatic
Gleb Bahmutov
Sr Director of Engineering
Andrae Ambrose
Enterprise Software Developer
Album Get Rich or Die Tryin' in 2009
Fun fact: the song has 18 + 4 = 22 questions
https://www.billboard.com/articles/columns/hip-hop/8098488/50-cent-21-questions-lyrics
expect(sum(2, 3)).to.equal(5)
cy.get('#submit').click()
cy.contains('Success!').should('be.visible')
expect(sum(2, 3)).to.equal(sum(4, 1))
🚨
cy.get('#submit').should(_ => {})
.then($button => {
if ($button.length) {
cy.wrap($button).click()
cy.contains('Success!')
.should('be.visible')
}
})
Logic in the test itself 🚩
expect(sum(2, 3)).to.equal(5)
expect(sum(2, 3)).to.equal(5)
// maybe?
expect(sum(200, 300)).to.equal(500)
// possibly?
expect(sum(-2, -3)).to.equal(-5)
// unknown
expect(sum('two', 'three')).to.equal('five')
expect(sum(2)) // ?
A: With the code
B: In a separate repo
C: No-code solution
expect(result).to.equal(5)
const result = sum(2, 3)
import {sum} from './math'
cy.contains('Next').click()
cy.log('Second page')
cy.contains('h1', 'Book Hotel 2')
cy.window()
.its('app.state')
.should('deep.equal', startOfSecondPageState)
cy.window()
.its('app')
.invoke('setState', startOfSecondPageState)
cy.log('Second page')
cy.contains('h1', 'Book Hotel 2')
cy.get('#username').type('JoeSmith', typeOptions)
A Developer should run his/her tests on every commit
Test early, test often.
Repetition (DRY your code!)
//original spec
Cypress.Commands.add("loadHomePage", () => {
cy.get(`[data-testid-SearchInput]`).should("be.visible");
cy.get(`[data-testid-SignupButton]`).should("be.visible");
cy.get(`[data-testid-LoginButton]`).should("be.visible");
cy.get(`[data-testid-CategoryNav]`).should("be.visible");
});
//Refactored
Cypress.Commands.add("loadHomePage", () => {
const homePageSelectors = [
"SearchInput", "SignupButton", "LoginButton", "CategoryNav",];
homePageSelectors.forEach((testid) => {
cy.get(`[data-testid=${testid}]`).should("be.visible");
});
});
<button
id="main"
class="btn btn-large"
name="submission"
role="button"
data-cy="submit"
>
Submit
</button>
FLAKE
YES AND NO!
Tool X vs Tool Y
Running the most primitive "visit X" test case
⚠️ 🚩 ⚠️ 🚩 ⚠️ 🚩 ⚠️ 🚩 ⚠️ 🚩 ⚠️ 🚩 ⚠️ 🚩 ⚠️ 🚩 ⚠️ 🚩 ⚠️ 🚩 ⚠️ 🚩 ⚠️ 🚩 ⚠️ 🚩 ⚠️ 🚩 ⚠️ 🚩 ⚠️ 🚩
⚠️ 🚩 ⚠️ 🚩 ⚠️ 🚩 ⚠️ 🚩 ⚠️ 🚩 ⚠️ 🚩 ⚠️ 🚩 ⚠️ 🚩 ⚠️ 🚩 ⚠️ 🚩 ⚠️ 🚩 ⚠️ 🚩 ⚠️ 🚩 ⚠️ 🚩 ⚠️ 🚩 ⚠️ 🚩
⚠️
🚩
⚠️
🚩
⚠️
🚩
⚠️
🚩
⚠️
🚩
⚠️
🚩
⚠️
🚩
⚠️
🚩
⚠️
🚩
⚠️
🚩
⚠️
🚩
⚠️
🚩
⚠️
🚩
Installation
Writing tests
Running tests
Debugging tests
Maintenance
Installation
Writing tests
Running tests
Debugging tests
Maintenance
Documentation
Training
Prev experience
Installation
Writing tests
Running tests
Debugging tests
Maintenance
Documentation
Training
Prev experience
CI Setup
Installation
Writing tests
Running tests
Debugging tests
Maintenance
Documentation
Training
Prev experience
CI Setup
The test runner
Installation
Writing tests
Running tests
Debugging tests
Maintenance
Installation
Writing tests
Running tests
Debugging tests
Maintenance
Installation
Writing tests
Running tests
Debugging tests
Maintenance
Installation
Writing tests
Running tests
Debugging tests
Maintenance
Installation
Writing tests
Running tests
Debugging tests
Maintenance
source: TestJSSummit presentation by Roman Sandler and Gleb Bahmutov https://slides.com/bahmutov/pyramid-testjsummit
Speak Management's native language - Metrics and Money 📈 💰
Will Klein
"The problem is not that testing is the bottleneck. The problem is that you don’t know what’s in the bottle. That’s a problem that testing addresses."
— Michael Bolton, author, “Rapid Software Testing”
By Gleb Bahmutov
In the pursuit of building rock-solid end-to-end testing suites, there are many variables that need to be decided in order to maintain a consistent testing environment. If left undefined, these variables can lead to endless wasted cycles spent on the effects, rather than simply eliminating the root cause. Presented at EnterpriseNG Dec 2021, video at https://www.youtube.com/watch?v=_7SJ_sMAols
JavaScript ninja, image processing expert, software quality fanatic