Giter VIP home page Giter VIP logo

cypress-workshop-epitech's Introduction

cypress-workshop-Epitech

Installing

npm version

Install Cypress for Mac, Linux, or Windows, then get started.

cd /your/project/path

then

npm install cypress --save-dev

or

yarn add cypress --dev

Make sure that you have already run npm init or have a node_modules folder or package.json file in the root of your project to ensure cypress is installed in the correct directory.

Discover Cypress

Open cypress with the following command inside your project file :

node_modules/.bin/cypress open

then, if it's your first time, you must see the message :

➜  cypress-workshop-Epitech git:(main) ✗ node_modules/.bin/cypress open
It looks like this is your first time using Cypress: 9.2.1

✔  Verified Cypress! /Users/your-name/Library/Caches/Cypress/9.2.1/Cypress.app

Opening Cypress...

Now, check some sample test files that demonstrate key Cypress concepts to help you get started.

Writing Your First Test

Add a test file

Assuming you've successfully installed the Test Runner and opened the Cypress app, now it's time to write our first test. We're going to:

  • Create a sample_spec.js file.
  • Watch Cypress update our list of specs.
  • Launch the Cypress Test Runner.

Let's create a new file in the cypress/integration folder that was created for us:

touch {your_project}/cypress/integration/sample_spec.js

Once we've created that file, we should see the Cypress Test Runner immediately display it in the list of Integration Tests. Cypress monitors your spec files for any changes and automatically displays any changes.

Even though we haven't written any tests yet - that's okay - let's click on sample_spec.js and watch Cypress launch your browser.

Step 1 - Visit a page

describe('My First Test', () => {
  it('Visits the Kitchen Sink', () => {
    cy.visit('https://example.cypress.io')
  })
})

Step 2 - Query for an element

describe('My First Test', () => {
  it('Visits the Kitchen Sink', () => {
    cy.visit('https://example.cypress.io')
    
    cy.contains('type')
  })
})

Step 3 - Click an element

describe('My First Test', () => {
  it('Visits the Kitchen Sink', () => {
    cy.visit('https://example.cypress.io')
    
    cy.contains('type').click()
  })
})

Step 4 - Make an assertion

describe('My First Test', () => {
  it('Visits the Kitchen Sink', () => {
    cy.visit('https://example.cypress.io')
    
    cy.contains('type').click()

    // Should be on a new URL which includes '/commands/actions'
    cy.url().should('include', '/commands/actions')

    // Get an input, type into it and verify that the value has been updated
    cy.get('.action-email')
      .type('[email protected]')
      .should('have.value', '[email protected]')
  })
})

Special commands

In addition to having a helpful UI, there are also special commands dedicated to the task of debugging.

For instance there is:

  • cy.pause()
  • cy.debug()

Youssra El-Ajli : [email protected]
Hugo Suzanne : [email protected]

cypress-workshop-epitech's People

Contributors

kurepu06 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.