Giter Site home page Giter Site logo

cypress-io / cypress-example-todomvc Goto Github PK

View Code? Open in Web Editor NEW
249.0 249.0 485.0 1.41 MB

The official TodoMVC tests written in Cypress.

License: MIT License

HTML 1.93% JavaScript 61.13% TypeScript 36.95%
automated-tests circleci cypress e2e-tests react todomvc travis-ci

cypress-example-todomvc's Introduction

TodoMVC Circle CI

This repo contains an example React App, with the tests written in Cypress.

Additionally this example app is configured to run tests in Circle CI and Travis CI.

The tests are written to be directly compared to the official TodoMVC tests.

Each test covers the same functionality found in the official TodoMVC tests but utilizes the Cypress API.

The tests are heavily commented to ease you into the Cypress API.

You can find the official TodoMVC tests we are comparing to here. And here. And here.

Help + Testing

The steps below will take you all the way through Cypress. It is assumed you have nothing installed except for node + git.

If you get stuck, here is more help:

1. Install Cypress

Follow these instructions to install Cypress.

2. Fork this repo

If you want to experiment with running this project in Continous Integration, you'll need to fork it first.

After forking this project in Github, run these commands:

## clone this repo to a local directory
git clone https://github.com/<your-username>/cypress-example-todomvc.git

## cd into the cloned repo
cd cypress-example-todomvc

## install the node_modules
npm install

## start the local webserver
npm start

The npm start script will spawn a webserver on port 8888 which hosts the TodoMVC app.

You can verify this by opening your browser and navigating to: http://localhost:8888

You should see the TodoMVC app up and running. We are now ready to run Cypress tests.

3. Add the project to Cypress

Follow these instructions to add the project to Cypress.

4. Run in Continuous Integration

Follow these instructions to run the tests in CI.

Cypress IntelliSense

If you use modern IDE that supports TypeScript (like VSCode), you can benefit from Cypress type declarations included with the cypress NPM module. Just add @ts-check to the spec file and configure "dummy" tsconfig.json file and see IntelliSense over cy.<something> commands.

cy.type IntelliSense

Custom commands

This project also adds several custom commands in cypress/support/commands.js. They are useful to create one or more default todos from the tests.

it('should append new items to the bottom of the list', function () {
  cy.createDefaultTodos().as('todos')
  // more test commands
})

To let TypeScript compiler know that we have added a custom command and have IntelliSense working, I have described the type signature of the custom command in file cypress/support/index.d.ts. Here is how this file looks; the type signatures should match the arguments custom commands expect.

/// <reference types="cypress" />

declare namespace Cypress {
  interface Chainable<Subject> {
    /**
     * Create several Todo items via UI
     * @example
     * cy.createDefaultTodos()
     */
    createDefaultTodos(): Chainable<any>
    /**
     * Creates one Todo using UI
     * @example
     * cy.createTodo('new item')
     */
    createTodo(title: string): Chainable<any>
  }
}

To include the new ".d.ts" file into IntelliSense, I could update tsconfig.json or I could add another special comment to the JavaScript spec files - /// <reference types="...>.

// type definitions for Cypress object "cy"
/// <reference types="cypress" />

// type definitions for custom commands like "createDefaultTodos"
// will resolve to "cypress/support/index.d.ts"
/// <reference types="../support" />

Related: IntelliSense for custom Chai assertions added to Cypress

Support

If you find errors in the type documentation, please open an issue

You can also ask questions in our chat channel

cypress-example-todomvc's People

Contributors

atofstryker avatar bahmutov avatar bluewinds avatar brian-mann avatar chrisbreiding avatar codersjj avatar doodlewind avatar flotwig avatar greenkeeper[bot] avatar jennifer-shehane avatar kuceb avatar mike-plummer avatar mikemcc399 avatar mjhenkes avatar mschile avatar renovate-bot avatar renovate[bot] avatar ryanthemanuel avatar sevkioruc avatar zachjw34 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cypress-example-todomvc's Issues

Explain or allow connecting React dev tools to the application under test

Using a hook we can point React dev tools (separate Chrome extension) but they do not align very well, plus keep adding new nodes

<script>
		if (window.Cypress) {
      // this allows React DevTools to work in an iframe
      // (if we're in Cypress running our app)
      __REACT_DEVTOOLS_GLOBAL_HOOK__ = parent.__REACT_DEVTOOLS_GLOBAL_HOOK__
    }
</script>

screen shot 2018-04-26 at 2 24 25 pm

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Repository problems

These problems occurred while renovating this repository. View logs.

  • WARN: Found renovate config warnings

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

github-actions
.github/workflows/add-issue-to-triage-board.yml
.github/workflows/main.yml
  • cypress-io/github-action v5
.github/workflows/triage-closed-issue-comment.yml
nodenv
.node-version
npm
package.json
  • director ^1.2.0
  • todomvc-app-css ^2.0.0
  • todomvc-common 88b7c6359ad4a5097312d8b2a21dd539ce9f4446
  • axe-core 4.7.2
  • cypress 13.8.0
  • cypress-axe 1.5.0
  • eslint 7.32.0
  • eslint-plugin-cypress-dev 3.0.0
  • eslint-plugin-mocha 5.3.0
  • typescript 5.4.5

  • Check this box to trigger a request for Renovate to run again on this repository

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

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.