0% found this document useful (0 votes)
130 views19 pages

Cypress in A Nutshell

This document provides an overview of Cypress, an open source tool for front end testing. It discusses what Cypress is, why it's useful, how to set up and organize tests, write different types of tests using locators and assertions, debug tests, and use fixtures, plugins, custom commands and hooks. Key features highlighted include the test runner, dashboard, large ecosystem, CI integration, automatic waiting, and cross-browser testing capabilities.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
130 views19 pages

Cypress in A Nutshell

This document provides an overview of Cypress, an open source tool for front end testing. It discusses what Cypress is, why it's useful, how to set up and organize tests, write different types of tests using locators and assertions, debug tests, and use fixtures, plugins, custom commands and hooks. Key features highlighted include the test runner, dashboard, large ecosystem, CI integration, automatic waiting, and cross-browser testing capabilities.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Cypress

Automation
What is Cypress?

Cypress is a next generation front end testing tool built for the modern web.
We address the key pain points developers and QA engineers face when
testing modern applications.

We make it possible to:

Set up tests

Write tests

Run tests

Debug Tests

Note: This enables you to write faster, easier and more reliable tests.
Why Cypress?

● Test Runner
● Dashboard service
● Large ecosystem
● CI Provider
● Automatic Waiting
● Cross browser Testing
Setting up Tests

● Installing Cypress
● Writing tests
● Running tests
● Debugging tests
Organizing Tests

● Cypress will automatically scaffold out a


suggested folder structure
● Cypress allows you to configure where
your tests, fixtures, and support files are
located
Working with fixtures

Fixtures are used as external pieces


of static data that can be used by
your tests.
Writing tests

<reference types="cypress" />


describe ( ‘our first suite’ , ( ) => {
it ( ‘login’ , ( ) => {
});
it.only ( ‘login-with-invalid-uid’ , ( ) => {
});
it.skip ( ‘login-with-invalid-pass’ , ( ) => {
});
});
Types Of Locators

● cy.get( ‘<tag name>’ )


● cy.get( ‘#<ID>’ )
● cy.get( ‘.<class name>’ )
● cy.get( ‘[<attribute name>]’ )
● cy.get( ‘[class=”<class name>”]’ )
● cy.get( ‘[<own created attributes>=
“<attributes name>”]”)
Test types

● End-to-end
● Component
● API

Through a large number of official and 3rd party plugins you can write
Cypress allys, visual, email and other types of tests.
Essential functions

● then( )
● wrap( )
● each( )
Navigation in Cypress

● Forward navigation.
● Backward navigation.
Cypress Hooks

● before(() => {})

● beforeEach(() => {})

● afterEach(() => {})

● after(() => {})


Cypress plugins

● Plugins enable you to tap into the Node process running outside of

the browser.

● Installing a plugin [npm install <plugin name> --save-dev]

● Configuring a plugin module.exports = (on, config) => { on('<event>',

(arg1, arg2) => { })}


Cypress custom commands

● Create new commands


Cypress.Commands.add(n
ame, callbackFn)
● Overwrite existing
commands
Cypress.Commands.overw
rite(name, callbackFn)
Assertions

● Bundles the popular Chai assertion library.


● Brings you dozens of powerful assertions for free.
● Helpful extensions for Sinon and jQuery.
● Two types of assertions:
❖ Implicite
❖ Explicit
Implicit assertion

When the assertion applies to the object provided by the parent


chained command, its called an Implicit assertion.

● should( )
● and( )
Explicit assertion

When there is a need to pass an explicit subject for the


assertion, it falls under the category of Explicit assertion.

● expect( )
● assert( )
Page Object Model

POM is a design principle that suggests to keep the objects and methods
separate from the test scripts.
Thank You

- Sagnick Biswas

You might also like