Giter Site home page Giter Site logo

cypress-examples's Introduction

@bahmutov/cypress-examples cypress-examples

ci status prettier status deployed status scrape renovate-app badge cypress version

Static site with Cypress examples tested right from the Markdown sources

Live site glebbahmutov.com/cypress-examples/

Benefits

  • single source of truth for tests and HTML pages. No more copy / pasting
  • great development experience with live reload and optimized static build thanks to Vuepress and Prettier formatting
  • excellent text and code comment search thanks to Algolia
  • recipes that are not included in the NPM package but deployed to the static pages

Blog posts

The following blog posts explain how I write Cypress demo tests using Markdown in this repository

You can see the cypress.config.js and plugins.js to learn how cypress-markdown-preprocessor is set tup.

Notes

  • use "function" syntax in <script> tags that need to be live, otherwise Markdown escapes => arrows?!
  • if the HTML block includes the <style> section, put it at the start of the block, otherwise it might get lost

Try published specs

You can run the exported spec files.

  • Start a new project or use an existing project, and add this module as a dev dependency
$ npm i -D @bahmutov/cypress-examples
  • Open or run Cypress and point at the folder inside node_modules
$ npx cypress open --project node_modules/\@bahmutov/cypress-examples/

Spec running

Development

There is a difference between running Markdown files and testing fully exported specs against the built site. To do this all in a single command locally run

npm run dev:export

This command builds the static site, exports the Markdown specs into JavaScript specs, starts local server, and when it responds, starts Cypress.

You can also export all Markdown files into JavaScript, run them locally, and run all E2E tests using the JS specs with:

npm run run:exported

cypress-examples's People

Contributors

bahmutov avatar cypresscecelia avatar marktnoonan avatar mikemcc399 avatar renovate-bot avatar renovate[bot] avatar tugkanboz 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

cypress-examples's Issues

Do not generate docs/index.js file

From docs/index.md

Because the file has not tests, just

/// <reference types="cypress" />
describe('Cypress Examples', () => {
  before(() => {
    cy.visit('http://localhost:5000/cypress-examples/5.6.0/index')
  })
})

Screen Shot 2020-11-17 at 9 34 09 AM

How to show the code under test live better?

In Kitchensink we have bootstrap markup rendered live side by side with the test code

Screen Shot 2020-04-13 at 9 11 29 AM

In these examples, we can show the HTML and optionally mount it too and then do the test

Screen Shot 2020-04-13 at 9 14 33 AM

I really like seeing the HTML markup, since I can understand how the test works better, but I miss having a live element.

Maybe we can style the live element better?
Maybe we can avoid duplication and use the live element as HTML or render one into the other automatically? Maybe it could be a special Vue widget for showing source and live element?

Dependency Dashboard

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

Open

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

Detected dependencies

github-actions
.github/workflows/ci.yml
  • cypress-io/github-action v6
  • cypress-io/github-action v6
  • cypress-io/github-action v6
  • cypress-io/github-action v6
  • cypress-io/github-action v6
.github/workflows/collect-fiddles.yml
.github/workflows/deployed.yml
  • cypress-io/github-action v6
  • cypress-io/github-action v6
.github/workflows/deployment.yml
.github/workflows/prettier.yml
.github/workflows/scrape.yml
  • cypress-io/github-action v6
npm
package.json
  • @vuepress/plugin-docsearch ^2.0.0-beta.61
  • cypress 13.13.1
  • cypress-book 1.5.0
  • cypress-map ^1.40.0
  • cypress-markdown-preprocessor 1.10.10
  • cypress-recurse ^1.31.2
  • start-server-and-test 2.0.4
  • vuepress 2.0.0-beta.61
  • vuepress-plugin-clean-urls 1.1.2
nvm
.nvmrc

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

Add redirects for recipes

So we can give URLs without a version. Right now only the commands and other stuff has redirect HTML pages

Screen Shot 2021-04-14 at 9 45 00 PM

Make sure every page has all existing tests

Look at the Kitchensink repo to make sure our markdown has all tests. Kitchensink online might be behind the tests in the repo

  • Quering
  • Traversal
  • Actions @CypressCecelia
  • Window
  • Viewport
  • Location
  • Navigation
  • Assertions
  • Misc
  • Connectors @CypressCecelia
  • Aliasing
  • Waiting
  • Network Requests
  • Files
  • Cookies
  • Spies, Stubs & Clocks
  • Utilities
  • Cypress API

Replace Kitchensink

Start using this repo instead of cypress-example-kitchensink

  • what to do about all CIs? I say let's split CI examples from Kitchensink examples

Solve tough cases

There are several tests that are harder to solve dynamically

  • location hardcodes full urls
  • cy.root (export solves it)

Can't push to fork in Windows

Running this repository on Windows 11 it is not possible to push to a fork.

"pre-push": "npm run stop-only" fails:

$ git push origin
husky > pre-push (node v12.22.12)

> @bahmutov/[email protected] stop-only 
> stop-only --folder docs --skip docs/.vuepress

Found .only here ๐Ÿ‘Ž
docs/commands/assertions.md:73:// 1 argument - the assertion name only like "be.visible"
docs/commands/assertions.md:361:If we only know a part of the expected attribute, we can first assert the attribute is present, then use an assertion to match its value.
...

The problem is reproducible running
npm run stop-only
directly.
(node 18.13.0 / npm 8.19.3)

npm run stop-only completes without error on Ubuntu 22.04

$ npm run stop-only

> @bahmutov/[email protected] stop-only
> stop-only --folder docs --skip docs/.vuepress


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.

Location: renovate.json
Error type: The renovate configuration file contains some invalid settings
Message: Invalid schedule: 'Invalid schedule: Failed to parse "before 2am every Thursday"'

add cypress-map plugin

I think these recipes would look great if we could show solutions based on cypress-map commands

Collect Git created date for each file

To give accurate timestamps for collected fiddles

$ git log --diff-filter=A --follow --format=%aD -1 -- docs/recipes/own-text.md 
Sun, 22 May 2022 14:24:04 -0400

How to extract into spec files

We have just Markdown files, but to function as Kitchensink examples, we need to extract all fiddles as JavaScript spec files

switch away from set-output command

- name: Set Cypress version ๐ŸŽ
  id: cypress
  run: echo "::set-output name=version::$(node ./src/print-cypress-version)"

- name: Print Cypress version ๐Ÿ–จ
  run: echo "Cypress version is ${{ steps.cypress.outputs.version }}"

Screenshot 2023-03-17 at 10 48 00

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.