From cc13866e55bd28e1d1323ba6d498d85204f292b5 Mon Sep 17 00:00:00 2001 From: Amir Rustamzadeh <334337+amirrustam@users.noreply.github.com> Date: Mon, 6 Jun 2022 14:02:39 -0700 Subject: [PATCH] Release v10 testing branch (#750) Co-authored-by: Ben Alman Co-authored-by: Paul Jaffre Co-authored-by: Jennifer Shehane Co-authored-by: Kevin Old Co-authored-by: ElevateBart Co-authored-by: Tyler Biethman --- .circleci/config.yml | 22 +-- README.md | 12 +- appveyor.yml | 43 ----- examples/blogs__a11y/README.md | 6 +- examples/blogs__a11y/cypress.config.js | 3 + examples/blogs__a11y/cypress.json | 3 - .../failing-spec.cy.js} | 0 .../passing-spec.cy.js} | 0 .../cypress/support/{index.js => e2e.js} | 0 .../cypress.config.js | 10 ++ .../blogs__application-actions/cypress.json | 6 - .../{integration/spec.js => e2e/spec.cy.js} | 2 +- .../{integration/utils.js => e2e/utils.cy.js} | 0 .../cypress/plugins/index.js | 4 - .../cypress/support/{index.js => e2e.js} | 0 .../blogs__application-actions/package.json | 4 +- examples/blogs__assertion-counting/README.md | 4 +- .../cypress.config.js | 3 + .../blogs__assertion-counting/cypress.json | 3 - .../errors.js => e2e/errors.cy.js} | 0 .../{integration/spec.js => e2e/spec.cy.js} | 0 .../cypress/support/{index.js => e2e.js} | 0 examples/blogs__class-decorator/README.md | 2 +- .../blogs__class-decorator/cypress.config.js | 9 ++ examples/blogs__class-decorator/cypress.json | 6 - .../{integration/spec.js => e2e/spec.cy.js} | 0 .../blogs__codepen-demo/cypress.config.js | 9 ++ examples/blogs__codepen-demo/cypress.json | 6 - .../{integration/spec.js => e2e/spec.cy.js} | 0 examples/blogs__dayjs/README.md | 4 +- examples/blogs__dayjs/cypress.config.js | 7 + examples/blogs__dayjs/cypress.json | 6 - .../{integration/spec.js => e2e/spec.cy.js} | 0 .../{integration/spec2.js => e2e/spec2.cy.js} | 0 .../cypress/support/{index.js => e2e.js} | 2 +- .../cypress.config.js | 9 ++ .../cypress.json | 6 - .../{integration/spec.js => e2e/spec.cy.js} | 0 .../blogs__e2e-api-testing/cypress.config.js | 9 ++ examples/blogs__e2e-api-testing/cypress.json | 6 - .../example_spec.cy.js} | 0 examples/blogs__e2e-api-testing/package.json | 4 +- examples/blogs__e2e-snapshots/README.md | 6 +- .../blogs__e2e-snapshots/cypress.config.js | 15 ++ examples/blogs__e2e-snapshots/cypress.json | 4 - .../api-spec.js => e2e/api-spec.cy.js} | 0 .../store-spec.js => e2e/store-spec.cy.js} | 0 .../ui-spec.js => e2e/ui-spec.cy.js} | 0 .../unit-spec.js => e2e/unit-spec.cy.js} | 0 .../cypress/plugins/index.js | 20 --- .../cypress/support/e2e.js} | 2 +- .../blogs__element-coverage/cypress.config.js | 11 ++ examples/blogs__element-coverage/cypress.json | 10 -- .../{integration/spec.js => e2e/spec.cy.js} | 0 .../cypress/plugins/index.js | 19 --- .../cypress/support/{index.js => e2e.js} | 0 examples/blogs__form-submit/cypress.config.js | 10 ++ examples/blogs__form-submit/cypress.json | 7 - .../{integration/spec.js => e2e/spec.cy.js} | 0 examples/blogs__iframes/cypress.config.js | 11 ++ examples/blogs__iframes/cypress.json | 10 -- .../button-spec.js => e2e/button-spec.cy.js} | 0 .../custom-command-spec.cy.js} | 0 .../first-spec.js => e2e/first-spec.cy.js} | 0 .../plugin-spec.js => e2e/plugin-spec.cy.js} | 0 .../single-its-spec.cy.js} | 0 .../spy-on-fetch-spec.cy.js} | 0 .../xhr-spec.js => e2e/xhr-spec.cy.js} | 0 .../cypress/support/{index.js => e2e.js} | 0 examples/blogs__notification/README.md | 2 +- .../blogs__notification/cypress.config.js | 10 ++ examples/blogs__notification/cypress.json | 7 - .../{integration/spec.js => e2e/spec.cy.js} | 0 .../cypress.config.js | 18 +++ .../blogs__testing-redux-store/cypress.json | 10 -- .../__snapshots__/spec.js.snap | 0 .../{integration/spec.js => e2e/spec.cy.js} | 0 .../cypress/plugins/index.js | 7 - .../cypress/support/{index.js => e2e.js} | 0 examples/blogs__use-react-devtools/README.md | 2 +- .../cypress.config.js | 25 +++ .../blogs__use-react-devtools/cypress.json | 1 - .../{integration/spec.js => e2e/spec.cy.js} | 0 .../cypress/plugins/index.js | 21 --- .../cypress/support/{index.js => e2e.js} | 0 examples/blogs__vue-vuex-rest/README.md | 10 +- .../blogs__vue-vuex-rest/cypress.config.js | 61 +++++++ examples/blogs__vue-vuex-rest/cypress.json | 5 - .../api-spec.js => e2e/api-spec.cy.js} | 0 .../speed-spec.js => e2e/speed-spec.cy.js} | 4 +- .../store-spec.js => e2e/store-spec.cy.js} | 0 .../ui-spec.js => e2e/ui-spec.cy.js} | 0 .../cypress/plugins/index.js | 65 -------- .../README.md | 6 +- .../cypress.config.js | 5 + .../cypress.json | 4 - ...tending-chai-assertion-plugins-spec.cy.js} | 2 +- .../cypress/support/{index.js => e2e.js} | 2 +- examples/file-upload-react/cypress.config.js | 3 + .../cypress/e2e/csv-file-spec.cy.js | 20 +++ .../file-upload-react/cypress/e2e/spec.cy.js | 37 +++++ .../cypress/e2e/upload-plugin-spec.cy.js | 20 +++ .../cypress/e2e/upload-via-app-spec.cy.js | 32 ++++ .../file-upload-react/cypress/support/e2e.js | 1 + .../README.md | 4 +- .../cypress.config.ts | 7 + .../cypress.json | 6 - .../async-command.cy.ts} | 0 .../cypress/{integration => e2e}/spec.ts | 0 .../cypress/support/{index.ts => e2e.ts} | 0 .../README.md | 2 +- .../cypress.config.js | 7 + .../cypress.json | 6 - .../async-command.cy.js} | 0 .../{integration/spec.js => e2e/spec.cy.js} | 0 .../cypress/support/{index.js => e2e.js} | 2 +- .../cypress.config.js | 101 ++++++++++++ .../cypress.json | 4 - .../{integration/spec.js => e2e/spec.cy.js} | 0 .../cypress/plugins/index.js | 69 -------- .../fundamentals__custom-browsers/README.md | 2 + .../cypress.config.js | 26 +++ .../cypress.json | 4 - .../{integration/spec.js => e2e/spec.cy.js} | 0 .../cypress/plugins/brave.js | 51 +++--- .../cypress/plugins/index.js | 16 -- examples/fundamentals__cy-events/README.md | 4 +- .../fundamentals__cy-events/cypress.config.js | 8 + examples/fundamentals__cy-events/cypress.json | 5 - .../cy-on-spec.js => e2e/cy-on-spec.cy.js} | 0 .../cypress-on-spec.cy.js} | 0 .../README.md | 2 +- .../cypress.config.js | 40 +++++ .../cypress.json | 4 - .../users-spec.js => e2e/users-spec.cy.js} | 0 .../cypress/plugins/index.js | 28 ---- .../README.md | 6 +- .../cypress.config.js | 35 ++++ .../cypress.json | 4 - .../csv-spec.js => e2e/csv-spec.cy.js} | 0 .../cypress/plugins/index.js | 39 ----- .../fundamentals__dynamic-tests/README.md | 18 +-- .../cypress.config.js | 44 +++++ .../fundamentals__dynamic-tests/cypress.json | 7 - .../fixture-spec.cy.js} | 0 .../list-spec.js => e2e/list-spec.cy.js} | 0 .../request-spec.cy.js} | 0 .../subdomains-spec.cy.js} | 0 .../task-spec.js => e2e/task-spec.cy.js} | 0 .../plugin-spec.js => e2e/user-spec.cy.js} | 4 +- .../viewports-spec.cy.js} | 0 .../cypress/plugins/index.js | 42 ----- .../cypress/support/{index.js => e2e.js} | 0 .../fundamentals__dynamic-tests/package.json | 4 +- examples/fundamentals__errors/README.md | 8 +- .../fundamentals__errors/cypress.config.js | 8 + examples/fundamentals__errors/cypress.json | 5 - .../app-error.js => e2e/app-error.cy.js} | 0 .../test-fails.js => e2e/test-fails.cy.js} | 0 .../unhandled-promise-in-test.cy.js} | 0 .../unhandled-promise.cy.js} | 0 .../unhandled-promise2.cy.js} | 0 examples/fundamentals__fixtures/README.md | 12 +- .../fundamentals__fixtures/cypress.config.js | 3 + examples/fundamentals__fixtures/cypress.json | 3 - .../list-spec.js => e2e/list-spec.cy.js} | 0 .../load-fixtures-spec.cy.js} | 0 .../multiple-fixtures-spec.cy.js} | 0 .../require-fixtures-spec.cy.js} | 0 .../sanity-js-spec.cy.js} | 14 +- .../single-fixture-spec.cy.js} | 0 .../cypress/support/{index.js => e2e.js} | 0 examples/fundamentals__fixtures/package.json | 4 +- .../cypress.config.js | 8 + .../cypress.json | 5 - .../{integration/spec.js => e2e/spec.cy.js} | 0 examples/fundamentals__module-api/README.md | 16 +- .../cypress.config.js | 5 + .../fundamentals__module-api/cypress.json | 4 - .../first-spec.js => e2e/first-spec.cy.js} | 0 .../second-spec.js => e2e/second-spec.cy.js} | 0 .../third-spec.js => e2e/third-spec.cy.js} | 0 .../cypress/support/{index.js => e2e.js} | 2 +- .../fundamentals__module-api/e2e-tests.js | 2 +- examples/fundamentals__node-modules/README.md | 2 +- .../cypress.config.js | 5 + .../fundamentals__node-modules/cypress.json | 4 - .../es2015-commonjs-modules-spec.cy.js} | 2 +- .../cypress/support/{index.js => e2e.js} | 2 +- .../fundamentals__node-modules/package.json | 4 +- examples/fundamentals__timeout/README.md | 6 +- .../fundamentals__timeout/cypress.config.js | 9 ++ examples/fundamentals__timeout/cypress.json | 6 - .../all-tests-spec.cy.js} | 2 +- .../{integration/spec.js => e2e/spec.cy.js} | 2 +- .../timeout.js => e2e/timeout.cy.js} | 0 examples/fundamentals__typescript/README.Md | 2 +- .../cypress.config.js | 7 + .../fundamentals__typescript/cypress.json | 1 - .../tests.spec.ts => e2e/tests.spec.cy.ts} | 0 .../cypress/plugins/index.ts | 5 - .../cypress/support/{index.ts => e2e.js} | 2 +- .../cypress/types.d.ts | 1 - .../fundamentals__typescript/package.json | 1 - .../fundamentals__typescript/tsconfig.json | 4 +- examples/fundamentals__window-size/README.md | 2 +- .../cypress.config.js | 62 ++++++++ .../fundamentals__window-size/cypress.json | 4 - .../{integration/spec.js => e2e/spec.cy.js} | 6 +- .../cypress/plugins/index.js | 48 ------ examples/logging-in__basic-auth/README.md | 2 +- .../logging-in__basic-auth/cypress.config.js | 11 ++ examples/logging-in__basic-auth/cypress.json | 8 - .../{integration/spec.js => e2e/spec.cy.js} | 0 examples/logging-in__csrf-tokens/README.md | 2 +- .../logging-in__csrf-tokens/cypress.config.js | 9 ++ examples/logging-in__csrf-tokens/cypress.json | 6 - .../logging-in-csrf-tokens-spec.cy.js} | 0 examples/logging-in__html-web-forms/README.md | 2 +- .../cypress.config.js | 9 ++ .../logging-in__html-web-forms/cypress.json | 6 - .../logging-in-html-web-form-spec.cy.js} | 0 examples/logging-in__jwt/README.md | 4 +- examples/logging-in__jwt/cypress.config.js | 13 ++ examples/logging-in__jwt/cypress.json | 10 -- .../{integration/spec.js => e2e/spec.cy.js} | 0 .../using-ui-spec.cy.js} | 0 examples/logging-in__single-sign-on/README.md | 4 +- .../cypress.config.js | 11 ++ .../logging-in__single-sign-on/cypress.json | 8 - .../logging-in-single-sign-on-spec.cy.js} | 4 +- .../cypress/support/e2e.js} | 2 +- examples/logging-in__using-app-code/README.md | 4 +- .../cypress.config.js | 25 +++ .../logging-in__using-app-code/cypress.json | 8 - .../{integration/spec.js => e2e/spec.cy.js} | 0 .../cypress/plugins/index.js | 13 -- examples/logging-in__xhr-web-forms/README.md | 10 +- .../cypress.config.js | 9 ++ .../logging-in__xhr-web-forms/cypress.json | 6 - .../custom-command-spec.cy.js} | 0 .../logging-in-xhr-web-form-spec.cy.js} | 0 .../logging-via-request-spec.cy.js} | 0 .../slow-login-spec.cy.js} | 0 .../preprocessors__flow-browserify/README.md | 4 +- .../cypress.config.js | 16 ++ .../cypress.json | 3 - .../{integration/spec.js => e2e/spec.cy.js} | 0 .../cypress/plugins/index.js | 8 - .../cypress/support/e2e.js} | 2 +- examples/preprocessors__grep/README.md | 6 +- .../preprocessors__grep/cypress.config.js | 12 ++ examples/preprocessors__grep/cypress.json | 1 - .../feature-a.js => e2e/feature-a.cy.js} | 0 .../feature-b.js => e2e/feature-b.cy.js} | 0 .../cypress/plugins/index.js | 5 - .../cypress/support/index.js | 1 - .../README.md | 4 +- .../cypress.config.js | 17 ++ .../cypress.json | 4 - .../{integration/spec.ts => e2e/spec.cy.ts} | 0 .../cypress/plugins/index.js | 9 -- .../README.md | 4 +- .../cypress.config.js | 17 ++ .../cypress.json | 4 - .../{integration/spec.ts => e2e/spec.cy.ts} | 6 +- .../cypress/plugins/index.js | 9 -- .../cypress/support/commands.ts | 2 +- .../cypress/support/e2e.ts | 20 +++ .../cypress/support/index.ts | 20 --- .../package.json | 2 +- .../README.md | 2 +- .../cypress.config.js | 8 + .../cypress.json | 5 - .../bootstrapping_your_app_spec.cy.js} | 0 .../server-communication__env-variables/.env | 2 +- .../README.md | 8 +- .../cypress.config.js | 31 ++++ .../cypress.json | 7 - .../{integration/spec.js => e2e/spec.cy.js} | 7 +- .../cypress/plugins/index.js | 30 ---- .../server-communication__offline/README.md | 5 +- .../cypress.config.js | 12 ++ .../cypress.json | 9 -- .../offline-spec.cy.js} | 0 .../README.md | 16 +- .../cypress.config.js | 45 ++++++ .../cypress.json | 4 - .../first-spec.js => e2e/first-spec.cy.js} | 3 +- .../second-spec.js => e2e/second-spec.cy.js} | 3 +- .../cypress/plugins/index.js | 54 ------- .../server-communication__request/README.md | 2 +- .../cypress.config.js | 26 +++ .../cypress.json | 7 - .../{integration/spec.js => e2e/spec.cy.js} | 0 .../cypress/plugins/index.js | 21 --- .../.babelrc | 3 - .../README.md | 9 +- .../cypress.config.js | 19 +++ .../cypress.json | 4 - .../seeding_database_in_node_spec.cy.js} | 4 +- .../cypress/plugins/index.js | 10 -- .../cypress/plugins/main.js | 12 -- .../server/db.js | 13 +- .../server/routes.js | 8 +- .../README.md | 2 +- .../cypress.config.js | 9 ++ .../cypress.json | 6 - .../cypress/README.md | 7 +- .../{integration/spec.js => e2e/spec.cy.js} | 0 .../README.md | 12 +- .../cypress.config.js | 32 ++++ .../cypress.json | 3 - .../{integration/spec.js => e2e/spec.cy.js} | 0 .../cypress/plugins/index.js | 30 ---- .../cypress/support/{index.js => e2e.js} | 0 .../README.md | 10 +- .../cypress.config.js | 28 ++++ .../cypress.json | 4 - .../using-file-spec.cy.js} | 0 .../using-task-spec.cy.js} | 2 +- .../cypress/plugins/index.js | 37 ----- .../cypress.config.js | 13 ++ .../cypress.json | 10 -- .../{integration/spec.js => e2e/spec.cy.js} | 0 .../README.md | 14 +- .../cypress.config.js | 10 ++ .../cypress.json | 7 - .../clock-control.cy.js} | 0 .../duration-spec.cy.js} | 0 .../multiple-requests.cy.js} | 0 .../{integration/spec.js => e2e/spec.cy.js} | 0 .../spok-spec.js => e2e/spok-spec.cy.js} | 0 .../wait-vs-get.js => e2e/wait-vs-get.cy.js} | 0 .../xml-spec.js => e2e/xml-spec.cy.js} | 0 examples/stubbing-spying__console/README.md | 2 +- .../cypress.config.js | 8 + .../stubbing-spying__console/cypress.json | 5 - .../{integration/spec.js => e2e/spec.cy.js} | 0 .../cypress.config.js | 8 + .../stubbing-spying__functions/cypress.json | 5 - ...nit-test-stubbing-dependencies-spec.cy.js} | 0 .../README.md | 4 +- .../cypress.config.js | 21 +++ .../cypress.json | 6 - .../ga-method-stubbing.cy.js} | 0 .../ga-network-stubbing.cy.js} | 0 .../cypress/plugins/index.js | 24 --- examples/stubbing-spying__intercept/README.md | 40 ++--- .../cypress.config.js | 24 +++ .../stubbing-spying__intercept/cypress.json | 6 - .../control-clock-spec.cy.js} | 0 .../count-spec.js => e2e/count-spec.cy.js} | 0 .../form-spec.js => e2e/form-spec.cy.js} | 0 .../glob-matching-intercept-url.spec.cy.js} | 0 .../header-spec.js => e2e/header-spec.cy.js} | 0 .../html-css-spec.cy.js} | 0 .../image-spec.js => e2e/image-spec.cy.js} | 0 .../intercept-events.spec.cy.js} | 0 .../intercept-force404.spec.cy.js} | 0 .../jsonp-spec.js => e2e/jsonp-spec.cy.js} | 0 .../loading-element-spec.cy.js} | 0 .../matching-spec.cy.js} | 0 .../middleware-intercept.spec.cy.js} | 0 .../ping-spec.js => e2e/ping-spec.cy.js} | 3 +- .../redirect-spec.cy.js} | 0 .../repeat-spec.js => e2e/repeat-spec.cy.js} | 0 .../spy-on-fetch-spec.cy.js} | 0 .../stub-fetch-spec.cy.js} | 0 .../stubbed-api-spec.cy.js} | 0 .../times-spec.js => e2e/times-spec.cy.js} | 0 .../cypress/plugins/index.js | 14 -- examples/stubbing-spying__navigator/README.md | 2 +- .../cypress.config.js | 8 + .../stubbing-spying__navigator/cypress.json | 5 - .../{integration/spec.js => e2e/spec.cy.js} | 0 .../stubbing-spying__window-fetch/README.md | 10 +- .../cypress.config.js | 10 ++ .../cypress.json | 7 - .../control-clock-spec.cy.js} | 0 .../spy-on-fetch-spec.cy.js} | 0 .../stub-fetch-spec.cy.js} | 0 .../cypress/support/e2e.js | 20 +++ .../cypress/support/index.js | 20 --- .../stubbing-spying__window-print/README.md | 2 +- .../cypress.config.js | 8 + .../cypress.json | 5 - .../{integration/spec.js => e2e/spec.cy.js} | 0 examples/stubbing-spying__window/README.md | 4 +- .../stubbing-spying__window/cypress.config.js | 8 + examples/stubbing-spying__window/cypress.json | 5 - .../{integration/spec.js => e2e/spec.cy.js} | 0 .../spy-before-load.cy.js} | 0 examples/stubbing__resources/README.md | 2 +- .../stubbing__resources/cypress.config.js | 8 + examples/stubbing__resources/cypress.json | 5 - .../{integration/spec.js => e2e/spec.cy.js} | 0 examples/testing-dom__clipboard/README.md | 2 +- .../testing-dom__clipboard/cypress.config.js | 10 ++ examples/testing-dom__clipboard/cypress.json | 7 - .../permissions-spec.cy.js} | 0 .../{integration/spec.js => e2e/spec.cy.js} | 0 examples/testing-dom__csv-table/README.md | 2 +- .../testing-dom__csv-table/cypress.config.js | 10 ++ examples/testing-dom__csv-table/cypress.json | 7 - .../{integration/spec.js => e2e/spec.cy.js} | 0 examples/testing-dom__download/README.md | 10 +- .../testing-dom__download/cypress.config.js | 150 ++++++++++++++++++ examples/testing-dom__download/cypress.json | 10 -- .../form-submission-spec.cy.js} | 6 +- .../local-download-spec.cy.js} | 8 +- .../location-href-spec.cy.js} | 3 - .../remote-download-spec.cy.js} | 4 +- .../cypress/{integration => e2e}/utils.js | 14 +- .../cypress/plugins/index.js | 130 --------------- .../plugins => document-utils}/read-excel.js | 0 .../plugins => document-utils}/read-pdf.js | 4 +- examples/testing-dom__download/package.json | 2 - examples/testing-dom__drag-drop/README.md | 2 +- .../testing-dom__drag-drop/cypress.config.js | 9 ++ examples/testing-dom__drag-drop/cypress.json | 6 - .../drag_n_drop_spec.cy.js} | 0 .../testing-dom__form-interactions/README.md | 2 +- .../cypress.config.js | 9 ++ .../cypress.json | 6 - .../form-interactions-spec.cy.js} | 0 .../README.md | 2 +- .../cypress.config.js | 9 ++ .../cypress.json | 6 - .../hover-hidden-elements-spec.cy.js} | 0 .../cypress.config.js | 9 ++ .../testing-dom__lit-element/cypress.json | 6 - .../shadow-tests.cy.ts} | 0 .../testing-dom__lit-element/package.json | 4 +- examples/testing-dom__page-reloads/README.md | 2 +- .../cypress.config.js | 10 ++ .../testing-dom__page-reloads/cypress.json | 7 - .../{integration/spec.js => e2e/spec.cy.js} | 0 examples/testing-dom__page-source/README.md | 2 +- .../cypress.config.js | 9 ++ .../testing-dom__page-source/cypress.json | 6 - .../{integration/spec.js => e2e/spec.cy.js} | 0 examples/testing-dom__pagination/README.md | 2 +- .../testing-dom__pagination/cypress.config.js | 10 ++ examples/testing-dom__pagination/cypress.json | 7 - .../{integration/spec.js => e2e/spec.cy.js} | 0 .../README.md | 2 +- .../cypress.config.js | 8 + .../cypress.json | 5 - .../{integration/spec.js => e2e/spec.cy.js} | 0 .../testing-dom__responsive-image/README.md | 2 +- .../cypress.config.js | 8 + .../cypress.json | 5 - .../{integration/spec.js => e2e/spec.cy.js} | 0 examples/testing-dom__root-style/README.md | 2 +- .../testing-dom__root-style/cypress.config.js | 10 ++ examples/testing-dom__root-style/cypress.json | 7 - .../{integration/spec.js => e2e/spec.cy.js} | 0 examples/testing-dom__select2/README.md | 2 +- .../testing-dom__select2/cypress.config.js | 12 ++ examples/testing-dom__select2/cypress.json | 9 -- .../{integration/spec.js => e2e/spec.cy.js} | 0 examples/testing-dom__sorting-table/README.md | 2 +- .../cypress.config.js | 8 + .../testing-dom__sorting-table/cypress.json | 5 - .../{integration/spec.js => e2e/spec.cy.js} | 0 .../testing-dom__tab-handling-links/README.md | 2 +- .../cypress.config.js | 9 ++ .../cypress.json | 6 - .../tab_handling_anchor_links_spec.cy.js} | 2 +- .../testing-dom__wait-for-resource/README.md | 8 +- .../cypress.config.js | 9 ++ .../cypress.json | 6 - .../cypress/README.md | 8 +- .../{integration/spec.js => e2e/spec.cy.js} | 2 +- .../cypress/support/{index.js => e2e.js} | 2 +- .../unit-testing__application-code/README.md | 10 +- .../cypress.config.js | 7 + .../cypress.json | 4 - .../async-tests.js => e2e/async-tests.cy.js} | 0 .../unit_test_application_code_spec.cy.js} | 0 .../wait-for-object-property-spec.cy.js} | 0 .../wait-for-window-property-spec.cy.js} | 0 .../package.json | 4 +- package-lock.json | 16 +- package.json | 6 +- test-examples.js | 5 - 487 files changed, 1877 insertions(+), 1710 deletions(-) delete mode 100644 appveyor.yml create mode 100644 examples/blogs__a11y/cypress.config.js delete mode 100644 examples/blogs__a11y/cypress.json rename examples/blogs__a11y/cypress/{integration/failing-spec.js => e2e/failing-spec.cy.js} (100%) rename examples/blogs__a11y/cypress/{integration/passing-spec.js => e2e/passing-spec.cy.js} (100%) rename examples/blogs__a11y/cypress/support/{index.js => e2e.js} (100%) create mode 100644 examples/blogs__application-actions/cypress.config.js delete mode 100644 examples/blogs__application-actions/cypress.json rename examples/blogs__application-actions/cypress/{integration/spec.js => e2e/spec.cy.js} (99%) rename examples/blogs__application-actions/cypress/{integration/utils.js => e2e/utils.cy.js} (100%) delete mode 100644 examples/blogs__application-actions/cypress/plugins/index.js rename examples/blogs__application-actions/cypress/support/{index.js => e2e.js} (100%) create mode 100644 examples/blogs__assertion-counting/cypress.config.js delete mode 100644 examples/blogs__assertion-counting/cypress.json rename examples/blogs__assertion-counting/cypress/{integration/errors.js => e2e/errors.cy.js} (100%) rename examples/blogs__assertion-counting/cypress/{integration/spec.js => e2e/spec.cy.js} (100%) rename examples/blogs__assertion-counting/cypress/support/{index.js => e2e.js} (100%) create mode 100644 examples/blogs__class-decorator/cypress.config.js delete mode 100644 examples/blogs__class-decorator/cypress.json rename examples/blogs__class-decorator/cypress/{integration/spec.js => e2e/spec.cy.js} (100%) create mode 100644 examples/blogs__codepen-demo/cypress.config.js delete mode 100644 examples/blogs__codepen-demo/cypress.json rename examples/blogs__codepen-demo/cypress/{integration/spec.js => e2e/spec.cy.js} (100%) create mode 100644 examples/blogs__dayjs/cypress.config.js delete mode 100644 examples/blogs__dayjs/cypress.json rename examples/blogs__dayjs/cypress/{integration/spec.js => e2e/spec.cy.js} (100%) rename examples/blogs__dayjs/cypress/{integration/spec2.js => e2e/spec2.cy.js} (100%) rename examples/blogs__dayjs/cypress/support/{index.js => e2e.js} (92%) create mode 100644 examples/blogs__direct-control-angular/cypress.config.js delete mode 100644 examples/blogs__direct-control-angular/cypress.json rename examples/blogs__direct-control-angular/cypress/{integration/spec.js => e2e/spec.cy.js} (100%) create mode 100644 examples/blogs__e2e-api-testing/cypress.config.js delete mode 100644 examples/blogs__e2e-api-testing/cypress.json rename examples/blogs__e2e-api-testing/cypress/{integration/example_spec.js => e2e/example_spec.cy.js} (100%) create mode 100644 examples/blogs__e2e-snapshots/cypress.config.js delete mode 100644 examples/blogs__e2e-snapshots/cypress.json rename examples/blogs__e2e-snapshots/cypress/{integration/api-spec.js => e2e/api-spec.cy.js} (100%) rename examples/blogs__e2e-snapshots/cypress/{integration/store-spec.js => e2e/store-spec.cy.js} (100%) rename examples/blogs__e2e-snapshots/cypress/{integration/ui-spec.js => e2e/ui-spec.cy.js} (100%) rename examples/blogs__e2e-snapshots/cypress/{integration/unit-spec.js => e2e/unit-spec.cy.js} (100%) delete mode 100644 examples/blogs__e2e-snapshots/cypress/plugins/index.js rename examples/{preprocessors__flow-browserify/cypress/support/index.js => blogs__e2e-snapshots/cypress/support/e2e.js} (92%) create mode 100644 examples/blogs__element-coverage/cypress.config.js delete mode 100644 examples/blogs__element-coverage/cypress.json rename examples/blogs__element-coverage/cypress/{integration/spec.js => e2e/spec.cy.js} (100%) delete mode 100644 examples/blogs__element-coverage/cypress/plugins/index.js rename examples/blogs__element-coverage/cypress/support/{index.js => e2e.js} (100%) create mode 100644 examples/blogs__form-submit/cypress.config.js delete mode 100644 examples/blogs__form-submit/cypress.json rename examples/blogs__form-submit/cypress/{integration/spec.js => e2e/spec.cy.js} (100%) create mode 100644 examples/blogs__iframes/cypress.config.js delete mode 100644 examples/blogs__iframes/cypress.json rename examples/blogs__iframes/cypress/{integration/button-spec.js => e2e/button-spec.cy.js} (100%) rename examples/blogs__iframes/cypress/{integration/custom-command-spec.js => e2e/custom-command-spec.cy.js} (100%) rename examples/blogs__iframes/cypress/{integration/first-spec.js => e2e/first-spec.cy.js} (100%) rename examples/blogs__iframes/cypress/{integration/plugin-spec.js => e2e/plugin-spec.cy.js} (100%) rename examples/blogs__iframes/cypress/{integration/single-its-spec.js => e2e/single-its-spec.cy.js} (100%) rename examples/blogs__iframes/cypress/{integration/spy-on-fetch-spec.js => e2e/spy-on-fetch-spec.cy.js} (100%) rename examples/blogs__iframes/cypress/{integration/xhr-spec.js => e2e/xhr-spec.cy.js} (100%) rename examples/blogs__iframes/cypress/support/{index.js => e2e.js} (100%) create mode 100644 examples/blogs__notification/cypress.config.js delete mode 100644 examples/blogs__notification/cypress.json rename examples/blogs__notification/cypress/{integration/spec.js => e2e/spec.cy.js} (100%) create mode 100644 examples/blogs__testing-redux-store/cypress.config.js delete mode 100644 examples/blogs__testing-redux-store/cypress.json rename examples/blogs__testing-redux-store/cypress/{integration => e2e}/__snapshots__/spec.js.snap (100%) rename examples/blogs__testing-redux-store/cypress/{integration/spec.js => e2e/spec.cy.js} (100%) delete mode 100644 examples/blogs__testing-redux-store/cypress/plugins/index.js rename examples/blogs__testing-redux-store/cypress/support/{index.js => e2e.js} (100%) create mode 100644 examples/blogs__use-react-devtools/cypress.config.js delete mode 100644 examples/blogs__use-react-devtools/cypress.json rename examples/blogs__use-react-devtools/cypress/{integration/spec.js => e2e/spec.cy.js} (100%) delete mode 100644 examples/blogs__use-react-devtools/cypress/plugins/index.js rename examples/blogs__use-react-devtools/cypress/support/{index.js => e2e.js} (100%) create mode 100644 examples/blogs__vue-vuex-rest/cypress.config.js delete mode 100644 examples/blogs__vue-vuex-rest/cypress.json rename examples/blogs__vue-vuex-rest/cypress/{integration/api-spec.js => e2e/api-spec.cy.js} (100%) rename examples/blogs__vue-vuex-rest/cypress/{integration/speed-spec.js => e2e/speed-spec.cy.js} (97%) rename examples/blogs__vue-vuex-rest/cypress/{integration/store-spec.js => e2e/store-spec.cy.js} (100%) rename examples/blogs__vue-vuex-rest/cypress/{integration/ui-spec.js => e2e/ui-spec.cy.js} (100%) delete mode 100644 examples/blogs__vue-vuex-rest/cypress/plugins/index.js create mode 100644 examples/extending-cypress__chai-assertions/cypress.config.js delete mode 100644 examples/extending-cypress__chai-assertions/cypress.json rename examples/extending-cypress__chai-assertions/cypress/{integration/extending-chai-assertion-plugins-spec.js => e2e/extending-chai-assertion-plugins-spec.cy.js} (97%) rename examples/extending-cypress__chai-assertions/cypress/support/{index.js => e2e.js} (93%) create mode 100644 examples/file-upload-react/cypress.config.js create mode 100644 examples/file-upload-react/cypress/e2e/csv-file-spec.cy.js create mode 100644 examples/file-upload-react/cypress/e2e/spec.cy.js create mode 100644 examples/file-upload-react/cypress/e2e/upload-plugin-spec.cy.js create mode 100644 examples/file-upload-react/cypress/e2e/upload-via-app-spec.cy.js create mode 100644 examples/file-upload-react/cypress/support/e2e.js create mode 100644 examples/fundamentals__add-custom-command-ts/cypress.config.ts delete mode 100644 examples/fundamentals__add-custom-command-ts/cypress.json rename examples/fundamentals__add-custom-command-ts/cypress/{integration/async-command.ts => e2e/async-command.cy.ts} (100%) rename examples/fundamentals__add-custom-command-ts/cypress/{integration => e2e}/spec.ts (100%) rename examples/fundamentals__add-custom-command-ts/cypress/support/{index.ts => e2e.ts} (100%) create mode 100644 examples/fundamentals__add-custom-command/cypress.config.js delete mode 100644 examples/fundamentals__add-custom-command/cypress.json rename examples/fundamentals__add-custom-command/cypress/{integration/async-command.js => e2e/async-command.cy.js} (100%) rename examples/fundamentals__add-custom-command/cypress/{integration/spec.js => e2e/spec.cy.js} (100%) rename examples/fundamentals__add-custom-command/cypress/support/{index.js => e2e.js} (93%) create mode 100644 examples/fundamentals__chrome-remote-debugging/cypress.config.js delete mode 100644 examples/fundamentals__chrome-remote-debugging/cypress.json rename examples/fundamentals__chrome-remote-debugging/cypress/{integration/spec.js => e2e/spec.cy.js} (100%) delete mode 100644 examples/fundamentals__chrome-remote-debugging/cypress/plugins/index.js create mode 100644 examples/fundamentals__custom-browsers/cypress.config.js delete mode 100644 examples/fundamentals__custom-browsers/cypress.json rename examples/fundamentals__custom-browsers/cypress/{integration/spec.js => e2e/spec.cy.js} (100%) delete mode 100644 examples/fundamentals__custom-browsers/cypress/plugins/index.js create mode 100644 examples/fundamentals__cy-events/cypress.config.js delete mode 100644 examples/fundamentals__cy-events/cypress.json rename examples/fundamentals__cy-events/cypress/{integration/cy-on-spec.js => e2e/cy-on-spec.cy.js} (100%) rename examples/fundamentals__cy-events/cypress/{integration/cypress-on-spec.js => e2e/cypress-on-spec.cy.js} (100%) create mode 100644 examples/fundamentals__dynamic-tests-from-api/cypress.config.js delete mode 100644 examples/fundamentals__dynamic-tests-from-api/cypress.json rename examples/fundamentals__dynamic-tests-from-api/cypress/{integration/users-spec.js => e2e/users-spec.cy.js} (100%) delete mode 100644 examples/fundamentals__dynamic-tests-from-api/cypress/plugins/index.js create mode 100644 examples/fundamentals__dynamic-tests-from-csv/cypress.config.js delete mode 100644 examples/fundamentals__dynamic-tests-from-csv/cypress.json rename examples/fundamentals__dynamic-tests-from-csv/cypress/{integration/csv-spec.js => e2e/csv-spec.cy.js} (100%) delete mode 100644 examples/fundamentals__dynamic-tests-from-csv/cypress/plugins/index.js create mode 100644 examples/fundamentals__dynamic-tests/cypress.config.js delete mode 100644 examples/fundamentals__dynamic-tests/cypress.json rename examples/fundamentals__dynamic-tests/cypress/{integration/fixture-spec.js => e2e/fixture-spec.cy.js} (100%) rename examples/fundamentals__dynamic-tests/cypress/{integration/list-spec.js => e2e/list-spec.cy.js} (100%) rename examples/fundamentals__dynamic-tests/cypress/{integration/request-spec.js => e2e/request-spec.cy.js} (100%) rename examples/fundamentals__dynamic-tests/cypress/{integration/subdomains-spec.js => e2e/subdomains-spec.cy.js} (100%) rename examples/fundamentals__dynamic-tests/cypress/{integration/task-spec.js => e2e/task-spec.cy.js} (100%) rename examples/fundamentals__dynamic-tests/cypress/{integration/plugin-spec.js => e2e/user-spec.cy.js} (86%) rename examples/fundamentals__dynamic-tests/cypress/{integration/viewports-spec.js => e2e/viewports-spec.cy.js} (100%) delete mode 100644 examples/fundamentals__dynamic-tests/cypress/plugins/index.js rename examples/fundamentals__dynamic-tests/cypress/support/{index.js => e2e.js} (100%) create mode 100644 examples/fundamentals__errors/cypress.config.js delete mode 100644 examples/fundamentals__errors/cypress.json rename examples/fundamentals__errors/cypress/{integration/app-error.js => e2e/app-error.cy.js} (100%) rename examples/fundamentals__errors/cypress/{integration/test-fails.js => e2e/test-fails.cy.js} (100%) rename examples/fundamentals__errors/cypress/{integration/unhandled-promise-in-test.js => e2e/unhandled-promise-in-test.cy.js} (100%) rename examples/fundamentals__errors/cypress/{integration/unhandled-promise.js => e2e/unhandled-promise.cy.js} (100%) rename examples/fundamentals__errors/cypress/{integration/unhandled-promise2.js => e2e/unhandled-promise2.cy.js} (100%) create mode 100644 examples/fundamentals__fixtures/cypress.config.js delete mode 100644 examples/fundamentals__fixtures/cypress.json rename examples/fundamentals__fixtures/cypress/{integration/list-spec.js => e2e/list-spec.cy.js} (100%) rename examples/fundamentals__fixtures/cypress/{integration/load-fixtures-spec.js => e2e/load-fixtures-spec.cy.js} (100%) rename examples/fundamentals__fixtures/cypress/{integration/multiple-fixtures-spec.js => e2e/multiple-fixtures-spec.cy.js} (100%) rename examples/fundamentals__fixtures/cypress/{integration/require-fixtures-spec.js => e2e/require-fixtures-spec.cy.js} (100%) rename examples/fundamentals__fixtures/cypress/{integration/sanity-js-spec.js => e2e/sanity-js-spec.cy.js} (61%) rename examples/fundamentals__fixtures/cypress/{integration/single-fixture-spec.js => e2e/single-fixture-spec.cy.js} (100%) rename examples/fundamentals__fixtures/cypress/support/{index.js => e2e.js} (100%) create mode 100644 examples/fundamentals__module-api-wrap/cypress.config.js delete mode 100644 examples/fundamentals__module-api-wrap/cypress.json rename examples/fundamentals__module-api-wrap/cypress/{integration/spec.js => e2e/spec.cy.js} (100%) create mode 100644 examples/fundamentals__module-api/cypress.config.js delete mode 100644 examples/fundamentals__module-api/cypress.json rename examples/fundamentals__module-api/cypress/{integration/first-spec.js => e2e/first-spec.cy.js} (100%) rename examples/fundamentals__module-api/cypress/{integration/second-spec.js => e2e/second-spec.cy.js} (100%) rename examples/fundamentals__module-api/cypress/{integration/third-spec.js => e2e/third-spec.cy.js} (100%) rename examples/fundamentals__module-api/cypress/support/{index.js => e2e.js} (92%) create mode 100644 examples/fundamentals__node-modules/cypress.config.js delete mode 100644 examples/fundamentals__node-modules/cypress.json rename examples/fundamentals__node-modules/cypress/{integration/es2015-commonjs-modules-spec.js => e2e/es2015-commonjs-modules-spec.cy.js} (98%) rename examples/fundamentals__node-modules/cypress/support/{index.js => e2e.js} (92%) create mode 100644 examples/fundamentals__timeout/cypress.config.js delete mode 100644 examples/fundamentals__timeout/cypress.json rename examples/fundamentals__timeout/cypress/{integration/all-tests-spec.js => e2e/all-tests-spec.cy.js} (96%) rename examples/fundamentals__timeout/cypress/{integration/spec.js => e2e/spec.cy.js} (91%) rename examples/fundamentals__timeout/cypress/{integration/timeout.js => e2e/timeout.cy.js} (100%) create mode 100644 examples/fundamentals__typescript/cypress.config.js delete mode 100644 examples/fundamentals__typescript/cypress.json rename examples/fundamentals__typescript/cypress/{integration/tests.spec.ts => e2e/tests.spec.cy.ts} (100%) delete mode 100644 examples/fundamentals__typescript/cypress/plugins/index.ts rename examples/fundamentals__typescript/cypress/support/{index.ts => e2e.js} (92%) create mode 100644 examples/fundamentals__window-size/cypress.config.js delete mode 100644 examples/fundamentals__window-size/cypress.json rename examples/fundamentals__window-size/cypress/{integration/spec.js => e2e/spec.cy.js} (90%) delete mode 100644 examples/fundamentals__window-size/cypress/plugins/index.js create mode 100644 examples/logging-in__basic-auth/cypress.config.js delete mode 100644 examples/logging-in__basic-auth/cypress.json rename examples/logging-in__basic-auth/cypress/{integration/spec.js => e2e/spec.cy.js} (100%) create mode 100644 examples/logging-in__csrf-tokens/cypress.config.js delete mode 100644 examples/logging-in__csrf-tokens/cypress.json rename examples/logging-in__csrf-tokens/cypress/{integration/logging-in-csrf-tokens-spec.js => e2e/logging-in-csrf-tokens-spec.cy.js} (100%) create mode 100644 examples/logging-in__html-web-forms/cypress.config.js delete mode 100644 examples/logging-in__html-web-forms/cypress.json rename examples/logging-in__html-web-forms/cypress/{integration/logging-in-html-web-form-spec.js => e2e/logging-in-html-web-form-spec.cy.js} (100%) create mode 100644 examples/logging-in__jwt/cypress.config.js delete mode 100644 examples/logging-in__jwt/cypress.json rename examples/logging-in__jwt/cypress/{integration/spec.js => e2e/spec.cy.js} (100%) rename examples/logging-in__jwt/cypress/{integration/using-ui-spec.js => e2e/using-ui-spec.cy.js} (100%) create mode 100644 examples/logging-in__single-sign-on/cypress.config.js delete mode 100644 examples/logging-in__single-sign-on/cypress.json rename examples/logging-in__single-sign-on/cypress/{integration/logging-in-single-sign-on-spec.js => e2e/logging-in-single-sign-on-spec.cy.js} (99%) rename examples/{blogs__e2e-snapshots/cypress/support/index.js => logging-in__single-sign-on/cypress/support/e2e.js} (92%) create mode 100644 examples/logging-in__using-app-code/cypress.config.js delete mode 100644 examples/logging-in__using-app-code/cypress.json rename examples/logging-in__using-app-code/cypress/{integration/spec.js => e2e/spec.cy.js} (100%) delete mode 100644 examples/logging-in__using-app-code/cypress/plugins/index.js create mode 100644 examples/logging-in__xhr-web-forms/cypress.config.js delete mode 100644 examples/logging-in__xhr-web-forms/cypress.json rename examples/logging-in__xhr-web-forms/cypress/{integration/custom-command-spec.js => e2e/custom-command-spec.cy.js} (100%) rename examples/logging-in__xhr-web-forms/cypress/{integration/logging-in-xhr-web-form-spec.js => e2e/logging-in-xhr-web-form-spec.cy.js} (100%) rename examples/logging-in__xhr-web-forms/cypress/{integration/logging-via-request-spec.js => e2e/logging-via-request-spec.cy.js} (100%) rename examples/logging-in__xhr-web-forms/cypress/{integration/slow-login-spec.js => e2e/slow-login-spec.cy.js} (100%) create mode 100644 examples/preprocessors__flow-browserify/cypress.config.js delete mode 100644 examples/preprocessors__flow-browserify/cypress.json rename examples/preprocessors__flow-browserify/cypress/{integration/spec.js => e2e/spec.cy.js} (100%) delete mode 100644 examples/preprocessors__flow-browserify/cypress/plugins/index.js rename examples/{logging-in__single-sign-on/cypress/support/index.js => preprocessors__flow-browserify/cypress/support/e2e.js} (92%) create mode 100644 examples/preprocessors__grep/cypress.config.js delete mode 100644 examples/preprocessors__grep/cypress.json rename examples/preprocessors__grep/cypress/{integration/feature-a.js => e2e/feature-a.cy.js} (100%) rename examples/preprocessors__grep/cypress/{integration/feature-b.js => e2e/feature-b.cy.js} (100%) delete mode 100644 examples/preprocessors__grep/cypress/plugins/index.js delete mode 100644 examples/preprocessors__grep/cypress/support/index.js create mode 100644 examples/preprocessors__typescript-browserify/cypress.config.js delete mode 100644 examples/preprocessors__typescript-browserify/cypress.json rename examples/preprocessors__typescript-browserify/cypress/{integration/spec.ts => e2e/spec.cy.ts} (100%) delete mode 100644 examples/preprocessors__typescript-browserify/cypress/plugins/index.js create mode 100644 examples/preprocessors__typescript-webpack/cypress.config.js delete mode 100644 examples/preprocessors__typescript-webpack/cypress.json rename examples/preprocessors__typescript-webpack/cypress/{integration/spec.ts => e2e/spec.cy.ts} (94%) delete mode 100644 examples/preprocessors__typescript-webpack/cypress/plugins/index.js create mode 100644 examples/preprocessors__typescript-webpack/cypress/support/e2e.ts delete mode 100644 examples/preprocessors__typescript-webpack/cypress/support/index.ts create mode 100644 examples/server-communication__bootstrapping-your-app/cypress.config.js delete mode 100644 examples/server-communication__bootstrapping-your-app/cypress.json rename examples/server-communication__bootstrapping-your-app/cypress/{integration/bootstrapping_your_app_spec.js => e2e/bootstrapping_your_app_spec.cy.js} (100%) create mode 100644 examples/server-communication__env-variables/cypress.config.js delete mode 100644 examples/server-communication__env-variables/cypress.json rename examples/server-communication__env-variables/cypress/{integration/spec.js => e2e/spec.cy.js} (91%) delete mode 100644 examples/server-communication__env-variables/cypress/plugins/index.js create mode 100644 examples/server-communication__offline/cypress.config.js delete mode 100644 examples/server-communication__offline/cypress.json rename examples/server-communication__offline/cypress/{integration/offline-spec.js => e2e/offline-spec.cy.js} (100%) create mode 100644 examples/server-communication__pass-value-between-specs/cypress.config.js delete mode 100644 examples/server-communication__pass-value-between-specs/cypress.json rename examples/server-communication__pass-value-between-specs/cypress/{integration/first-spec.js => e2e/first-spec.cy.js} (90%) rename examples/server-communication__pass-value-between-specs/cypress/{integration/second-spec.js => e2e/second-spec.cy.js} (81%) delete mode 100644 examples/server-communication__pass-value-between-specs/cypress/plugins/index.js create mode 100644 examples/server-communication__request/cypress.config.js delete mode 100644 examples/server-communication__request/cypress.json rename examples/server-communication__request/cypress/{integration/spec.js => e2e/spec.cy.js} (100%) delete mode 100644 examples/server-communication__request/cypress/plugins/index.js delete mode 100644 examples/server-communication__seeding-database-in-node/.babelrc create mode 100644 examples/server-communication__seeding-database-in-node/cypress.config.js delete mode 100644 examples/server-communication__seeding-database-in-node/cypress.json rename examples/server-communication__seeding-database-in-node/cypress/{integration/seeding_database_in_node_spec.js => e2e/seeding_database_in_node_spec.cy.js} (80%) delete mode 100644 examples/server-communication__seeding-database-in-node/cypress/plugins/index.js delete mode 100644 examples/server-communication__seeding-database-in-node/cypress/plugins/main.js create mode 100644 examples/server-communication__server-timing/cypress.config.js delete mode 100644 examples/server-communication__server-timing/cypress.json rename examples/server-communication__server-timing/cypress/{integration/spec.js => e2e/spec.cy.js} (100%) create mode 100644 examples/server-communication__stream-tests/cypress.config.js delete mode 100644 examples/server-communication__stream-tests/cypress.json rename examples/server-communication__stream-tests/cypress/{integration/spec.js => e2e/spec.cy.js} (100%) delete mode 100644 examples/server-communication__stream-tests/cypress/plugins/index.js rename examples/server-communication__stream-tests/cypress/support/{index.js => e2e.js} (100%) create mode 100644 examples/server-communication__visit-2nd-domain/cypress.config.js delete mode 100644 examples/server-communication__visit-2nd-domain/cypress.json rename examples/server-communication__visit-2nd-domain/cypress/{integration/using-file-spec.js => e2e/using-file-spec.cy.js} (100%) rename examples/server-communication__visit-2nd-domain/cypress/{integration/using-task-spec.js => e2e/using-task-spec.cy.js} (94%) delete mode 100644 examples/server-communication__visit-2nd-domain/cypress/plugins/index.js create mode 100644 examples/server-communication__wait-for-api/cypress.config.js delete mode 100644 examples/server-communication__wait-for-api/cypress.json rename examples/server-communication__wait-for-api/cypress/{integration/spec.js => e2e/spec.cy.js} (100%) create mode 100644 examples/server-communication__xhr-assertions/cypress.config.js delete mode 100644 examples/server-communication__xhr-assertions/cypress.json rename examples/server-communication__xhr-assertions/cypress/{integration/clock-control.js => e2e/clock-control.cy.js} (100%) rename examples/server-communication__xhr-assertions/cypress/{integration/duration-spec.js => e2e/duration-spec.cy.js} (100%) rename examples/server-communication__xhr-assertions/cypress/{integration/multiple-requests.js => e2e/multiple-requests.cy.js} (100%) rename examples/server-communication__xhr-assertions/cypress/{integration/spec.js => e2e/spec.cy.js} (100%) rename examples/server-communication__xhr-assertions/cypress/{integration/spok-spec.js => e2e/spok-spec.cy.js} (100%) rename examples/server-communication__xhr-assertions/cypress/{integration/wait-vs-get.js => e2e/wait-vs-get.cy.js} (100%) rename examples/server-communication__xhr-assertions/cypress/{integration/xml-spec.js => e2e/xml-spec.cy.js} (100%) create mode 100644 examples/stubbing-spying__console/cypress.config.js delete mode 100644 examples/stubbing-spying__console/cypress.json rename examples/stubbing-spying__console/cypress/{integration/spec.js => e2e/spec.cy.js} (100%) create mode 100644 examples/stubbing-spying__functions/cypress.config.js delete mode 100644 examples/stubbing-spying__functions/cypress.json rename examples/stubbing-spying__functions/cypress/{integration/unit-test-stubbing-dependencies-spec.js => e2e/unit-test-stubbing-dependencies-spec.cy.js} (100%) create mode 100644 examples/stubbing-spying__google-analytics/cypress.config.js delete mode 100644 examples/stubbing-spying__google-analytics/cypress.json rename examples/stubbing-spying__google-analytics/cypress/{integration/ga-method-stubbing.js => e2e/ga-method-stubbing.cy.js} (100%) rename examples/stubbing-spying__google-analytics/cypress/{integration/ga-network-stubbing.js => e2e/ga-network-stubbing.cy.js} (100%) delete mode 100644 examples/stubbing-spying__google-analytics/cypress/plugins/index.js create mode 100644 examples/stubbing-spying__intercept/cypress.config.js delete mode 100644 examples/stubbing-spying__intercept/cypress.json rename examples/stubbing-spying__intercept/cypress/{integration/control-clock-spec.js => e2e/control-clock-spec.cy.js} (100%) rename examples/stubbing-spying__intercept/cypress/{integration/count-spec.js => e2e/count-spec.cy.js} (100%) rename examples/stubbing-spying__intercept/cypress/{integration/form-spec.js => e2e/form-spec.cy.js} (100%) rename examples/stubbing-spying__intercept/cypress/{integration/glob-matching-intercept-url.spec.js => e2e/glob-matching-intercept-url.spec.cy.js} (100%) rename examples/stubbing-spying__intercept/cypress/{integration/header-spec.js => e2e/header-spec.cy.js} (100%) rename examples/stubbing-spying__intercept/cypress/{integration/html-css-spec.js => e2e/html-css-spec.cy.js} (100%) rename examples/stubbing-spying__intercept/cypress/{integration/image-spec.js => e2e/image-spec.cy.js} (100%) rename examples/stubbing-spying__intercept/cypress/{integration/intercept-events.spec.js => e2e/intercept-events.spec.cy.js} (100%) rename examples/stubbing-spying__intercept/cypress/{integration/intercept-force404.spec.js => e2e/intercept-force404.spec.cy.js} (100%) rename examples/stubbing-spying__intercept/cypress/{integration/jsonp-spec.js => e2e/jsonp-spec.cy.js} (100%) rename examples/stubbing-spying__intercept/cypress/{integration/loading-element-spec.js => e2e/loading-element-spec.cy.js} (100%) rename examples/stubbing-spying__intercept/cypress/{integration/matching-spec.js => e2e/matching-spec.cy.js} (100%) rename examples/stubbing-spying__intercept/cypress/{integration/middleware-intercept.spec.js => e2e/middleware-intercept.spec.cy.js} (100%) rename examples/stubbing-spying__intercept/cypress/{integration/ping-spec.js => e2e/ping-spec.cy.js} (81%) rename examples/stubbing-spying__intercept/cypress/{integration/redirect-spec.js => e2e/redirect-spec.cy.js} (100%) rename examples/stubbing-spying__intercept/cypress/{integration/repeat-spec.js => e2e/repeat-spec.cy.js} (100%) rename examples/stubbing-spying__intercept/cypress/{integration/spy-on-fetch-spec.js => e2e/spy-on-fetch-spec.cy.js} (100%) rename examples/stubbing-spying__intercept/cypress/{integration/stub-fetch-spec.js => e2e/stub-fetch-spec.cy.js} (100%) rename examples/stubbing-spying__intercept/cypress/{integration/stubbed-api-spec.js => e2e/stubbed-api-spec.cy.js} (100%) rename examples/stubbing-spying__intercept/cypress/{integration/times-spec.js => e2e/times-spec.cy.js} (100%) delete mode 100644 examples/stubbing-spying__intercept/cypress/plugins/index.js create mode 100644 examples/stubbing-spying__navigator/cypress.config.js delete mode 100644 examples/stubbing-spying__navigator/cypress.json rename examples/stubbing-spying__navigator/cypress/{integration/spec.js => e2e/spec.cy.js} (100%) create mode 100644 examples/stubbing-spying__window-fetch/cypress.config.js delete mode 100644 examples/stubbing-spying__window-fetch/cypress.json rename examples/stubbing-spying__window-fetch/cypress/{integration/control-clock-spec.js => e2e/control-clock-spec.cy.js} (100%) rename examples/stubbing-spying__window-fetch/cypress/{integration/spy-on-fetch-spec.js => e2e/spy-on-fetch-spec.cy.js} (100%) rename examples/stubbing-spying__window-fetch/cypress/{integration/stub-fetch-spec.js => e2e/stub-fetch-spec.cy.js} (100%) create mode 100644 examples/stubbing-spying__window-fetch/cypress/support/e2e.js delete mode 100644 examples/stubbing-spying__window-fetch/cypress/support/index.js create mode 100644 examples/stubbing-spying__window-print/cypress.config.js delete mode 100644 examples/stubbing-spying__window-print/cypress.json rename examples/stubbing-spying__window-print/cypress/{integration/spec.js => e2e/spec.cy.js} (100%) create mode 100644 examples/stubbing-spying__window/cypress.config.js delete mode 100644 examples/stubbing-spying__window/cypress.json rename examples/stubbing-spying__window/cypress/{integration/spec.js => e2e/spec.cy.js} (100%) rename examples/stubbing-spying__window/cypress/{integration/spy-before-load.js => e2e/spy-before-load.cy.js} (100%) create mode 100644 examples/stubbing__resources/cypress.config.js delete mode 100644 examples/stubbing__resources/cypress.json rename examples/stubbing__resources/cypress/{integration/spec.js => e2e/spec.cy.js} (100%) create mode 100644 examples/testing-dom__clipboard/cypress.config.js delete mode 100644 examples/testing-dom__clipboard/cypress.json rename examples/testing-dom__clipboard/cypress/{integration/permissions-spec.js => e2e/permissions-spec.cy.js} (100%) rename examples/testing-dom__clipboard/cypress/{integration/spec.js => e2e/spec.cy.js} (100%) create mode 100644 examples/testing-dom__csv-table/cypress.config.js delete mode 100644 examples/testing-dom__csv-table/cypress.json rename examples/testing-dom__csv-table/cypress/{integration/spec.js => e2e/spec.cy.js} (100%) create mode 100644 examples/testing-dom__download/cypress.config.js delete mode 100644 examples/testing-dom__download/cypress.json rename examples/testing-dom__download/cypress/{integration/form-submission-spec.js => e2e/form-submission-spec.cy.js} (91%) rename examples/testing-dom__download/cypress/{integration/local-download-spec.js => e2e/local-download-spec.cy.js} (95%) rename examples/testing-dom__download/cypress/{integration/location-href-spec.js => e2e/location-href-spec.cy.js} (98%) rename examples/testing-dom__download/cypress/{integration/remote-download-spec.js => e2e/remote-download-spec.cy.js} (98%) rename examples/testing-dom__download/cypress/{integration => e2e}/utils.js (91%) delete mode 100644 examples/testing-dom__download/cypress/plugins/index.js rename examples/testing-dom__download/{cypress/plugins => document-utils}/read-excel.js (100%) rename examples/testing-dom__download/{cypress/plugins => document-utils}/read-pdf.js (83%) create mode 100644 examples/testing-dom__drag-drop/cypress.config.js delete mode 100644 examples/testing-dom__drag-drop/cypress.json rename examples/testing-dom__drag-drop/cypress/{integration/drag_n_drop_spec.js => e2e/drag_n_drop_spec.cy.js} (100%) create mode 100644 examples/testing-dom__form-interactions/cypress.config.js delete mode 100644 examples/testing-dom__form-interactions/cypress.json rename examples/testing-dom__form-interactions/cypress/{integration/form-interactions-spec.js => e2e/form-interactions-spec.cy.js} (100%) create mode 100644 examples/testing-dom__hover-hidden-elements/cypress.config.js delete mode 100644 examples/testing-dom__hover-hidden-elements/cypress.json rename examples/testing-dom__hover-hidden-elements/cypress/{integration/hover-hidden-elements-spec.js => e2e/hover-hidden-elements-spec.cy.js} (100%) create mode 100644 examples/testing-dom__lit-element/cypress.config.js delete mode 100644 examples/testing-dom__lit-element/cypress.json rename examples/testing-dom__lit-element/cypress/{integration/shadow-tests.ts => e2e/shadow-tests.cy.ts} (100%) create mode 100644 examples/testing-dom__page-reloads/cypress.config.js delete mode 100644 examples/testing-dom__page-reloads/cypress.json rename examples/testing-dom__page-reloads/cypress/{integration/spec.js => e2e/spec.cy.js} (100%) create mode 100644 examples/testing-dom__page-source/cypress.config.js delete mode 100644 examples/testing-dom__page-source/cypress.json rename examples/testing-dom__page-source/cypress/{integration/spec.js => e2e/spec.cy.js} (100%) create mode 100644 examples/testing-dom__pagination/cypress.config.js delete mode 100644 examples/testing-dom__pagination/cypress.json rename examples/testing-dom__pagination/cypress/{integration/spec.js => e2e/spec.cy.js} (100%) create mode 100644 examples/testing-dom__performance-metrics/cypress.config.js delete mode 100644 examples/testing-dom__performance-metrics/cypress.json rename examples/testing-dom__performance-metrics/cypress/{integration/spec.js => e2e/spec.cy.js} (100%) create mode 100644 examples/testing-dom__responsive-image/cypress.config.js delete mode 100644 examples/testing-dom__responsive-image/cypress.json rename examples/testing-dom__responsive-image/cypress/{integration/spec.js => e2e/spec.cy.js} (100%) create mode 100644 examples/testing-dom__root-style/cypress.config.js delete mode 100644 examples/testing-dom__root-style/cypress.json rename examples/testing-dom__root-style/cypress/{integration/spec.js => e2e/spec.cy.js} (100%) create mode 100644 examples/testing-dom__select2/cypress.config.js delete mode 100644 examples/testing-dom__select2/cypress.json rename examples/testing-dom__select2/cypress/{integration/spec.js => e2e/spec.cy.js} (100%) create mode 100644 examples/testing-dom__sorting-table/cypress.config.js delete mode 100644 examples/testing-dom__sorting-table/cypress.json rename examples/testing-dom__sorting-table/cypress/{integration/spec.js => e2e/spec.cy.js} (100%) create mode 100644 examples/testing-dom__tab-handling-links/cypress.config.js delete mode 100644 examples/testing-dom__tab-handling-links/cypress.json rename examples/testing-dom__tab-handling-links/cypress/{integration/tab_handling_anchor_links_spec.js => e2e/tab_handling_anchor_links_spec.cy.js} (99%) create mode 100644 examples/testing-dom__wait-for-resource/cypress.config.js delete mode 100644 examples/testing-dom__wait-for-resource/cypress.json rename examples/testing-dom__wait-for-resource/cypress/{integration/spec.js => e2e/spec.cy.js} (99%) rename examples/testing-dom__wait-for-resource/cypress/support/{index.js => e2e.js} (98%) create mode 100644 examples/unit-testing__application-code/cypress.config.js delete mode 100644 examples/unit-testing__application-code/cypress.json rename examples/unit-testing__application-code/cypress/{integration/async-tests.js => e2e/async-tests.cy.js} (100%) rename examples/unit-testing__application-code/cypress/{integration/unit_test_application_code_spec.js => e2e/unit_test_application_code_spec.cy.js} (100%) rename examples/unit-testing__application-code/cypress/{integration/wait-for-object-property-spec.js => e2e/wait-for-object-property-spec.cy.js} (100%) rename examples/unit-testing__application-code/cypress/{integration/wait-for-window-property-spec.js => e2e/wait-for-window-property-spec.cy.js} (100%) diff --git a/.circleci/config.yml b/.circleci/config.yml index eb5d8db38..c57a99c99 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -57,22 +57,16 @@ jobs: steps: - checkout - restore_cache: - key: cache-dirs-{{ .Branch }}-{{ checksum "package.json" }}-{{ checksum "circle.yml" }} + key: cache-dirs-{{ .Branch }}-{{ checksum "package.json" }}-{{ checksum ".circleci/config.yml" }} - run: npm ci - # Use Git commit message to install any pre-release versions of Cypress - - run: npm i -g @cypress/commit-message-install - # if there is no special JSON comment in the current commit body - # then this command does nothing - - run: commit-message-install --else "echo nothing custom to install" - # run verify and then save cache. # this ensures that the Cypress verified status is cached too - run: npm run cypress:verify - run: npm run cypress:info - run: npm run stop-only - save_cache: - key: cache-dirs-{{ .Branch }}-{{ checksum "package.json" }}-{{ checksum "circle.yml" }} + key: cache-dirs-{{ .Branch }}-{{ checksum "package.json" }}-{{ checksum ".circleci/config.yml" }} paths: - ~/.npm - ~/.cache @@ -334,8 +328,8 @@ jobs: <<: *defaults server-communication__stream-tests: <<: *defaults - server-communication__offline: - <<: *defaults + # server-communication__offline: + # <<: *defaults server-communication__server-timing: <<: *defaults server-communication__wait-for-api: @@ -639,9 +633,9 @@ all_jobs: &all_jobs - server-communication__stream-tests: requires: - build - - server-communication__offline: - requires: - - build + # - server-communication__offline: + # requires: + # - build - server-communication__server-timing: requires: - build @@ -708,7 +702,7 @@ all_jobs: &all_jobs - server-communication__visit-2nd-domain - server-communication__pass-value-between-specs - server-communication__stream-tests - - server-communication__offline + # - server-communication__offline - server-communication__server-timing - server-communication__wait-for-api - server-communication__request diff --git a/README.md b/README.md index 49bbab447..1ffaa44bb 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Recipes -[![CircleCI](https://circleci.com/gh/cypress-io/cypress-example-recipes/tree/master.svg?style=svg)](https://circleci.com/gh/cypress-io/cypress-example-recipes/tree/master) [![Build status](https://ci.appveyor.com/api/projects/status/7p4qkwavheciwbxc/branch/master?svg=true)](https://ci.appveyor.com/project/cypress-io/cypress-example-recipes/branch/master) [![renovate-app badge][renovate-badge]][renovate-app] [![Cypress Dashboard][dashboard badge]][dashboard url] +[![CircleCI](https://circleci.com/gh/cypress-io/cypress-example-recipes/tree/master.svg?style=svg)](https://circleci.com/gh/cypress-io/cypress-example-recipes/tree/master) + +[![renovate-app badge][renovate-badge]][renovate-app] [![Cypress Dashboard][dashboard badge]][dashboard url] > This repo contains various recipes for testing common scenarios using Cypress: [Fundamentals](#fundamentals), [Testing the DOM](#testing-the-dom), [Logging in](#logging-in-recipes), [Preprocessors](#preprocessors), [Blogs](#blogs), [Stubbing and spying](#stubbing-and-spying), [Unit Testing](#unit-testing), [Server Communication](#server-communication), [Other Cypress Recipes](#other-cypress-recipes), [Community Recipes](#community-recipes) @@ -130,8 +132,8 @@ Recipe | Description [Seeding your Database in Node](./examples/server-communication__seeding-database-in-node) | Seed your database with test data [XHR assertions](./examples/server-communication__xhr-assertions) | Spy and assert on application's network calls [Visiting 2nd domain](./examples/server-communication__visit-2nd-domain) | Visiting two different domains from two different tests and passing value from one test to another -[Pass value between specs](./examples/server-communication__pass-value-between-specs) | Pass a value from spec to spec via the plugin file using [cy.task](https://on.cypress.io/task) -[Stream test results](./examples/server-communication__stream-tests) | Streams each test result from the browser to the plugins to an external process via IPC +[Pass value between specs](./examples/server-communication__pass-value-between-specs) | Pass a value from spec to spec via the `setupNodeEvents` function in the Cypress configuration using [cy.task](https://on.cypress.io/task) +[Stream test results](./examples/server-communication__stream-tests) | Streams each test result from the browser to the `setupNodeEvents` function to an external process via IPC [Offline](./examples/server-communication__offline) | Test web application when the network is offline [Server timing](./examples/server-communication__server-timing) | Report server timing results from Cypress test [Wait for API](./examples/server-communication__wait-for-api) | Call the backend using `cy.request` until it responds @@ -182,13 +184,13 @@ Recipe | Description npm install ``` -## Opening Cypress GUI +## Opening Cypress App ```bash cd ./examples/testing-dom__drag-drop # start local server npm start & -# and open Cypress GUI +# open Cypress App npm run cypress:open ``` diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 5a436965c..000000000 --- a/appveyor.yml +++ /dev/null @@ -1,43 +0,0 @@ -# https://www.appveyor.com/docs/lang/nodejs-iojs/ -# Test against the latest version of this Node.js version -environment: - nodejs_version: "12" - -# Install scripts. (runs after repo cloning) -install: - - ps: Install-Product node $env:nodejs_version - # Output useful info for debugging. - - node --version - - npm --version - - node -e "console.log(process.platform)" - - node -e "console.log(process.arch)" - # print cached dependencies - - echo '%AppData%\npm-cache' - - echo '%USERPROFILE%\AppData\Local\Cypress\Cache' - - ls '%AppData%\npm-cache' || true - - ls '%USERPROFILE%\AppData\Local\Cypress\Cache' || true - - npm ci - # install global bin-up - # to avoid problems with finding tool paths on Windows - - npm i -g bin-up - -cache: - # cache NPM packages and Cypress binary - # https://www.appveyor.com/docs/build-cache/ - # https://docs.npmjs.com/files/folders.html#cache - # https://on.cypress.io/caching - # because we use exact version dependencies - # we can key caches using package.json file - - '%AppData%\npm-cache -> package.json' - - '%USERPROFILE%\AppData\Local\Cypress\Cache -> package.json' - # Note: by default cache is only saved for successful builds - # you can save cache from the failed builds - # using APPVEYOR_SAVE_CACHE_ON_ERROR: true environment variable - -test_script: - - npx cypress version - - npx cypress info - - npm run test:ci:windows:record - -# Don't actually build, we are only interested in tests -build: off diff --git a/examples/blogs__a11y/README.md b/examples/blogs__a11y/README.md index cc50abb05..466e96abb 100644 --- a/examples/blogs__a11y/README.md +++ b/examples/blogs__a11y/README.md @@ -2,10 +2,10 @@ This demo shows the [cypress-axe](https://github.com/avanslaars/cypress-axe) plugin which can run the [Axe-core](https://github.com/dequelabs/axe-core) library against the webpage to check if the page follows accessibility practices. -The tests are in [cypress/integration](cypress/integration) folder. +The tests are in [cypress/e2e](cypress/e2e) folder. -- The [passing-spec.js](cypress/integration/passing-spec.js) loads local [index.html](index.html) with high contrast text, which passes A11y checks -- The [failing-spec.js](cypress/integration/failing-spec.js) loads local [index-bad.html](index-bad.html) with low contrast text, failing the checks +- The [passing-spec.cy.js](cypress/e2e/passing-spec.cy.js) loads local [index.html](index.html) with high contrast text, which passes A11y checks +- The [failing-spec.cy.js](cypress/e2e/failing-spec.cy.js) loads local [index-bad.html](index-bad.html) with low contrast text, failing the checks ![Failing check](images/failing.png) diff --git a/examples/blogs__a11y/cypress.config.js b/examples/blogs__a11y/cypress.config.js new file mode 100644 index 000000000..53cf629bf --- /dev/null +++ b/examples/blogs__a11y/cypress.config.js @@ -0,0 +1,3 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({}) diff --git a/examples/blogs__a11y/cypress.json b/examples/blogs__a11y/cypress.json deleted file mode 100644 index eaf6a8861..000000000 --- a/examples/blogs__a11y/cypress.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "pluginsFile": false -} \ No newline at end of file diff --git a/examples/blogs__a11y/cypress/integration/failing-spec.js b/examples/blogs__a11y/cypress/e2e/failing-spec.cy.js similarity index 100% rename from examples/blogs__a11y/cypress/integration/failing-spec.js rename to examples/blogs__a11y/cypress/e2e/failing-spec.cy.js diff --git a/examples/blogs__a11y/cypress/integration/passing-spec.js b/examples/blogs__a11y/cypress/e2e/passing-spec.cy.js similarity index 100% rename from examples/blogs__a11y/cypress/integration/passing-spec.js rename to examples/blogs__a11y/cypress/e2e/passing-spec.cy.js diff --git a/examples/blogs__a11y/cypress/support/index.js b/examples/blogs__a11y/cypress/support/e2e.js similarity index 100% rename from examples/blogs__a11y/cypress/support/index.js rename to examples/blogs__a11y/cypress/support/e2e.js diff --git a/examples/blogs__application-actions/cypress.config.js b/examples/blogs__application-actions/cypress.config.js new file mode 100644 index 000000000..fa9587be1 --- /dev/null +++ b/examples/blogs__application-actions/cypress.config.js @@ -0,0 +1,10 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + fixturesFolder: false, + defaultCommandTimeout: 8000, + e2e: { + baseUrl: 'http://localhost:8888', + excludeSpecPattern: 'utils.js', + }, +}) diff --git a/examples/blogs__application-actions/cypress.json b/examples/blogs__application-actions/cypress.json deleted file mode 100644 index 31107a531..000000000 --- a/examples/blogs__application-actions/cypress.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "baseUrl": "http://localhost:8888", - "ignoreTestFiles": "utils.js", - "fixturesFolder": false, - "defaultCommandTimeout": 8000 -} diff --git a/examples/blogs__application-actions/cypress/integration/spec.js b/examples/blogs__application-actions/cypress/e2e/spec.cy.js similarity index 99% rename from examples/blogs__application-actions/cypress/integration/spec.js rename to examples/blogs__application-actions/cypress/e2e/spec.cy.js index f3504c7d4..ca0bd9157 100644 --- a/examples/blogs__application-actions/cypress/integration/spec.js +++ b/examples/blogs__application-actions/cypress/e2e/spec.cy.js @@ -10,7 +10,7 @@ import { TODO_ITEM_THREE, TODO_ITEM_TWO, toggle, -} from './utils' +} from './utils.cy' describe('TodoMVC', function () { beforeEach(function () { diff --git a/examples/blogs__application-actions/cypress/integration/utils.js b/examples/blogs__application-actions/cypress/e2e/utils.cy.js similarity index 100% rename from examples/blogs__application-actions/cypress/integration/utils.js rename to examples/blogs__application-actions/cypress/e2e/utils.cy.js diff --git a/examples/blogs__application-actions/cypress/plugins/index.js b/examples/blogs__application-actions/cypress/plugins/index.js deleted file mode 100644 index 18cabe464..000000000 --- a/examples/blogs__application-actions/cypress/plugins/index.js +++ /dev/null @@ -1,4 +0,0 @@ -module.exports = (on, config) => { - // `on` is used to hook into various events Cypress emits - // `config` is the resolved Cypress config -} diff --git a/examples/blogs__application-actions/cypress/support/index.js b/examples/blogs__application-actions/cypress/support/e2e.js similarity index 100% rename from examples/blogs__application-actions/cypress/support/index.js rename to examples/blogs__application-actions/cypress/support/e2e.js diff --git a/examples/blogs__application-actions/package.json b/examples/blogs__application-actions/package.json index 15c9d5c03..af50b0988 100644 --- a/examples/blogs__application-actions/package.json +++ b/examples/blogs__application-actions/package.json @@ -17,8 +17,6 @@ "test:ci": "../../node_modules/.bin/start-test 8888 cypress:run", "test:ci:chrome": "../../node_modules/.bin/start-test 8888 cypress:run:chrome", "test:ci:firefox": "../../node_modules/.bin/start-test 8888 cypress:run:firefox", - "test:ci:record": "../../node_modules/.bin/start-test 8888 cypress:run:record", - "test:ci:windows": "bin-up start-test start:win http://localhost:8888 cypress:run:win", - "test:ci:windows:record": "bin-up start-test start:win http://localhost:8888 cypress:run:win:record" + "test:ci:record": "../../node_modules/.bin/start-test 8888 cypress:run:record" } } diff --git a/examples/blogs__assertion-counting/README.md b/examples/blogs__assertion-counting/README.md index d2b90a8c4..5f0248fed 100644 --- a/examples/blogs__assertion-counting/README.md +++ b/examples/blogs__assertion-counting/README.md @@ -6,7 +6,7 @@ See the application in [index.html](index.html) that shows `window.confirm` on c ![Window confirm](images/confirm.gif) -The [cypress/integration/spec.js](cypress/integration/spec.js) shows various ways the tests can ensure the async assertions finish before the test finishes. The last test shows how to use [cypress-expect-n-assertions](https://github.com/bahmutov/cypress-expect-n-assertions) to automatically wait for declared number of assertions to run before finishing the test. +The [cypress/e2e/spec.cy.js](cypress/e2e/spec.cy.js) shows various ways the tests can ensure the async assertions finish before the test finishes. The last test shows how to use [cypress-expect-n-assertions](https://github.com/bahmutov/cypress-expect-n-assertions) to automatically wait for declared number of assertions to run before finishing the test. ```js import { plan } from 'cypress-expect-n-assertions' @@ -26,6 +26,6 @@ it('waits for planned number of assertion to run', () => { ## Unhandled promise rejections -If the application code creates an unhandled rejected promise, Cypress does NOT see it by default. If you want to fail the test, listen to the unhandled promise event and throw an error. See spec file [errors.js](cypress/integration/errors.js) +If the application code creates an unhandled rejected promise, Cypress does NOT see it by default. If you want to fail the test, listen to the unhandled promise event and throw an error. See spec file [errors.cy.js](cypress/e2e/errors.cy.js) ![Fail the test when a promise is rejected and is not handled](./images/fail-test-on-unhandled-promise-rejection.gif) diff --git a/examples/blogs__assertion-counting/cypress.config.js b/examples/blogs__assertion-counting/cypress.config.js new file mode 100644 index 000000000..53cf629bf --- /dev/null +++ b/examples/blogs__assertion-counting/cypress.config.js @@ -0,0 +1,3 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({}) diff --git a/examples/blogs__assertion-counting/cypress.json b/examples/blogs__assertion-counting/cypress.json deleted file mode 100644 index eaf6a8861..000000000 --- a/examples/blogs__assertion-counting/cypress.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "pluginsFile": false -} \ No newline at end of file diff --git a/examples/blogs__assertion-counting/cypress/integration/errors.js b/examples/blogs__assertion-counting/cypress/e2e/errors.cy.js similarity index 100% rename from examples/blogs__assertion-counting/cypress/integration/errors.js rename to examples/blogs__assertion-counting/cypress/e2e/errors.cy.js diff --git a/examples/blogs__assertion-counting/cypress/integration/spec.js b/examples/blogs__assertion-counting/cypress/e2e/spec.cy.js similarity index 100% rename from examples/blogs__assertion-counting/cypress/integration/spec.js rename to examples/blogs__assertion-counting/cypress/e2e/spec.cy.js diff --git a/examples/blogs__assertion-counting/cypress/support/index.js b/examples/blogs__assertion-counting/cypress/support/e2e.js similarity index 100% rename from examples/blogs__assertion-counting/cypress/support/index.js rename to examples/blogs__assertion-counting/cypress/support/e2e.js diff --git a/examples/blogs__class-decorator/README.md b/examples/blogs__class-decorator/README.md index e8d5e8490..b07b38932 100644 --- a/examples/blogs__class-decorator/README.md +++ b/examples/blogs__class-decorator/README.md @@ -16,7 +16,7 @@ export default class TodoItem extends Component { During the test, we can get to that component using `cy.window().its('TodoItem')` to check internal state or trigger component's methods. ```js -// cypress/integration/spec.js +// cypress/e2e/spec.cy.js it('creates Todo components', () => { cy.visit('/') cy.get('.new-todo') diff --git a/examples/blogs__class-decorator/cypress.config.js b/examples/blogs__class-decorator/cypress.config.js new file mode 100644 index 000000000..7f76e1263 --- /dev/null +++ b/examples/blogs__class-decorator/cypress.config.js @@ -0,0 +1,9 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + fixturesFolder: false, + e2e: { + baseUrl: 'http://localhost:1234', + supportFile: false, + }, +}) diff --git a/examples/blogs__class-decorator/cypress.json b/examples/blogs__class-decorator/cypress.json deleted file mode 100644 index 76db1f4fb..000000000 --- a/examples/blogs__class-decorator/cypress.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "baseUrl": "http://localhost:1234", - "fixturesFolder": false, - "supportFile": false, - "pluginsFile": false -} diff --git a/examples/blogs__class-decorator/cypress/integration/spec.js b/examples/blogs__class-decorator/cypress/e2e/spec.cy.js similarity index 100% rename from examples/blogs__class-decorator/cypress/integration/spec.js rename to examples/blogs__class-decorator/cypress/e2e/spec.cy.js diff --git a/examples/blogs__codepen-demo/cypress.config.js b/examples/blogs__codepen-demo/cypress.config.js new file mode 100644 index 000000000..35ccc1513 --- /dev/null +++ b/examples/blogs__codepen-demo/cypress.config.js @@ -0,0 +1,9 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + chromeWebSecurity: false, + fixturesFolder: false, + e2e: { + supportFile: false, + }, +}) diff --git a/examples/blogs__codepen-demo/cypress.json b/examples/blogs__codepen-demo/cypress.json deleted file mode 100644 index 03451cfa9..000000000 --- a/examples/blogs__codepen-demo/cypress.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "chromeWebSecurity": false, - "fixturesFolder": false, - "pluginsFile": false, - "supportFile": false -} \ No newline at end of file diff --git a/examples/blogs__codepen-demo/cypress/integration/spec.js b/examples/blogs__codepen-demo/cypress/e2e/spec.cy.js similarity index 100% rename from examples/blogs__codepen-demo/cypress/integration/spec.js rename to examples/blogs__codepen-demo/cypress/e2e/spec.cy.js diff --git a/examples/blogs__dayjs/README.md b/examples/blogs__dayjs/README.md index 8e25c6ac0..98f966649 100644 --- a/examples/blogs__dayjs/README.md +++ b/examples/blogs__dayjs/README.md @@ -1,7 +1,7 @@ # example: dayjs > Using the [day.js](https://day.js.org/en/) instead of the deprecated Cypress.moment -You can install `day.js` as a regular NPM dependency and require or import it in your spec file. See [spec.js](cypress/integration/spec.js) for example: +You can install `day.js` as a regular NPM dependency and require or import it in your spec file. See [spec.cy.js](cypress/e2e/spec.cy.js) for example: ```js const dayjs = require('dayjs') @@ -11,7 +11,7 @@ const todaysDate = dayjs().format('MMM DD, YYYY') cy.contains('span', `Order shipped on: ${todaysDate}`) ``` -Alternatively, if many specs need the dayjs library, you can load it from the [support file](cypress/support/index.js) and set the reference as `Cypress.dayjs` to make the library available in every spec. +Alternatively, if many specs need the dayjs library, you can load it from the [support file](cypress/support/e2e.js) and set the reference as `Cypress.dayjs` to make the library available in every spec. ```js // support file diff --git a/examples/blogs__dayjs/cypress.config.js b/examples/blogs__dayjs/cypress.config.js new file mode 100644 index 000000000..51db0a10a --- /dev/null +++ b/examples/blogs__dayjs/cypress.config.js @@ -0,0 +1,7 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + fixturesFolder: false, + viewportWidth: 500, + viewportHeight: 200, +}) diff --git a/examples/blogs__dayjs/cypress.json b/examples/blogs__dayjs/cypress.json deleted file mode 100644 index 50edef9fc..000000000 --- a/examples/blogs__dayjs/cypress.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "fixturesFolder": false, - "pluginsFile": false, - "viewportWidth": 500, - "viewportHeight": 200 -} diff --git a/examples/blogs__dayjs/cypress/integration/spec.js b/examples/blogs__dayjs/cypress/e2e/spec.cy.js similarity index 100% rename from examples/blogs__dayjs/cypress/integration/spec.js rename to examples/blogs__dayjs/cypress/e2e/spec.cy.js diff --git a/examples/blogs__dayjs/cypress/integration/spec2.js b/examples/blogs__dayjs/cypress/e2e/spec2.cy.js similarity index 100% rename from examples/blogs__dayjs/cypress/integration/spec2.js rename to examples/blogs__dayjs/cypress/e2e/spec2.cy.js diff --git a/examples/blogs__dayjs/cypress/support/index.js b/examples/blogs__dayjs/cypress/support/e2e.js similarity index 92% rename from examples/blogs__dayjs/cypress/support/index.js rename to examples/blogs__dayjs/cypress/support/e2e.js index 55d3f3e07..1f7488fca 100644 --- a/examples/blogs__dayjs/cypress/support/index.js +++ b/examples/blogs__dayjs/cypress/support/e2e.js @@ -1,5 +1,5 @@ // *********************************************************** -// This example support/index.js is processed and +// This example support/e2e.js is processed and // loaded automatically before your test files. // // This is a great place to put global configuration and diff --git a/examples/blogs__direct-control-angular/cypress.config.js b/examples/blogs__direct-control-angular/cypress.config.js new file mode 100644 index 000000000..002d37970 --- /dev/null +++ b/examples/blogs__direct-control-angular/cypress.config.js @@ -0,0 +1,9 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + fixturesFolder: false, + e2e: { + baseUrl: 'http://todomvc.com/examples/angularjs', + supportFile: false, + }, +}) diff --git a/examples/blogs__direct-control-angular/cypress.json b/examples/blogs__direct-control-angular/cypress.json deleted file mode 100644 index adca2d7d4..000000000 --- a/examples/blogs__direct-control-angular/cypress.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "baseUrl": "http://todomvc.com/examples/angularjs", - "fixturesFolder": false, - "pluginsFile": false, - "supportFile": false -} \ No newline at end of file diff --git a/examples/blogs__direct-control-angular/cypress/integration/spec.js b/examples/blogs__direct-control-angular/cypress/e2e/spec.cy.js similarity index 100% rename from examples/blogs__direct-control-angular/cypress/integration/spec.js rename to examples/blogs__direct-control-angular/cypress/e2e/spec.cy.js diff --git a/examples/blogs__e2e-api-testing/cypress.config.js b/examples/blogs__e2e-api-testing/cypress.config.js new file mode 100644 index 000000000..58b1669dd --- /dev/null +++ b/examples/blogs__e2e-api-testing/cypress.config.js @@ -0,0 +1,9 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + fixturesFolder: false, + e2e: { + baseUrl: 'http://localhost:7081', + supportFile: false, + }, +}) diff --git a/examples/blogs__e2e-api-testing/cypress.json b/examples/blogs__e2e-api-testing/cypress.json deleted file mode 100644 index fcbe5c4ee..000000000 --- a/examples/blogs__e2e-api-testing/cypress.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "baseUrl": "http://localhost:7081", - "fixturesFolder": false, - "pluginsFile": false, - "supportFile": false -} \ No newline at end of file diff --git a/examples/blogs__e2e-api-testing/cypress/integration/example_spec.js b/examples/blogs__e2e-api-testing/cypress/e2e/example_spec.cy.js similarity index 100% rename from examples/blogs__e2e-api-testing/cypress/integration/example_spec.js rename to examples/blogs__e2e-api-testing/cypress/e2e/example_spec.cy.js diff --git a/examples/blogs__e2e-api-testing/package.json b/examples/blogs__e2e-api-testing/package.json index 2f7ec2bc2..1e25593c6 100644 --- a/examples/blogs__e2e-api-testing/package.json +++ b/examples/blogs__e2e-api-testing/package.json @@ -11,8 +11,6 @@ "start": "../../node_modules/.bin/json-server db.json --port 7081 --quiet", "start:windows": "bin-up json-server db.json --port 7081 --quiet", "test:ci": "../../node_modules/.bin/start-test 7081 cypress:run", - "test:ci:record": "../../node_modules/.bin/start-test 7081 cypress:run:record", - "test:ci:windows": "bin-up start-test start:windows 7081 cypress:run:windows", - "test:ci:windows:record": "bin-up start-test start:windows 7081 cypress:run:windows:record" + "test:ci:record": "../../node_modules/.bin/start-test 7081 cypress:run:record" } } diff --git a/examples/blogs__e2e-snapshots/README.md b/examples/blogs__e2e-snapshots/README.md index 98e855bf3..fb476e196 100644 --- a/examples/blogs__e2e-snapshots/README.md +++ b/examples/blogs__e2e-snapshots/README.md @@ -9,9 +9,9 @@ Adding snapshot support to Cypress via 3rd party module [@cypress/snapshot](http ## Lessons - Adding `.snapshot()` command by requiring 3rd party module [cypress/support/commands.js](cypress/support/commands.js) -- Capturing and saving snapshots of primitive values [cypress/integration/unit-spec.js](cypress/integration/unit-spec.js) -- Testing central data Vuex store using snapshots [cypress/integration/store-spec.js](cypress/integration/store-spec.js) -- Making assertions against a DOM element using `cy.get('todo-list').snapshot()` [cypress/integration/ui-spec.js](cypress/integration/ui-spec.js) +- Capturing and saving snapshots of primitive values [cypress/e2e/unit-spec.cy.js](cypress/e2e/unit-spec.cy.js) +- Testing central data Vuex store using snapshots [cypress/e2e/store-spec.cy.js](cypress/e2e/store-spec.cy.js) +- Making assertions against a DOM element using `cy.get('todo-list').snapshot()` [cypress/e2e/ui-spec.cy.js](cypress/e2e/ui-spec.cy.js) ## Development diff --git a/examples/blogs__e2e-snapshots/cypress.config.js b/examples/blogs__e2e-snapshots/cypress.config.js new file mode 100644 index 000000000..0080abb4e --- /dev/null +++ b/examples/blogs__e2e-snapshots/cypress.config.js @@ -0,0 +1,15 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + video: false, + e2e: { + baseUrl: 'http://localhost:3700', + setupNodeEvents (on, config) { + // `on` is used to hook into various events Cypress emits + // `config` is the resolved Cypress config + on('task', { + failed: require('cypress-failed-log/src/failed')(), + }) + }, + }, +}) diff --git a/examples/blogs__e2e-snapshots/cypress.json b/examples/blogs__e2e-snapshots/cypress.json deleted file mode 100644 index be3b5ad82..000000000 --- a/examples/blogs__e2e-snapshots/cypress.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "baseUrl": "http://localhost:3700", - "video": false -} diff --git a/examples/blogs__e2e-snapshots/cypress/integration/api-spec.js b/examples/blogs__e2e-snapshots/cypress/e2e/api-spec.cy.js similarity index 100% rename from examples/blogs__e2e-snapshots/cypress/integration/api-spec.js rename to examples/blogs__e2e-snapshots/cypress/e2e/api-spec.cy.js diff --git a/examples/blogs__e2e-snapshots/cypress/integration/store-spec.js b/examples/blogs__e2e-snapshots/cypress/e2e/store-spec.cy.js similarity index 100% rename from examples/blogs__e2e-snapshots/cypress/integration/store-spec.js rename to examples/blogs__e2e-snapshots/cypress/e2e/store-spec.cy.js diff --git a/examples/blogs__e2e-snapshots/cypress/integration/ui-spec.js b/examples/blogs__e2e-snapshots/cypress/e2e/ui-spec.cy.js similarity index 100% rename from examples/blogs__e2e-snapshots/cypress/integration/ui-spec.js rename to examples/blogs__e2e-snapshots/cypress/e2e/ui-spec.cy.js diff --git a/examples/blogs__e2e-snapshots/cypress/integration/unit-spec.js b/examples/blogs__e2e-snapshots/cypress/e2e/unit-spec.cy.js similarity index 100% rename from examples/blogs__e2e-snapshots/cypress/integration/unit-spec.js rename to examples/blogs__e2e-snapshots/cypress/e2e/unit-spec.cy.js diff --git a/examples/blogs__e2e-snapshots/cypress/plugins/index.js b/examples/blogs__e2e-snapshots/cypress/plugins/index.js deleted file mode 100644 index 5d978e901..000000000 --- a/examples/blogs__e2e-snapshots/cypress/plugins/index.js +++ /dev/null @@ -1,20 +0,0 @@ -// *********************************************************** -// This example plugins/index.js can be used to load plugins -// -// You can change the location of this file or turn off loading -// the plugins file with the 'pluginsFile' configuration option. -// -// You can read more here: -// https://on.cypress.io/plugins-guide -// *********************************************************** - -// This function is called when a project is opened or re-opened (e.g. due to -// the project's config changing) - -module.exports = (on, config) => { - // `on` is used to hook into various events Cypress emits - // `config` is the resolved Cypress config - on('task', { - failed: require('cypress-failed-log/src/failed')(), - }) -} diff --git a/examples/preprocessors__flow-browserify/cypress/support/index.js b/examples/blogs__e2e-snapshots/cypress/support/e2e.js similarity index 92% rename from examples/preprocessors__flow-browserify/cypress/support/index.js rename to examples/blogs__e2e-snapshots/cypress/support/e2e.js index d68db96df..d1dd1353e 100644 --- a/examples/preprocessors__flow-browserify/cypress/support/index.js +++ b/examples/blogs__e2e-snapshots/cypress/support/e2e.js @@ -1,5 +1,5 @@ // *********************************************************** -// This example support/index.js is processed and +// This example support/e2e.js is processed and // loaded automatically before your test files. // // This is a great place to put global configuration and diff --git a/examples/blogs__element-coverage/cypress.config.js b/examples/blogs__element-coverage/cypress.config.js new file mode 100644 index 000000000..3ca1d9074 --- /dev/null +++ b/examples/blogs__element-coverage/cypress.config.js @@ -0,0 +1,11 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + env: { + 'cypress-plugin-snapshots': {}, + }, + e2e: { + baseUrl: 'http://localhost:3000', + excludeSpecPattern: ['**/*.snap", "**/__snapshot__/*'], + }, +}) diff --git a/examples/blogs__element-coverage/cypress.json b/examples/blogs__element-coverage/cypress.json deleted file mode 100644 index c1540ff22..000000000 --- a/examples/blogs__element-coverage/cypress.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "baseUrl": "http://localhost:3000", - "ignoreTestFiles": [ - "**/*.snap", - "**/__snapshot__/*" - ], - "env": { - "cypress-plugin-snapshots": {} - } -} diff --git a/examples/blogs__element-coverage/cypress/integration/spec.js b/examples/blogs__element-coverage/cypress/e2e/spec.cy.js similarity index 100% rename from examples/blogs__element-coverage/cypress/integration/spec.js rename to examples/blogs__element-coverage/cypress/e2e/spec.cy.js diff --git a/examples/blogs__element-coverage/cypress/plugins/index.js b/examples/blogs__element-coverage/cypress/plugins/index.js deleted file mode 100644 index 610fd1c3e..000000000 --- a/examples/blogs__element-coverage/cypress/plugins/index.js +++ /dev/null @@ -1,19 +0,0 @@ -// *********************************************************** -// This example plugins/index.js can be used to load plugins -// -// You can change the location of this file or turn off loading -// the plugins file with the 'pluginsFile' configuration option. -// -// You can read more here: -// https://on.cypress.io/plugins-guide -// *********************************************************** - -// This function is called when a project is opened or re-opened (e.g. due to -// the project's config changing) - -/* eslint-disable no-unused-vars */ -module.exports = (on, config) => { - // `on` is used to hook into various events Cypress emits - // `config` is the resolved Cypress config -} -/* eslint-enable no-unused-vars */ diff --git a/examples/blogs__element-coverage/cypress/support/index.js b/examples/blogs__element-coverage/cypress/support/e2e.js similarity index 100% rename from examples/blogs__element-coverage/cypress/support/index.js rename to examples/blogs__element-coverage/cypress/support/e2e.js diff --git a/examples/blogs__form-submit/cypress.config.js b/examples/blogs__form-submit/cypress.config.js new file mode 100644 index 000000000..b349b58dc --- /dev/null +++ b/examples/blogs__form-submit/cypress.config.js @@ -0,0 +1,10 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + fixturesFolder: false, + defaultCommandTimeout: 1000, + e2e: { + baseUrl: 'http://localhost:58000/', + supportFile: false, + }, +}) diff --git a/examples/blogs__form-submit/cypress.json b/examples/blogs__form-submit/cypress.json deleted file mode 100644 index 859b699df..000000000 --- a/examples/blogs__form-submit/cypress.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "baseUrl": "http://localhost:58000/", - "fixturesFolder": false, - "supportFile": false, - "pluginsFile": false, - "defaultCommandTimeout": 1000 -} diff --git a/examples/blogs__form-submit/cypress/integration/spec.js b/examples/blogs__form-submit/cypress/e2e/spec.cy.js similarity index 100% rename from examples/blogs__form-submit/cypress/integration/spec.js rename to examples/blogs__form-submit/cypress/e2e/spec.cy.js diff --git a/examples/blogs__iframes/cypress.config.js b/examples/blogs__iframes/cypress.config.js new file mode 100644 index 000000000..997a7b351 --- /dev/null +++ b/examples/blogs__iframes/cypress.config.js @@ -0,0 +1,11 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + chromeWebSecurity: false, + viewportHeight: 1000, + fixturesFolder: false, + retries: { + runMode: 2, + openMode: 0, + }, +}) diff --git a/examples/blogs__iframes/cypress.json b/examples/blogs__iframes/cypress.json deleted file mode 100644 index 4ac74066e..000000000 --- a/examples/blogs__iframes/cypress.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "chromeWebSecurity": false, - "viewportHeight": 1000, - "fixturesFolder": false, - "pluginsFile": false, - "retries": { - "runMode": 2, - "openMode": 0 - } -} diff --git a/examples/blogs__iframes/cypress/integration/button-spec.js b/examples/blogs__iframes/cypress/e2e/button-spec.cy.js similarity index 100% rename from examples/blogs__iframes/cypress/integration/button-spec.js rename to examples/blogs__iframes/cypress/e2e/button-spec.cy.js diff --git a/examples/blogs__iframes/cypress/integration/custom-command-spec.js b/examples/blogs__iframes/cypress/e2e/custom-command-spec.cy.js similarity index 100% rename from examples/blogs__iframes/cypress/integration/custom-command-spec.js rename to examples/blogs__iframes/cypress/e2e/custom-command-spec.cy.js diff --git a/examples/blogs__iframes/cypress/integration/first-spec.js b/examples/blogs__iframes/cypress/e2e/first-spec.cy.js similarity index 100% rename from examples/blogs__iframes/cypress/integration/first-spec.js rename to examples/blogs__iframes/cypress/e2e/first-spec.cy.js diff --git a/examples/blogs__iframes/cypress/integration/plugin-spec.js b/examples/blogs__iframes/cypress/e2e/plugin-spec.cy.js similarity index 100% rename from examples/blogs__iframes/cypress/integration/plugin-spec.js rename to examples/blogs__iframes/cypress/e2e/plugin-spec.cy.js diff --git a/examples/blogs__iframes/cypress/integration/single-its-spec.js b/examples/blogs__iframes/cypress/e2e/single-its-spec.cy.js similarity index 100% rename from examples/blogs__iframes/cypress/integration/single-its-spec.js rename to examples/blogs__iframes/cypress/e2e/single-its-spec.cy.js diff --git a/examples/blogs__iframes/cypress/integration/spy-on-fetch-spec.js b/examples/blogs__iframes/cypress/e2e/spy-on-fetch-spec.cy.js similarity index 100% rename from examples/blogs__iframes/cypress/integration/spy-on-fetch-spec.js rename to examples/blogs__iframes/cypress/e2e/spy-on-fetch-spec.cy.js diff --git a/examples/blogs__iframes/cypress/integration/xhr-spec.js b/examples/blogs__iframes/cypress/e2e/xhr-spec.cy.js similarity index 100% rename from examples/blogs__iframes/cypress/integration/xhr-spec.js rename to examples/blogs__iframes/cypress/e2e/xhr-spec.cy.js diff --git a/examples/blogs__iframes/cypress/support/index.js b/examples/blogs__iframes/cypress/support/e2e.js similarity index 100% rename from examples/blogs__iframes/cypress/support/index.js rename to examples/blogs__iframes/cypress/support/e2e.js diff --git a/examples/blogs__notification/README.md b/examples/blogs__notification/README.md index 2a3cc76a2..d15880eb4 100644 --- a/examples/blogs__notification/README.md +++ b/examples/blogs__notification/README.md @@ -2,7 +2,7 @@ Read the blog post [Testing the Browser Notification API](https://www.cypress.io/blog/2020/01/24/testing-the-browser-notification-api/). -You can find the sample app in [index.html](index.html) and all tests in [cypress/integration/spec.js](cypress/integration/spec.js). The tests spy / stub Notification function in various ways to check how the app handles: +You can find the sample app in [index.html](index.html) and all tests in [cypress/e2e/spec.cy.js](cypress/e2e/spec.cy.js). The tests spy / stub Notification function in various ways to check how the app handles: - permission was granted before - permission was denied before - permission was neither granted nor denied before, so the app asks the user and acts depending on the answer diff --git a/examples/blogs__notification/cypress.config.js b/examples/blogs__notification/cypress.config.js new file mode 100644 index 000000000..7ab05f85e --- /dev/null +++ b/examples/blogs__notification/cypress.config.js @@ -0,0 +1,10 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + fixturesFolder: false, + viewportHeight: 100, + viewportWidth: 200, + e2e: { + supportFile: false, + }, +}) diff --git a/examples/blogs__notification/cypress.json b/examples/blogs__notification/cypress.json deleted file mode 100644 index 17bc16b8e..000000000 --- a/examples/blogs__notification/cypress.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "pluginsFile": false, - "supportFile": false, - "fixturesFolder": false, - "viewportHeight": 100, - "viewportWidth": 200 -} diff --git a/examples/blogs__notification/cypress/integration/spec.js b/examples/blogs__notification/cypress/e2e/spec.cy.js similarity index 100% rename from examples/blogs__notification/cypress/integration/spec.js rename to examples/blogs__notification/cypress/e2e/spec.cy.js diff --git a/examples/blogs__testing-redux-store/cypress.config.js b/examples/blogs__testing-redux-store/cypress.config.js new file mode 100644 index 000000000..eb583d20c --- /dev/null +++ b/examples/blogs__testing-redux-store/cypress.config.js @@ -0,0 +1,18 @@ +const { defineConfig } = require('cypress') + +const { initPlugin } = require('cypress-plugin-snapshots/plugin') + +module.exports = defineConfig({ + env: { + 'cypress-plugin-snapshots': {}, + }, + e2e: { + baseUrl: 'http://localhost:3000', + excludeSpecPattern: ['**/*.snap', '**/__snapshot__/*'], + setupNodeEvents (on, config) { + initPlugin(on, config) + + return config + }, + }, +}) diff --git a/examples/blogs__testing-redux-store/cypress.json b/examples/blogs__testing-redux-store/cypress.json deleted file mode 100644 index 72d4f4b34..000000000 --- a/examples/blogs__testing-redux-store/cypress.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "baseUrl": "http://localhost:3000", - "ignoreTestFiles": [ - "**/*.snap", - "**/__snapshot__/*" - ], - "env": { - "cypress-plugin-snapshots": {} - } -} \ No newline at end of file diff --git a/examples/blogs__testing-redux-store/cypress/integration/__snapshots__/spec.js.snap b/examples/blogs__testing-redux-store/cypress/e2e/__snapshots__/spec.js.snap similarity index 100% rename from examples/blogs__testing-redux-store/cypress/integration/__snapshots__/spec.js.snap rename to examples/blogs__testing-redux-store/cypress/e2e/__snapshots__/spec.js.snap diff --git a/examples/blogs__testing-redux-store/cypress/integration/spec.js b/examples/blogs__testing-redux-store/cypress/e2e/spec.cy.js similarity index 100% rename from examples/blogs__testing-redux-store/cypress/integration/spec.js rename to examples/blogs__testing-redux-store/cypress/e2e/spec.cy.js diff --git a/examples/blogs__testing-redux-store/cypress/plugins/index.js b/examples/blogs__testing-redux-store/cypress/plugins/index.js deleted file mode 100644 index 3173ca1c6..000000000 --- a/examples/blogs__testing-redux-store/cypress/plugins/index.js +++ /dev/null @@ -1,7 +0,0 @@ -const { initPlugin } = require('cypress-plugin-snapshots/plugin') - -module.exports = (on, config) => { - initPlugin(on, config) - - return config -} diff --git a/examples/blogs__testing-redux-store/cypress/support/index.js b/examples/blogs__testing-redux-store/cypress/support/e2e.js similarity index 100% rename from examples/blogs__testing-redux-store/cypress/support/index.js rename to examples/blogs__testing-redux-store/cypress/support/e2e.js diff --git a/examples/blogs__use-react-devtools/README.md b/examples/blogs__use-react-devtools/README.md index 62dd7dea4..0bb5314d0 100644 --- a/examples/blogs__use-react-devtools/README.md +++ b/examples/blogs__use-react-devtools/README.md @@ -4,7 +4,7 @@ Read blog post [How to load the React DevTools extension in Cypress](https://www TicTacToe app from https://github.com/itsrave/tictactoe-react -React DevTools extension copied from installed extension in Chrome by finding its profile data folder (shown when you go to `chrome://version/` url) and copying by extension id into [4.2.1_0](4.2.1_0) folder. When Cypress launches the browser it loads this extension using path, see [cypress/plugins/index.js](cypress/plugins/index.js) +React DevTools extension copied from installed extension in Chrome by finding its profile data folder (shown when you go to `chrome://version/` url) and copying by extension id into [4.2.1_0](4.2.1_0) folder. When Cypress launches the browser it loads this extension using path, see [cypress.config.js](cypress.config.js) ## Known problems diff --git a/examples/blogs__use-react-devtools/cypress.config.js b/examples/blogs__use-react-devtools/cypress.config.js new file mode 100644 index 000000000..7a94892d7 --- /dev/null +++ b/examples/blogs__use-react-devtools/cypress.config.js @@ -0,0 +1,25 @@ +/* eslint-disable no-console */ +const { defineConfig } = require('cypress') + +const path = require('path') + +module.exports = defineConfig({ + e2e: { + setupNodeEvents (on, config) { + on('before:browser:launch', (browser, launchOptions) => { + console.log('launching browser %o', browser) + + // only load React DevTools extension when opening Chrome in interactive mode + if (browser.family === 'chromium') { + // we could also restrict the extension to only load when browser.isHeaded is true + const extensionFolder = path.resolve(__dirname, '..', '..', '4.2.1_0') + + console.log('adding React DevTools extension from', extensionFolder) + launchOptions.args.push(extensionFolder) + + return launchOptions + } + }) + }, + }, +}) diff --git a/examples/blogs__use-react-devtools/cypress.json b/examples/blogs__use-react-devtools/cypress.json deleted file mode 100644 index 0967ef424..000000000 --- a/examples/blogs__use-react-devtools/cypress.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/blogs__use-react-devtools/cypress/integration/spec.js b/examples/blogs__use-react-devtools/cypress/e2e/spec.cy.js similarity index 100% rename from examples/blogs__use-react-devtools/cypress/integration/spec.js rename to examples/blogs__use-react-devtools/cypress/e2e/spec.cy.js diff --git a/examples/blogs__use-react-devtools/cypress/plugins/index.js b/examples/blogs__use-react-devtools/cypress/plugins/index.js deleted file mode 100644 index 127aed075..000000000 --- a/examples/blogs__use-react-devtools/cypress/plugins/index.js +++ /dev/null @@ -1,21 +0,0 @@ -const path = require('path') - -/* eslint-disable no-console */ - -// eslint-disable-next-line no-unused-vars -module.exports = (on, config) => { - on('before:browser:launch', (browser, launchOptions) => { - console.log('launching browser %o', browser) - - // only load React DevTools extension when opening Chrome in interactive mode - if (browser.family === 'chromium') { - // we could also restrict the extension to only load when browser.isHeaded is true - const extensionFolder = path.resolve(__dirname, '..', '..', '4.2.1_0') - - console.log('adding React DevTools extension from', extensionFolder) - launchOptions.args.push(extensionFolder) - - return launchOptions - } - }) -} diff --git a/examples/blogs__use-react-devtools/cypress/support/index.js b/examples/blogs__use-react-devtools/cypress/support/e2e.js similarity index 100% rename from examples/blogs__use-react-devtools/cypress/support/index.js rename to examples/blogs__use-react-devtools/cypress/support/e2e.js diff --git a/examples/blogs__vue-vuex-rest/README.md b/examples/blogs__vue-vuex-rest/README.md index 66a369301..afdc915cb 100644 --- a/examples/blogs__vue-vuex-rest/README.md +++ b/examples/blogs__vue-vuex-rest/README.md @@ -10,12 +10,12 @@ Testing Vue + Vuex + REST TodoMVC using Cypress. ## Shows how to -Spec files are in [cypress/integration](cypress/integration) folder +Spec files are in [cypress/e2e](cypress/e2e) folder -- test application through the GUI in [ui-spec.js](cypress/integration/ui-spec.js) +- test application through the GUI in [ui-spec.cy.js](cypress/e2e/ui-spec.cy.js) - mock REST calls to the server -- test application through the Vuex store in [store-spec.js](cypress/integration/store-spec.js) -- test application through REST calls in [api-spec.js](cypress/integration/api-spec.js) +- test application through the Vuex store in [store-spec.cy.js](cypress/e2e/store-spec.cy.js) +- test application through REST calls in [api-spec.cy.js](cypress/e2e/api-spec.cy.js) - test text file upload ## Script commands @@ -24,6 +24,6 @@ Spec files are in [cypress/integration](cypress/integration) folder ## Speed test -Spec file [cypress/integration/speed-spec.js](cypress/integration/speed-spec.js) shows how to get test and command timings. +Spec file [cypress/e2e/speed-spec.cy.js](cypress/e2e/speed-spec.cy.js) shows how to get test and command timings. ![Speed spec](img/speed-spec.png) diff --git a/examples/blogs__vue-vuex-rest/cypress.config.js b/examples/blogs__vue-vuex-rest/cypress.config.js new file mode 100644 index 000000000..3540aa8f5 --- /dev/null +++ b/examples/blogs__vue-vuex-rest/cypress.config.js @@ -0,0 +1,61 @@ +const { defineConfig } = require('cypress') + +/* eslint-disable no-console */ +const fs = require('fs') +const path = require('path') + +const findRecord = (title) => { + const dbFilename = path.join(__dirname, 'data.json') + const contents = JSON.parse(fs.readFileSync(dbFilename)) + const todos = contents.todos + + return todos.find((record) => record.title === title) +} + +const hasRecordAsync = (title, ms) => { + const delay = 50 + + return new Promise((resolve, reject) => { + if (ms < 0) { + return reject(new Error(`Could not find record with title "${title}"`)) + } + + const found = findRecord(title) + + if (found) { + return resolve(found) + } + + setTimeout(() => { + hasRecordAsync(title, ms - delay).then(resolve, reject) + }, 50) + }) +} + +module.exports = defineConfig({ + video: false, + e2e: { + baseUrl: 'http://localhost:3000', + supportFile: false, + setupNodeEvents (on, config) { + // `on` is used to hook into various events Cypress emits + // `config` is the resolved Cypress config + on('task', { + hasSavedRecord (title, ms = 3000) { + console.log('looking for title "%s" in the database (time limit %dms)', + title, ms) + + return hasRecordAsync(title, ms) + }, + + testTimings (attributes) { + console.log('Test "%s" has finished in %dms', attributes.title, attributes.duration) + + console.table(attributes.commands) + + return null + }, + }) + }, + }, +}) diff --git a/examples/blogs__vue-vuex-rest/cypress.json b/examples/blogs__vue-vuex-rest/cypress.json deleted file mode 100644 index 861ce4cad..000000000 --- a/examples/blogs__vue-vuex-rest/cypress.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "baseUrl": "http://localhost:3000", - "video": false, - "supportFile": false -} diff --git a/examples/blogs__vue-vuex-rest/cypress/integration/api-spec.js b/examples/blogs__vue-vuex-rest/cypress/e2e/api-spec.cy.js similarity index 100% rename from examples/blogs__vue-vuex-rest/cypress/integration/api-spec.js rename to examples/blogs__vue-vuex-rest/cypress/e2e/api-spec.cy.js diff --git a/examples/blogs__vue-vuex-rest/cypress/integration/speed-spec.js b/examples/blogs__vue-vuex-rest/cypress/e2e/speed-spec.cy.js similarity index 97% rename from examples/blogs__vue-vuex-rest/cypress/integration/speed-spec.js rename to examples/blogs__vue-vuex-rest/cypress/e2e/speed-spec.cy.js index 10375fb1b..18e74899c 100644 --- a/examples/blogs__vue-vuex-rest/cypress/integration/speed-spec.js +++ b/examples/blogs__vue-vuex-rest/cypress/e2e/speed-spec.cy.js @@ -3,8 +3,8 @@ let commands = [] let testAttributes -// sends test results to the plugins process -// using cy.task https://on.cypress.io/task +// sends test results using +// cy.task https://on.cypress.io/task const sendTestTimings = () => { if (!testAttributes) { return diff --git a/examples/blogs__vue-vuex-rest/cypress/integration/store-spec.js b/examples/blogs__vue-vuex-rest/cypress/e2e/store-spec.cy.js similarity index 100% rename from examples/blogs__vue-vuex-rest/cypress/integration/store-spec.js rename to examples/blogs__vue-vuex-rest/cypress/e2e/store-spec.cy.js diff --git a/examples/blogs__vue-vuex-rest/cypress/integration/ui-spec.js b/examples/blogs__vue-vuex-rest/cypress/e2e/ui-spec.cy.js similarity index 100% rename from examples/blogs__vue-vuex-rest/cypress/integration/ui-spec.js rename to examples/blogs__vue-vuex-rest/cypress/e2e/ui-spec.cy.js diff --git a/examples/blogs__vue-vuex-rest/cypress/plugins/index.js b/examples/blogs__vue-vuex-rest/cypress/plugins/index.js deleted file mode 100644 index 064abb185..000000000 --- a/examples/blogs__vue-vuex-rest/cypress/plugins/index.js +++ /dev/null @@ -1,65 +0,0 @@ -// *********************************************************** -// This example plugins/index.js can be used to load plugins -// -// You can change the location of this file or turn off loading -// the plugins file with the 'pluginsFile' configuration option. -// -// You can read more here: -// https://on.cypress.io/plugins-guide -// *********************************************************** - -// This function is called when a project is opened or re-opened (e.g. due to -// the project's config changing) - -/* eslint-disable no-console */ - -const fs = require('fs') -const path = require('path') - -const findRecord = (title) => { - const dbFilename = path.join(__dirname, '..', '..', 'data.json') - const contents = JSON.parse(fs.readFileSync(dbFilename)) - const todos = contents.todos - - return todos.find((record) => record.title === title) -} - -const hasRecordAsync = (title, ms) => { - const delay = 50 - - return new Promise((resolve, reject) => { - if (ms < 0) { - return reject(new Error(`Could not find record with title "${title}"`)) - } - - const found = findRecord(title) - - if (found) { - return resolve(found) - } - - setTimeout(() => { - hasRecordAsync(title, ms - delay).then(resolve, reject) - }, 50) - }) -} - -module.exports = (on, config) => { - // `on` is used to hook into various events Cypress emits - // `config` is the resolved Cypress config - on('task', { - hasSavedRecord (title, ms = 3000) { - console.log('looking for title "%s" in the database (time limit %dms)', - title, ms) - - return hasRecordAsync(title, ms) - }, - - testTimings (attributes) { - console.log('Test "%s" has finished in %dms', attributes.title, attributes.duration) - console.table(attributes.commands) - - return null - }, - }) -} diff --git a/examples/extending-cypress__chai-assertions/README.md b/examples/extending-cypress__chai-assertions/README.md index 3d50c24f6..9bb3f9dcb 100644 --- a/examples/extending-cypress__chai-assertions/README.md +++ b/examples/extending-cypress__chai-assertions/README.md @@ -1,9 +1,9 @@ # Adding Chai Assertions -- Extend [`chai`](http://chaijs.com/) with the [`chai-date-string`](http://chaijs.com/plugins/chai-date-string/) assertion plugin from [cypress/support/index.js](cypress/support/index.js) so it is available in every spec file. -- Extend [`chai`](http://chaijs.com/) with the [`chai-colors`](http://chaijs.com/plugins/chai-colors/) assertion plugin in a single [spec file](cypress/integration/extending-chai-assertion-plugins-spec.js) +- Extend [`chai`](http://chaijs.com/) with the [`chai-date-string`](http://chaijs.com/plugins/chai-date-string/) assertion plugin from [cypress/support/e2e.js](cypress/support/e2e.js) so it is available in every spec file. +- Extend [`chai`](http://chaijs.com/) with the [`chai-colors`](http://chaijs.com/plugins/chai-colors/) assertion plugin in a single [spec file](cypress/e2e/extending-chai-assertion-plugins-spec.cy.js) - Globally extend [`chai`](http://chaijs.com/) for all specs. -- Write and use own Chai assertion, see [cypress/support/index.js](cypress/support/index.js) +- Write and use own Chai assertion, see [cypress/support/e2e.js](cypress/support/e2e.js) ### Code completion diff --git a/examples/extending-cypress__chai-assertions/cypress.config.js b/examples/extending-cypress__chai-assertions/cypress.config.js new file mode 100644 index 000000000..2709c41d1 --- /dev/null +++ b/examples/extending-cypress__chai-assertions/cypress.config.js @@ -0,0 +1,5 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + fixturesFolder: false, +}) diff --git a/examples/extending-cypress__chai-assertions/cypress.json b/examples/extending-cypress__chai-assertions/cypress.json deleted file mode 100644 index 1500460fe..000000000 --- a/examples/extending-cypress__chai-assertions/cypress.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "fixturesFolder": false, - "pluginsFile": false -} \ No newline at end of file diff --git a/examples/extending-cypress__chai-assertions/cypress/integration/extending-chai-assertion-plugins-spec.js b/examples/extending-cypress__chai-assertions/cypress/e2e/extending-chai-assertion-plugins-spec.cy.js similarity index 97% rename from examples/extending-cypress__chai-assertions/cypress/integration/extending-chai-assertion-plugins-spec.js rename to examples/extending-cypress__chai-assertions/cypress/e2e/extending-chai-assertion-plugins-spec.cy.js index 0f48a75fa..80186684b 100644 --- a/examples/extending-cypress__chai-assertions/cypress/integration/extending-chai-assertion-plugins-spec.js +++ b/examples/extending-cypress__chai-assertions/cypress/e2e/extending-chai-assertion-plugins-spec.cy.js @@ -23,7 +23,7 @@ describe('Chai Assertion Plugins', function () { // importing it in this file is that it's been globally // imported from our supportFile // - // if look inside cypress/support/index.js + // if look inside cypress/support/e2e.js // you'll see that we import cypress/support/assertions.js // and because the supportFile is bundled before our spec file, // it means we already have access to it diff --git a/examples/extending-cypress__chai-assertions/cypress/support/index.js b/examples/extending-cypress__chai-assertions/cypress/support/e2e.js similarity index 93% rename from examples/extending-cypress__chai-assertions/cypress/support/index.js rename to examples/extending-cypress__chai-assertions/cypress/support/e2e.js index 17259f667..795f7c30d 100644 --- a/examples/extending-cypress__chai-assertions/cypress/support/index.js +++ b/examples/extending-cypress__chai-assertions/cypress/support/e2e.js @@ -1,5 +1,5 @@ /* global chai */ -// because this file is imported from cypress/support/index.js +// because this file is imported from cypress/support/e2e.js // that means all other spec files will have this assertion plugin // available to them because the supportFile is bundled and served // prior to any spec files loading diff --git a/examples/file-upload-react/cypress.config.js b/examples/file-upload-react/cypress.config.js new file mode 100644 index 000000000..53cf629bf --- /dev/null +++ b/examples/file-upload-react/cypress.config.js @@ -0,0 +1,3 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({}) diff --git a/examples/file-upload-react/cypress/e2e/csv-file-spec.cy.js b/examples/file-upload-react/cypress/e2e/csv-file-spec.cy.js new file mode 100644 index 000000000..fe497771e --- /dev/null +++ b/examples/file-upload-react/cypress/e2e/csv-file-spec.cy.js @@ -0,0 +1,20 @@ +/// +describe('CSV file', () => { + it('parses', () => { + cy.visit('index.html') + cy.get('input#csv-file').attachFile('list.csv') + // the CSV fixture file will be parsed and + // the results will be set in the "window" property + cy.window().should('have.prop', '__csvResults') + .and('have.keys', ['data', 'errors', 'meta']) + .its('errors').should('be.empty') + + // validate the parsed list + cy.window().its('__csvResults.data').should('deep.equal', + [{ + 'First name': 'Joe', + 'Last name': 'Bravo', + }, + { 'First name': 'Mike', 'Last name': 'Smith' }]) + }) +}) diff --git a/examples/file-upload-react/cypress/e2e/spec.cy.js b/examples/file-upload-react/cypress/e2e/spec.cy.js new file mode 100644 index 000000000..56d1c8f94 --- /dev/null +++ b/examples/file-upload-react/cypress/e2e/spec.cy.js @@ -0,0 +1,37 @@ +/// +/* global File */ +describe('File upload', () => { + beforeEach(() => { + cy.visit('index.html') + }) + + it('uploads mock file and stubs the server', () => { + // mock the network call using https://on.cypress.io/intercept + cy.intercept('POST', 'https://some-server.com/upload', {}).as('upload') + // load mock data from a fixture or construct here + const testFile = new File(['data to upload'], 'upload.txt') + + cy.get('#file1').trigger('change', { testFile }) + // make sure upload has happened + cy.wait('@upload') + }) + + it('uploads mock file by stubbing axios.post', () => { + // see how to stub an object in the application environment + // https://on.cypress.io/stub + cy.window() + .its('axios') + .then((axios) => { + // save stub under an alias + cy.stub(axios, 'post').as('file-upload') + }) + + // load mock data from a fixture or construct here + const testFile = new File(['data to upload'], 'upload.txt') + + cy.get('#file1').trigger('change', { testFile }) + // check stub has been used + // https://on.cypress.io/assertions#Sinon-Chai + cy.get('@file-upload').should('have.been.calledOnce') + }) +}) diff --git a/examples/file-upload-react/cypress/e2e/upload-plugin-spec.cy.js b/examples/file-upload-react/cypress/e2e/upload-plugin-spec.cy.js new file mode 100644 index 000000000..6546a6084 --- /dev/null +++ b/examples/file-upload-react/cypress/e2e/upload-plugin-spec.cy.js @@ -0,0 +1,20 @@ +/// +// See official documentation at https://github.com/abramenal/cypress-file-upload + +describe('cypress-upload-file plugin', () => { + beforeEach(() => { + cy.visit('index.html') + }) + + it('uploads mock file', () => { + // see how to mock network calls + // https://on.cypress.io/intercept + cy.intercept('POST', 'https://some-server.com/upload', {}).as('upload') + + // finds file at cypress/fixtures/test.txt + cy.get('#file1').attachFile('test.txt') + + // make sure upload has happened + cy.wait('@upload') + }) +}) diff --git a/examples/file-upload-react/cypress/e2e/upload-via-app-spec.cy.js b/examples/file-upload-react/cypress/e2e/upload-via-app-spec.cy.js new file mode 100644 index 000000000..49d78cc22 --- /dev/null +++ b/examples/file-upload-react/cypress/e2e/upload-via-app-spec.cy.js @@ -0,0 +1,32 @@ +/// +/* global File */ +describe('File upload', () => { + beforeEach(() => { + cy.visit('index.html') + }) + + it('uploads file by stubbing application code', () => { + cy.intercept('POST', 'https://some-server.com/upload', {}).as('upload') + + // load mock data from a fixture or construct here + const testFile = new File(['data to upload'], 'upload.txt') + + // directly stub the application method that returns the File object to upload + cy.window() + .its('app') + .then((app) => { + cy.stub(app, 'getFileToUpload') + .returns(testFile) + // give this stub an alias to confirm it was called + .as('getFileToUpload') + }) + + cy.get('#file1').trigger('change', { testFile }) + + // make sure our application stub worked + cy.get('@getFileToUpload').should('have.been.calledOnce') + + // make sure upload has happened + cy.wait('@upload') + }) +}) diff --git a/examples/file-upload-react/cypress/support/e2e.js b/examples/file-upload-react/cypress/support/e2e.js new file mode 100644 index 000000000..2cde7012c --- /dev/null +++ b/examples/file-upload-react/cypress/support/e2e.js @@ -0,0 +1 @@ +import 'cypress-file-upload' diff --git a/examples/fundamentals__add-custom-command-ts/README.md b/examples/fundamentals__add-custom-command-ts/README.md index 4094090a7..04235db67 100644 --- a/examples/fundamentals__add-custom-command-ts/README.md +++ b/examples/fundamentals__add-custom-command-ts/README.md @@ -4,10 +4,10 @@ In this recipe we do not use `tsconfig.json` file, thus we need to specify additional command types using `/// ` commands, like this: ```js -// cypress/integration/spec.ts +// cypress/e2e/spec.ts /// ``` ![IntelliSense for custom command cy.dataCy](images/data-cy.png) -See [cypress/support/index.ts](cypress/support/index.ts) and [cypress/support/index.d.ts](cypress/support/index.d.ts). +See [cypress/support/e2e.ts](cypress/support/e2e.ts) and [cypress/support/index.d.ts](cypress/support/index.d.ts). diff --git a/examples/fundamentals__add-custom-command-ts/cypress.config.ts b/examples/fundamentals__add-custom-command-ts/cypress.config.ts new file mode 100644 index 000000000..cfb7562c4 --- /dev/null +++ b/examples/fundamentals__add-custom-command-ts/cypress.config.ts @@ -0,0 +1,7 @@ +import { defineConfig } from 'cypress' + +export default defineConfig({ + viewportHeight: 200, + viewportWidth: 300, + fixturesFolder: false, +}) diff --git a/examples/fundamentals__add-custom-command-ts/cypress.json b/examples/fundamentals__add-custom-command-ts/cypress.json deleted file mode 100644 index 65397445b..000000000 --- a/examples/fundamentals__add-custom-command-ts/cypress.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "viewportHeight": 200, - "viewportWidth": 300, - "pluginsFile": false, - "fixturesFolder": false -} diff --git a/examples/fundamentals__add-custom-command-ts/cypress/integration/async-command.ts b/examples/fundamentals__add-custom-command-ts/cypress/e2e/async-command.cy.ts similarity index 100% rename from examples/fundamentals__add-custom-command-ts/cypress/integration/async-command.ts rename to examples/fundamentals__add-custom-command-ts/cypress/e2e/async-command.cy.ts diff --git a/examples/fundamentals__add-custom-command-ts/cypress/integration/spec.ts b/examples/fundamentals__add-custom-command-ts/cypress/e2e/spec.ts similarity index 100% rename from examples/fundamentals__add-custom-command-ts/cypress/integration/spec.ts rename to examples/fundamentals__add-custom-command-ts/cypress/e2e/spec.ts diff --git a/examples/fundamentals__add-custom-command-ts/cypress/support/index.ts b/examples/fundamentals__add-custom-command-ts/cypress/support/e2e.ts similarity index 100% rename from examples/fundamentals__add-custom-command-ts/cypress/support/index.ts rename to examples/fundamentals__add-custom-command-ts/cypress/support/e2e.ts diff --git a/examples/fundamentals__add-custom-command/README.md b/examples/fundamentals__add-custom-command/README.md index d3e50701f..bb52b4f5e 100644 --- a/examples/fundamentals__add-custom-command/README.md +++ b/examples/fundamentals__add-custom-command/README.md @@ -59,7 +59,7 @@ As an example this spec includes 3rd party module [cypress-wait-until](https://g ## Async commands -A custom command can call an async function from the application, the resolved value will be automatically yielded to the next command or assertion in the test. See [cypress/integration/async-command.js](cypress/integration/async-command.js) file. +A custom command can call an async function from the application, the resolved value will be automatically yielded to the next command or assertion in the test. See [cypress/e2e/async-command.cy.js](cypress/e2e/async-command.cy.js) file. ![Async add custom command](images/async-add.png) diff --git a/examples/fundamentals__add-custom-command/cypress.config.js b/examples/fundamentals__add-custom-command/cypress.config.js new file mode 100644 index 000000000..2ce48aa4a --- /dev/null +++ b/examples/fundamentals__add-custom-command/cypress.config.js @@ -0,0 +1,7 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + viewportHeight: 200, + viewportWidth: 300, + fixturesFolder: false, +}) diff --git a/examples/fundamentals__add-custom-command/cypress.json b/examples/fundamentals__add-custom-command/cypress.json deleted file mode 100644 index 65397445b..000000000 --- a/examples/fundamentals__add-custom-command/cypress.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "viewportHeight": 200, - "viewportWidth": 300, - "pluginsFile": false, - "fixturesFolder": false -} diff --git a/examples/fundamentals__add-custom-command/cypress/integration/async-command.js b/examples/fundamentals__add-custom-command/cypress/e2e/async-command.cy.js similarity index 100% rename from examples/fundamentals__add-custom-command/cypress/integration/async-command.js rename to examples/fundamentals__add-custom-command/cypress/e2e/async-command.cy.js diff --git a/examples/fundamentals__add-custom-command/cypress/integration/spec.js b/examples/fundamentals__add-custom-command/cypress/e2e/spec.cy.js similarity index 100% rename from examples/fundamentals__add-custom-command/cypress/integration/spec.js rename to examples/fundamentals__add-custom-command/cypress/e2e/spec.cy.js diff --git a/examples/fundamentals__add-custom-command/cypress/support/index.js b/examples/fundamentals__add-custom-command/cypress/support/e2e.js similarity index 93% rename from examples/fundamentals__add-custom-command/cypress/support/index.js rename to examples/fundamentals__add-custom-command/cypress/support/e2e.js index 2952adebf..2842ebb8e 100644 --- a/examples/fundamentals__add-custom-command/cypress/support/index.js +++ b/examples/fundamentals__add-custom-command/cypress/support/e2e.js @@ -1,5 +1,5 @@ // *********************************************************** -// This example support/index.js is processed and +// This example support/e2e.js is processed and // loaded automatically before your test files. // // This is a great place to put global configuration and diff --git a/examples/fundamentals__chrome-remote-debugging/cypress.config.js b/examples/fundamentals__chrome-remote-debugging/cypress.config.js new file mode 100644 index 000000000..177b0775f --- /dev/null +++ b/examples/fundamentals__chrome-remote-debugging/cypress.config.js @@ -0,0 +1,101 @@ +const { defineConfig } = require('cypress') + +const CDP = require('chrome-remote-interface') +const debug = require('debug')('cypress:server:protocol') + +function ensureRdpPort (args) { + const existing = args.find( + (arg) => arg.slice(0, 23) === '--remote-debugging-port' + ) + + if (existing) { + return Number(existing.split('=')[1]) + } + + const port = 40000 + Math.round(Math.random() * 25000) + + args.push(`--remote-debugging-port=${port}`) + + return port +} + +let port = 0 +let client = null + +module.exports = defineConfig({ + fixturesFolder: false, + e2e: { + supportFile: false, + setupNodeEvents (on, config) { + on('before:browser:launch', (browser, launchOptionsOrArgs) => { + debug('browser launch args or options %o', launchOptionsOrArgs) + const args = Array.isArray(launchOptionsOrArgs) + ? launchOptionsOrArgs + : launchOptionsOrArgs.args + + port = ensureRdpPort(args) + debug('ensureRdpPort %d', port) + debug('Chrome arguments %o', args) + }) + + on('task', { + resetCRI: async () => { + if (client) { + debug('resetting CRI client') + await client.close() + client = null + } + + return Promise.resolve(true) + }, + activatePrintMediaQuery: async () => { + debug('activatePrintMediaQuery') + + client = + client || + (await CDP({ + port, + })) + + return client.send('Emulation.setEmulatedMedia', { + media: 'print', + }) + }, + activateHoverPseudo: async ({ selector }) => { + debug('activateHoverPseudo') + + client = + client || + (await CDP({ + port, + })) + + await client.DOM.enable() + await client.CSS.enable() + + // as the Window consists of two IFrames, we must retrieve the right one + const allRootNodes = await client.DOM.getFlattenedDocument() + + const isIframe = (node) => { + return node.nodeName === 'IFRAME' && node.contentDocument + } + + const filtered = allRootNodes.nodes.filter(isIframe) + + // The first IFrame is our App + const root = filtered[0].contentDocument + + const { nodeId } = await client.DOM.querySelector({ + nodeId: root.nodeId, + selector, + }) + + return client.CSS.forcePseudoState({ + nodeId, + forcedPseudoClasses: ['hover'], + }) + }, + }) + }, + }, +}) diff --git a/examples/fundamentals__chrome-remote-debugging/cypress.json b/examples/fundamentals__chrome-remote-debugging/cypress.json deleted file mode 100644 index a84f6e38c..000000000 --- a/examples/fundamentals__chrome-remote-debugging/cypress.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "fixturesFolder": false, - "supportFile": false -} diff --git a/examples/fundamentals__chrome-remote-debugging/cypress/integration/spec.js b/examples/fundamentals__chrome-remote-debugging/cypress/e2e/spec.cy.js similarity index 100% rename from examples/fundamentals__chrome-remote-debugging/cypress/integration/spec.js rename to examples/fundamentals__chrome-remote-debugging/cypress/e2e/spec.cy.js diff --git a/examples/fundamentals__chrome-remote-debugging/cypress/plugins/index.js b/examples/fundamentals__chrome-remote-debugging/cypress/plugins/index.js deleted file mode 100644 index 13692b5de..000000000 --- a/examples/fundamentals__chrome-remote-debugging/cypress/plugins/index.js +++ /dev/null @@ -1,69 +0,0 @@ -const CDP = require('chrome-remote-interface') -const debug = require('debug')('cypress:server:protocol') - -function ensureRdpPort (args) { - const existing = args.find((arg) => arg.slice(0, 23) === '--remote-debugging-port') - - if (existing) { - return Number(existing.split('=')[1]) - } - - const port = 40000 + Math.round(Math.random() * 25000) - - args.push(`--remote-debugging-port=${port}`) - - return port -} - -let port = 0 -let client = null - -module.exports = (on, config) => { - on('before:browser:launch', (browser, launchOptionsOrArgs) => { - debug('browser launch args or options %o', launchOptionsOrArgs) - const args = Array.isArray(launchOptionsOrArgs) ? launchOptionsOrArgs : launchOptionsOrArgs.args - - port = ensureRdpPort(args) - debug('ensureRdpPort %d', port) - debug('Chrome arguments %o', args) - }) - - on('task', { - resetCRI: async () => { - if (client) { - debug('resetting CRI client') - await client.close() - client = null - } - - return Promise.resolve(true) - }, - activatePrintMediaQuery: async () => { - debug('activatePrintMediaQuery') - client = client || await CDP({ port }) - - return client.send('Emulation.setEmulatedMedia', { media: 'print' }) - }, - activateHoverPseudo: async ({ selector }) => { - debug('activateHoverPseudo') - client = client || await CDP({ port }) - await client.DOM.enable() - await client.CSS.enable() - // as the Window consists of two IFrames, we must retrieve the right one - const allRootNodes = await client.DOM.getFlattenedDocument() - const isIframe = (node) => node.nodeName === 'IFRAME' && node.contentDocument - const filtered = allRootNodes.nodes.filter(isIframe) - // The first IFrame is our App - const root = filtered[0].contentDocument - const { nodeId } = await client.DOM.querySelector({ - nodeId: root.nodeId, - selector, - }) - - return client.CSS.forcePseudoState({ - nodeId, - forcedPseudoClasses: ['hover'], - }) - }, - }) -} diff --git a/examples/fundamentals__custom-browsers/README.md b/examples/fundamentals__custom-browsers/README.md index 82c24a975..8294ef18a 100644 --- a/examples/fundamentals__custom-browsers/README.md +++ b/examples/fundamentals__custom-browsers/README.md @@ -1,5 +1,7 @@ # Custom browsers +**Warning ⚠️** This example recipe has not been updated to reflect the new [Cypress configuration](https://on.cypress.io/configuration). + Cypress v3.7.0+ allows the project to customize the list of browsers. In this example, [cypress/plugins/index.js](cypress/plugins/index.js) filters the list of all browsers detected on the user's machine and only returns the bundled Electron browser. Or you could do the opposite and only allow the project to use Chrome browsers ```js diff --git a/examples/fundamentals__custom-browsers/cypress.config.js b/examples/fundamentals__custom-browsers/cypress.config.js new file mode 100644 index 000000000..de58149db --- /dev/null +++ b/examples/fundamentals__custom-browsers/cypress.config.js @@ -0,0 +1,26 @@ +const { defineConfig } = require('cypress') + +const tasks = require('./cypress/plugins/tasks') + +module.exports = defineConfig({ + fixturesFolder: false, + e2e: { + supportFile: false, + setupNodeEvents (on, config) { + on('task', tasks) + + // only filter browsers if we are passed a list - this way + // this example works on Cypress v3.7.0+ and below + if (!config.browsers) { + return + } + + // Cypress v4.0.0+ + return { + browsers: config.browsers.filter( + (browser) => browser.name === 'electron' + ), + } + }, + }, +}) diff --git a/examples/fundamentals__custom-browsers/cypress.json b/examples/fundamentals__custom-browsers/cypress.json deleted file mode 100644 index 6fffb92fd..000000000 --- a/examples/fundamentals__custom-browsers/cypress.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "supportFile": false, - "fixturesFolder": false -} diff --git a/examples/fundamentals__custom-browsers/cypress/integration/spec.js b/examples/fundamentals__custom-browsers/cypress/e2e/spec.cy.js similarity index 100% rename from examples/fundamentals__custom-browsers/cypress/integration/spec.js rename to examples/fundamentals__custom-browsers/cypress/e2e/spec.cy.js diff --git a/examples/fundamentals__custom-browsers/cypress/plugins/brave.js b/examples/fundamentals__custom-browsers/cypress/plugins/brave.js index 4de6b48dc..4dea17b23 100644 --- a/examples/fundamentals__custom-browsers/cypress/plugins/brave.js +++ b/examples/fundamentals__custom-browsers/cypress/plugins/brave.js @@ -1,4 +1,7 @@ /* eslint-disable no-console */ + +const { defineConfig } = require('cypress') + const os = require('os') const execa = require('execa') const tasks = require('./tasks') @@ -47,31 +50,35 @@ const findBraveBrowser = () => { } } -module.exports = (on, config) => { - on('task', tasks) +module.exports = defineConfig({ + e2e: { + setupNodeEvents (on, config) { + on('task', tasks) - // only filter browsers if we are passed a list - this way - // this example works on Cypress v3.7.0+ and below - if (!config.browsers) { - return - } + // only filter browsers if we are passed a list - this way + // this example works on Cypress v3.7.0+ and below + if (!config.browsers) { + return + } - // kind of hack - we don't know the Cypress version running - // so we need to look at known Electron browser - const electron = config.browsers.find((browser) => browser.name === 'electron') + // kind of hack - we don"t know the Cypress version running + // so we need to look at known Electron browser + const electron = config.browsers.find((browser) => browser.name === 'electron') - if (!electron) { - console.error('Could not find even Electron browser ⚠️') + if (!electron) { + console.error('Could not find even Electron browser ⚠️') - return - } + return + } - // Cypress v3.7.0+ - return findBraveBrowser().then((browser) => { - browser.family = electron.family + // Cypress v3.7.0+ + return findBraveBrowser().then((browser) => { + browser.family = electron.family - return { - browsers: [browser], - } - }) -} + return { + browsers: [browser], + } + }) + }, + }, +}) diff --git a/examples/fundamentals__custom-browsers/cypress/plugins/index.js b/examples/fundamentals__custom-browsers/cypress/plugins/index.js deleted file mode 100644 index 2ad770613..000000000 --- a/examples/fundamentals__custom-browsers/cypress/plugins/index.js +++ /dev/null @@ -1,16 +0,0 @@ -const tasks = require('./tasks') - -module.exports = (on, config) => { - on('task', tasks) - - // only filter browsers if we are passed a list - this way - // this example works on Cypress v3.7.0+ and below - if (!config.browsers) { - return - } - - // Cypress v4.0.0+ - return { - browsers: config.browsers.filter((browser) => browser.name === 'electron'), - } -} diff --git a/examples/fundamentals__cy-events/README.md b/examples/fundamentals__cy-events/README.md index 22220f622..e74121da2 100644 --- a/examples/fundamentals__cy-events/README.md +++ b/examples/fundamentals__cy-events/README.md @@ -2,8 +2,8 @@ For more details, see [Cypress catalogue of events](https://on.cypress.io/catalog-of-events) -- [cypress-on-spec.js](./cypress/integration/cypress-on-spec.js) shows how we can add a property to every `window` object before the app load using `Cypress.on('window:before:load', ...)` event listener -- [cy-on-spec.js](./cypress/integration/cy-on-spec.js) shows how to add a property to every `window` object before the app loads using `cy.on('window:before:load', ...)` event listener. +- [cypress-on-spec.cy.js](./cypress/e2e/cypress-on-spec.cy.js) shows how we can add a property to every `window` object before the app load using `Cypress.on('window:before:load', ...)` event listener +- [cy-on-spec.cy.js]('./cypress/e2e/cy-on-spec.cy.js) shows how to add a property to every `window` object before the app loads using `cy.on('window:before:load', ...)` event listener. ## See also diff --git a/examples/fundamentals__cy-events/cypress.config.js b/examples/fundamentals__cy-events/cypress.config.js new file mode 100644 index 000000000..4415f5033 --- /dev/null +++ b/examples/fundamentals__cy-events/cypress.config.js @@ -0,0 +1,8 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + fixturesFolder: false, + e2e: { + supportFile: false, + }, +}) diff --git a/examples/fundamentals__cy-events/cypress.json b/examples/fundamentals__cy-events/cypress.json deleted file mode 100644 index 949d560f7..000000000 --- a/examples/fundamentals__cy-events/cypress.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "pluginsFile": false, - "fixturesFolder": false, - "supportFile": false -} diff --git a/examples/fundamentals__cy-events/cypress/integration/cy-on-spec.js b/examples/fundamentals__cy-events/cypress/e2e/cy-on-spec.cy.js similarity index 100% rename from examples/fundamentals__cy-events/cypress/integration/cy-on-spec.js rename to examples/fundamentals__cy-events/cypress/e2e/cy-on-spec.cy.js diff --git a/examples/fundamentals__cy-events/cypress/integration/cypress-on-spec.js b/examples/fundamentals__cy-events/cypress/e2e/cypress-on-spec.cy.js similarity index 100% rename from examples/fundamentals__cy-events/cypress/integration/cypress-on-spec.js rename to examples/fundamentals__cy-events/cypress/e2e/cypress-on-spec.cy.js diff --git a/examples/fundamentals__dynamic-tests-from-api/README.md b/examples/fundamentals__dynamic-tests-from-api/README.md index cd86a4076..c3d6d0a3b 100644 --- a/examples/fundamentals__dynamic-tests-from-api/README.md +++ b/examples/fundamentals__dynamic-tests-from-api/README.md @@ -2,6 +2,6 @@ Sometimes you want to generate tests dynamically from data fetched from the external API. Because we cannot add more tests after the spec has already started, we need to fetch the test data _before_ the spec file starts. -We can do this from the [plugin file](./cypress/plugins/index.js) that can call the external API server, parse the returned list of test objects, and then set the list of records in the `config.env` object. This config object will be available in each spec file. You then can get the list of test records before the tests are created, see the [users-spec.js](./cypress/integration/users-spec.js) +We can do this from the [setupNodeEvents](cypress.config.js) function. We can call the external API server, parse the returned list of test objects, and then set the list of records in the `config.env` object. This config object will be available in each spec file. You then can get the list of test records before the tests are created, see the [users-spec.cy.js](./cypress/e2e/users-spec.cy.js) ![Dynamic tests](./images/users.png) diff --git a/examples/fundamentals__dynamic-tests-from-api/cypress.config.js b/examples/fundamentals__dynamic-tests-from-api/cypress.config.js new file mode 100644 index 000000000..53da365fa --- /dev/null +++ b/examples/fundamentals__dynamic-tests-from-api/cypress.config.js @@ -0,0 +1,40 @@ +/* eslint-disable no-console */ +const { defineConfig } = require('cypress') + +const got = require('got') +// Cypress tests in the "e2e" folder have access to +// the Cypress object and the bundled Cypress._ Lodash. +// The Cypress configuration does NOT and thus has +// to import any 3rd party libraries + +const _ = require('lodash') + +// This function is called when a project is opened or re-opened (e.g. due to +// the project's config changing) +module.exports = defineConfig({ + fixturesFolder: false, + e2e: { + supportFile: false, + async setupNodeEvents (on, config) { + // let's fetch the list of users + const users = await got( + 'https://jsonplaceholder.cypress.io/users?_limit=3' + ).json() + + // we are only interested in the username and ID fields + const userInfo = _.map(users, (user) => { + return _.pick(user, ['id', 'username', 'email']) + }) + + console.log('Fetched the following users for testing') + console.table(userInfo) + + // then set it inside the config object under the environment + // which will make it available via Cypress.env("users") + // before the start of the tests + config.env.users = userInfo + + return config + }, + }, +}) diff --git a/examples/fundamentals__dynamic-tests-from-api/cypress.json b/examples/fundamentals__dynamic-tests-from-api/cypress.json deleted file mode 100644 index a84f6e38c..000000000 --- a/examples/fundamentals__dynamic-tests-from-api/cypress.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "fixturesFolder": false, - "supportFile": false -} diff --git a/examples/fundamentals__dynamic-tests-from-api/cypress/integration/users-spec.js b/examples/fundamentals__dynamic-tests-from-api/cypress/e2e/users-spec.cy.js similarity index 100% rename from examples/fundamentals__dynamic-tests-from-api/cypress/integration/users-spec.js rename to examples/fundamentals__dynamic-tests-from-api/cypress/e2e/users-spec.cy.js diff --git a/examples/fundamentals__dynamic-tests-from-api/cypress/plugins/index.js b/examples/fundamentals__dynamic-tests-from-api/cypress/plugins/index.js deleted file mode 100644 index fae4b0b40..000000000 --- a/examples/fundamentals__dynamic-tests-from-api/cypress/plugins/index.js +++ /dev/null @@ -1,28 +0,0 @@ -/* eslint-disable no-console */ -const got = require('got') -// Cypress tests in the 'integration' folder have access to -// the Cypress object and the bundled Cypress._ Lodash -// The plugin file does NOT have Cypress object -// and thus has to import any 3rd party libraries -const _ = require('lodash') - -// This function is called when a project is opened or re-opened (e.g. due to -// the project's config changing) -module.exports = async (on, config) => { - // when we load the plugins file, let's fetch the list of users - const users = await got('https://jsonplaceholder.cypress.io/users?_limit=3').json() - - // we are only interested in the username and ID fields - const userInfo = _.map(users, - (user) => _.pick(user, ['id', 'username', 'email'])) - - console.log('Fetched the following users for testing') - console.table(userInfo) - - // then set it inside the config object under the environment - // which will make it available via Cypress.env("users") - // before the start of the tests - config.env.users = userInfo - - return config -} diff --git a/examples/fundamentals__dynamic-tests-from-csv/README.md b/examples/fundamentals__dynamic-tests-from-csv/README.md index df836397a..12c799ee4 100644 --- a/examples/fundamentals__dynamic-tests-from-csv/README.md +++ b/examples/fundamentals__dynamic-tests-from-csv/README.md @@ -2,16 +2,16 @@ Sometimes you want to generate tests dynamically from a CSV file. We cannot load the CSV file directly from the spec file (unless we have a special CSV file bundler), and we cannot use the `cy.readFile` command - because by then it is too late to define new tests. Thus we need to load the CSV file _before_ the spec file starts. -We can do this from the [plugin file](./cypress/plugins/index.js) that has access to the file system, can load the CSV file, parse it, then set the list of records in the `config.env` object. This config object will be available in each spec file. You then can get the list of records before the tests are created, see [csv-spec.js](./cypress/integration/csv-spec.js) +We can do this from the [setupNodeEvents](cypress.config.js) function. It has access to the file system, can load the CSV file, parse it, then set the list of records in the `config.env` object. This config object will be available in each spec file. You then can get the list of records before the tests are created, see [csv-spec.cy.js](./cypress/e2e/csv-spec.cy.js) ```js -// cypress/plugins/index.js +// `setupNodeEvents` const text = fs.readFileSync(filename, 'utf8') const csv = await neatCSV(text) config.env.usersList = csv return config -// cypress/integration/csv-spec.js +// cypress/e2e/csv-spec.cy.js const csvUsers = Cypress.env('usersList') csvUsers.forEach(user => { diff --git a/examples/fundamentals__dynamic-tests-from-csv/cypress.config.js b/examples/fundamentals__dynamic-tests-from-csv/cypress.config.js new file mode 100644 index 000000000..fcffcfa5b --- /dev/null +++ b/examples/fundamentals__dynamic-tests-from-csv/cypress.config.js @@ -0,0 +1,35 @@ +/* eslint-disable no-console */ +const { defineConfig } = require('cypress') + +const fs = require('fs') +const path = require('path') +const neatCSV = require('neat-csv') + +// This function is called when a project is opened or re-opened (e.g. due to +// the project's config changing) +module.exports = defineConfig({ + fixturesFolder: false, + e2e: { + supportFile: false, + // `on` is used to hook into various events Cypress emits + // `config` is the resolved Cypress config + async setupNodeEvents (on, config) { + // let"s load the CSV file + const filename = path.join(__dirname, 'cypress/plugins/users.csv') + + console.log('loading file', filename) + const text = fs.readFileSync(filename, 'utf8') + const csv = await neatCSV(text) + + console.log('loaded the users') + console.log(csv) + + // then set it inside the config object under the environment + // which will make it available via Cypress.env("usersList") + // before the start of the tests + config.env.usersList = csv + + return config + }, + }, +}) diff --git a/examples/fundamentals__dynamic-tests-from-csv/cypress.json b/examples/fundamentals__dynamic-tests-from-csv/cypress.json deleted file mode 100644 index a84f6e38c..000000000 --- a/examples/fundamentals__dynamic-tests-from-csv/cypress.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "fixturesFolder": false, - "supportFile": false -} diff --git a/examples/fundamentals__dynamic-tests-from-csv/cypress/integration/csv-spec.js b/examples/fundamentals__dynamic-tests-from-csv/cypress/e2e/csv-spec.cy.js similarity index 100% rename from examples/fundamentals__dynamic-tests-from-csv/cypress/integration/csv-spec.js rename to examples/fundamentals__dynamic-tests-from-csv/cypress/e2e/csv-spec.cy.js diff --git a/examples/fundamentals__dynamic-tests-from-csv/cypress/plugins/index.js b/examples/fundamentals__dynamic-tests-from-csv/cypress/plugins/index.js deleted file mode 100644 index 39868260d..000000000 --- a/examples/fundamentals__dynamic-tests-from-csv/cypress/plugins/index.js +++ /dev/null @@ -1,39 +0,0 @@ -// *********************************************************** -// This example plugins/index.js can be used to load plugins -// -// You can change the location of this file or turn off loading -// the plugins file with the 'pluginsFile' configuration option. -// -// You can read more here: -// https://on.cypress.io/plugins-guide -// *********************************************************** - -/* eslint-disable no-console */ - -// This function is called when a project is opened or re-opened (e.g. due to -// the project's config changing) -const fs = require('fs') -const path = require('path') -const neatCSV = require('neat-csv') - -module.exports = async (on, config) => { - // `on` is used to hook into various events Cypress emits - // `config` is the resolved Cypress config - - // when we load the plugins file, let's load the CSV file - const filename = path.join(__dirname, 'users.csv') - - console.log('loading file', filename) - const text = fs.readFileSync(filename, 'utf8') - const csv = await neatCSV(text) - - console.log('loaded the users') - console.log(csv) - - // then set it inside the config object under the environment - // which will make it available via Cypress.env("usersList") - // before the start of the tests - config.env.usersList = csv - - return config -} diff --git a/examples/fundamentals__dynamic-tests/README.md b/examples/fundamentals__dynamic-tests/README.md index 53d20b6f6..fb180dc69 100644 --- a/examples/fundamentals__dynamic-tests/README.md +++ b/examples/fundamentals__dynamic-tests/README.md @@ -5,7 +5,7 @@ Sometimes you want to iterate through a list of items, and for each item create - run same test against different viewport resolutions - run same test against different sub-domains of your site - generate tests based on the fetched data -- get the dynamic data from the plugin file before the tests start +- get the dynamic data from the `setupNodeEvents` function before the tests start ## Note @@ -14,18 +14,18 @@ Sometimes the data to generate tests might be dynamic and come from an external 1. you can fetch data using a script that runs _before_ Cypress starts. Save the results as a JSON file and load data using `require`. This has an advantage that the data does not change while running the tests, making debugging simpler. See suite called "generated from fixture" for an example. 2. you can fetch the dynamic data before the tests and save as a local variable or context property, then have multiple tests assert against dynamic data items. 3. you can get the data to use to create dynamic tests using [`cy.task`](https://on.cypress.io/task) -4. you can get the data during the plugin file start and place the result into `Cypress.env()` object to pass to the specs +4. you can get the data during the `setupNodeEvents` function start and place the result into `Cypress.env()` object to pass to the specs ## Examples In these repo you can find: -- [cypress/integration/list-spec.js](cypress/integration/list-spec.js) iterates through an array, creating a test for each item -- [cypress/integration/viewports-spec.js](cypress/integration/viewports-spec.js) runs the same test against different viewports -- [cypress/integration/subdomains-spec.js](cypress/integration/subdomains-spec.js) runs the same test against different urls -- [cypress/integration/fixture-spec.js](cypress/integration/fixture-spec.js) uses `require` to load JSON fixture file and generates tests for each item from the fixture. -- [cypress/integration/request-spec.js](cypress/integration/request-spec.js) fetches a list of users from an external API endpoint and creates a test for each user -- [cypress/integration/task-spec.js](cypress/integration/task-spec.js) gets a list of items by calling [`cy.task`](https://on.cypress.io/task) and then generating a test for each item -- [cypress/integration/plugin-spec.js](./cypress/integration/plugin-spec.js) gets the list of users on start up, see [cypress/plugins/index.js](./cypress/plugins/index.js) file. You can see the fetched list in the `Cypress.env()` object +- [cypress/e2e/list-spec.cy.js](cypress/e2e/list-spec.cy.js) iterates through an array, creating a test for each item +- [cypress/e2e/viewports-spec.cy.js](cypress/e2e/viewports-spec.cy.js) runs the same test against different viewports +- [cypress/e2e/subdomains-spec.cy.js](cypress/e2e/subdomains-spec.cy.js) runs the same test against different urls +- [cypress/e2e/fixture-spec.cy.js](cypress/e2e/fixture-spec.cy.js) uses `require` to load JSON fixture file and generates tests for each item from the fixture. +- [cypress/e2e/request-spec.cy.js](cypress/e2e/request-spec.cy.js) fetches a list of users from an external API endpoint and creates a test for each user +- [cypress/e2e/task-spec.cy.js](cypress/e2e/task-spec.cy.js) gets a list of items by calling [`cy.task`](https://on.cypress.io/task) and then generating a test for each item +- [cypress/e2e/user-spec.cy.js](./cypress/e2e/user-spec.cy.js) gets the list of users on start up, see the [setupNodeEvents](cypress.config.js) function. You can see the fetched list in the `Cypress.env()` object ![Cypress env object with fetched users](./images/users.png) diff --git a/examples/fundamentals__dynamic-tests/cypress.config.js b/examples/fundamentals__dynamic-tests/cypress.config.js new file mode 100644 index 000000000..4b16e520f --- /dev/null +++ b/examples/fundamentals__dynamic-tests/cypress.config.js @@ -0,0 +1,44 @@ +/* eslint-disable no-console */ +const { defineConfig } = require('cypress') + +const got = require('got') +const _ = require('lodash') + +// This function is called when a project is opened or re-opened (e.g. due to +// the project's config changing) +module.exports = defineConfig({ + chromeWebSecurity: false, + retries: { + runMode: 2, + openMode: 0, + }, + e2e: { + async setupNodeEvents (on, config) { + // `on` is used to hook into various events Cypress emits + // `config` is the resolved Cypress config + on('task', { + getData () { + return ['a', 'b', 'c'] + }, + }) + + // you can fetch the dynamic list to use to generate the data + // before any tests run (even before the browser opens) + const { body } = await got( + 'https://jsonplaceholder.cypress.io/users?_limit=5', + { + responseType: 'json', + } + ) + + // pass the data through the Cypress config object + // by storing it in the environment object. + // we are only interested in a few properties in each user object + config.env.users = _.map(body, (user) => _.pick(user, 'id', 'name', 'email')) + console.table(config.env.users) + + // IMPORTANT: return the updated config object + return config + }, + }, +}) diff --git a/examples/fundamentals__dynamic-tests/cypress.json b/examples/fundamentals__dynamic-tests/cypress.json deleted file mode 100644 index 812cf03c5..000000000 --- a/examples/fundamentals__dynamic-tests/cypress.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "chromeWebSecurity": false, - "retries": { - "runMode": 2, - "openMode": 0 - } -} diff --git a/examples/fundamentals__dynamic-tests/cypress/integration/fixture-spec.js b/examples/fundamentals__dynamic-tests/cypress/e2e/fixture-spec.cy.js similarity index 100% rename from examples/fundamentals__dynamic-tests/cypress/integration/fixture-spec.js rename to examples/fundamentals__dynamic-tests/cypress/e2e/fixture-spec.cy.js diff --git a/examples/fundamentals__dynamic-tests/cypress/integration/list-spec.js b/examples/fundamentals__dynamic-tests/cypress/e2e/list-spec.cy.js similarity index 100% rename from examples/fundamentals__dynamic-tests/cypress/integration/list-spec.js rename to examples/fundamentals__dynamic-tests/cypress/e2e/list-spec.cy.js diff --git a/examples/fundamentals__dynamic-tests/cypress/integration/request-spec.js b/examples/fundamentals__dynamic-tests/cypress/e2e/request-spec.cy.js similarity index 100% rename from examples/fundamentals__dynamic-tests/cypress/integration/request-spec.js rename to examples/fundamentals__dynamic-tests/cypress/e2e/request-spec.cy.js diff --git a/examples/fundamentals__dynamic-tests/cypress/integration/subdomains-spec.js b/examples/fundamentals__dynamic-tests/cypress/e2e/subdomains-spec.cy.js similarity index 100% rename from examples/fundamentals__dynamic-tests/cypress/integration/subdomains-spec.js rename to examples/fundamentals__dynamic-tests/cypress/e2e/subdomains-spec.cy.js diff --git a/examples/fundamentals__dynamic-tests/cypress/integration/task-spec.js b/examples/fundamentals__dynamic-tests/cypress/e2e/task-spec.cy.js similarity index 100% rename from examples/fundamentals__dynamic-tests/cypress/integration/task-spec.js rename to examples/fundamentals__dynamic-tests/cypress/e2e/task-spec.cy.js diff --git a/examples/fundamentals__dynamic-tests/cypress/integration/plugin-spec.js b/examples/fundamentals__dynamic-tests/cypress/e2e/user-spec.cy.js similarity index 86% rename from examples/fundamentals__dynamic-tests/cypress/integration/plugin-spec.js rename to examples/fundamentals__dynamic-tests/cypress/e2e/user-spec.cy.js index 318a9b2c7..27302d031 100644 --- a/examples/fundamentals__dynamic-tests/cypress/integration/plugin-spec.js +++ b/examples/fundamentals__dynamic-tests/cypress/e2e/user-spec.cy.js @@ -1,8 +1,8 @@ /// // If we do NOT know the expected number of items we can grab them -// before the spec starts running using the plugin file. -// The plugin file places the dynamic list into "Cypress.env()" object +// before the spec starts running using the `setupNodeEvents` function. +// `setupNodeEvents` places the dynamic list into "Cypress.env()" object describe('Test for each user', { retries: 2 }, () => { // Cypress.env() object is set by the time the tests start const users = Cypress.env('users') diff --git a/examples/fundamentals__dynamic-tests/cypress/integration/viewports-spec.js b/examples/fundamentals__dynamic-tests/cypress/e2e/viewports-spec.cy.js similarity index 100% rename from examples/fundamentals__dynamic-tests/cypress/integration/viewports-spec.js rename to examples/fundamentals__dynamic-tests/cypress/e2e/viewports-spec.cy.js diff --git a/examples/fundamentals__dynamic-tests/cypress/plugins/index.js b/examples/fundamentals__dynamic-tests/cypress/plugins/index.js deleted file mode 100644 index 6d9b250b7..000000000 --- a/examples/fundamentals__dynamic-tests/cypress/plugins/index.js +++ /dev/null @@ -1,42 +0,0 @@ -// *********************************************************** -// This example plugins/index.js can be used to load plugins -// -// You can change the location of this file or turn off loading -// the plugins file with the 'pluginsFile' configuration option. -// -// You can read more here: -// https://on.cypress.io/plugins-guide -// *********************************************************** - -/* eslint-disable no-console */ -const got = require('got') -const _ = require('lodash') - -// This function is called when a project is opened or re-opened (e.g. due to -// the project's config changing) - -module.exports = async (on, config) => { - // `on` is used to hook into various events Cypress emits - // `config` is the resolved Cypress config - - on('task', { - getData () { - return ['a', 'b', 'c'] - }, - }) - - // you can fetch the dynamic list to use to generate the data - // before any tests run (even before the browser opens) - const { body } = await got('https://jsonplaceholder.cypress.io/users?_limit=5', { - responseType: 'json', - }) - - // pass the data through the Cypress config object - // by storing it in the environment object. - // we are only interested in a few properties in each user object - config.env.users = _.map(body, (user) => _.pick(user, 'id', 'name', 'email')) - console.table(config.env.users) - - // IMPORTANT: return the updated config object - return config -} diff --git a/examples/fundamentals__dynamic-tests/cypress/support/index.js b/examples/fundamentals__dynamic-tests/cypress/support/e2e.js similarity index 100% rename from examples/fundamentals__dynamic-tests/cypress/support/index.js rename to examples/fundamentals__dynamic-tests/cypress/support/e2e.js diff --git a/examples/fundamentals__dynamic-tests/package.json b/examples/fundamentals__dynamic-tests/package.json index c1a226294..50d660794 100644 --- a/examples/fundamentals__dynamic-tests/package.json +++ b/examples/fundamentals__dynamic-tests/package.json @@ -6,8 +6,6 @@ "cypress:open": "../../node_modules/.bin/cypress open", "cypress:run": "../../node_modules/.bin/cypress run", "test:ci": "npm run cypress:run", - "test:ci:record": "npm run cypress:run -- --record", - "test:ci:windows": "bin-up cypress run", - "test:ci:windows:record": "bin-up cypress run --record --group dynamic-tests" + "test:ci:record": "npm run cypress:run -- --record" } } diff --git a/examples/fundamentals__errors/README.md b/examples/fundamentals__errors/README.md index e306773a3..d40d8f6c7 100644 --- a/examples/fundamentals__errors/README.md +++ b/examples/fundamentals__errors/README.md @@ -8,7 +8,7 @@ If an application throws an error, it fails the Cypress test automatically. ![Application error fails the test](./images/app-error.gif) -You can see how to ignore such errors in [cypress/integration/app-error.js](./cypress/integration/app-error.js) spec file. +You can see how to ignore such errors in [cypress/e2e/app-error.cy.js](./cypress/e2e/app-error.cy.js) spec file. ```js // inspect the caught error @@ -32,15 +32,15 @@ If a Cypress command fails, the test fails ![Test fails after it fails to find an element](./images/test-error.gif) -You can listen to the "fail" events and return false to NOT fail the test, as [cypress/integration/test-fails.js](./cypress/integration/test-fails.js) shows. +You can listen to the "fail" events and return false to NOT fail the test, as [cypress/e2e/test-fails.cy.js](./cypress/e2e/test-fails.cy.js) shows. ## Unhandled promise rejections in the application -Cypress v7+ automatically fails the test if the application has an unhandled promise rejection event. See the [cypress/integration/unhandled-promise.js](./cypress/integration/unhandled-promise.js) spec file. +Cypress v7+ automatically fails the test if the application has an unhandled promise rejection event. See the [cypress/e2e/unhandled-promise.cy.js](./cypress/e2e/unhandled-promise.cy.js) spec file. ## Unhandled promise rejections in the test code -If your test code has an unhandled promise rejection, Cypress test happily continues. You can register handlers to fail the test. See [cypress/integration/unhandled-promise-in-test.js](./cypress/integration/unhandled-promise-in-test.js), but you have two choices: +If your test code has an unhandled promise rejection, Cypress test happily continues. You can register handlers to fail the test. See [cypress/e2e/unhandled-promise-in-test.cy.js](./cypress/e2e/unhandled-promise-in-test.cy.js), but you have two choices: If the test code uses [Cypress.Promise](https://on.cypress.io/promise) API, then: diff --git a/examples/fundamentals__errors/cypress.config.js b/examples/fundamentals__errors/cypress.config.js new file mode 100644 index 000000000..4415f5033 --- /dev/null +++ b/examples/fundamentals__errors/cypress.config.js @@ -0,0 +1,8 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + fixturesFolder: false, + e2e: { + supportFile: false, + }, +}) diff --git a/examples/fundamentals__errors/cypress.json b/examples/fundamentals__errors/cypress.json deleted file mode 100644 index 949d560f7..000000000 --- a/examples/fundamentals__errors/cypress.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "pluginsFile": false, - "fixturesFolder": false, - "supportFile": false -} diff --git a/examples/fundamentals__errors/cypress/integration/app-error.js b/examples/fundamentals__errors/cypress/e2e/app-error.cy.js similarity index 100% rename from examples/fundamentals__errors/cypress/integration/app-error.js rename to examples/fundamentals__errors/cypress/e2e/app-error.cy.js diff --git a/examples/fundamentals__errors/cypress/integration/test-fails.js b/examples/fundamentals__errors/cypress/e2e/test-fails.cy.js similarity index 100% rename from examples/fundamentals__errors/cypress/integration/test-fails.js rename to examples/fundamentals__errors/cypress/e2e/test-fails.cy.js diff --git a/examples/fundamentals__errors/cypress/integration/unhandled-promise-in-test.js b/examples/fundamentals__errors/cypress/e2e/unhandled-promise-in-test.cy.js similarity index 100% rename from examples/fundamentals__errors/cypress/integration/unhandled-promise-in-test.js rename to examples/fundamentals__errors/cypress/e2e/unhandled-promise-in-test.cy.js diff --git a/examples/fundamentals__errors/cypress/integration/unhandled-promise.js b/examples/fundamentals__errors/cypress/e2e/unhandled-promise.cy.js similarity index 100% rename from examples/fundamentals__errors/cypress/integration/unhandled-promise.js rename to examples/fundamentals__errors/cypress/e2e/unhandled-promise.cy.js diff --git a/examples/fundamentals__errors/cypress/integration/unhandled-promise2.js b/examples/fundamentals__errors/cypress/e2e/unhandled-promise2.cy.js similarity index 100% rename from examples/fundamentals__errors/cypress/integration/unhandled-promise2.js rename to examples/fundamentals__errors/cypress/e2e/unhandled-promise2.cy.js diff --git a/examples/fundamentals__fixtures/README.md b/examples/fundamentals__fixtures/README.md index 6181c1323..a75caf5d4 100644 --- a/examples/fundamentals__fixtures/README.md +++ b/examples/fundamentals__fixtures/README.md @@ -1,11 +1,11 @@ # Fixtures -You can load fixture data using the [`cy.fixture()`](https://on.cypress.io/fixture) command. The tests in the [cypress/integration](cypress/integration) folder show how to: +You can load fixture data using the [`cy.fixture()`](https://on.cypress.io/fixture) command. The tests in the [cypress/e2e](cypress/e2e) folder show how to: -- Load a single file in [single-fixture-spec.js](cypress/integration/single-fixture-spec.js) -- Load multiple files using closures in [multiple-fixtures-spec.js](cypress/integration/multiple-fixtures-spec.js) -- Load multiple files once or before each test in [load-fixtures-spec.js](cypress/integration/load-fixtures-spec.js) -- Require multiple JSON fixtures in [require-fixtures-spec.js](cypress/integration/require-fixtures-spec.js) -- Iterate over a list loaded from a JSON fixture in [list-spec.js](cypress/integration/list-spec.js) +- Load a single file in [single-fixture-spec.cy.js](cypress/e2e/single-fixture-spec.cy.js) +- Load multiple files using closures in [multiple-fixtures-spec.cy.js](cypress/e2e/multiple-fixtures-spec.cy.js) +- Load multiple files once or before each test in [load-fixtures-spec.cy.js](cypress/e2e/load-fixtures-spec.cy.js) +- Require multiple JSON fixtures in [require-fixtures-spec.cy.js](cypress/e2e/require-fixtures-spec.cy.js) +- Iterate over a list loaded from a JSON fixture in [list-spec.cy.js](cypress/e2e/list-spec.cy.js) For more examples see the "Fixtures" section in the [Cypress Testing Workshop](https://github.com/cypress-io/testing-workshop-cypress). diff --git a/examples/fundamentals__fixtures/cypress.config.js b/examples/fundamentals__fixtures/cypress.config.js new file mode 100644 index 000000000..53cf629bf --- /dev/null +++ b/examples/fundamentals__fixtures/cypress.config.js @@ -0,0 +1,3 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({}) diff --git a/examples/fundamentals__fixtures/cypress.json b/examples/fundamentals__fixtures/cypress.json deleted file mode 100644 index eaf6a8861..000000000 --- a/examples/fundamentals__fixtures/cypress.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "pluginsFile": false -} \ No newline at end of file diff --git a/examples/fundamentals__fixtures/cypress/integration/list-spec.js b/examples/fundamentals__fixtures/cypress/e2e/list-spec.cy.js similarity index 100% rename from examples/fundamentals__fixtures/cypress/integration/list-spec.js rename to examples/fundamentals__fixtures/cypress/e2e/list-spec.cy.js diff --git a/examples/fundamentals__fixtures/cypress/integration/load-fixtures-spec.js b/examples/fundamentals__fixtures/cypress/e2e/load-fixtures-spec.cy.js similarity index 100% rename from examples/fundamentals__fixtures/cypress/integration/load-fixtures-spec.js rename to examples/fundamentals__fixtures/cypress/e2e/load-fixtures-spec.cy.js diff --git a/examples/fundamentals__fixtures/cypress/integration/multiple-fixtures-spec.js b/examples/fundamentals__fixtures/cypress/e2e/multiple-fixtures-spec.cy.js similarity index 100% rename from examples/fundamentals__fixtures/cypress/integration/multiple-fixtures-spec.js rename to examples/fundamentals__fixtures/cypress/e2e/multiple-fixtures-spec.cy.js diff --git a/examples/fundamentals__fixtures/cypress/integration/require-fixtures-spec.js b/examples/fundamentals__fixtures/cypress/e2e/require-fixtures-spec.cy.js similarity index 100% rename from examples/fundamentals__fixtures/cypress/integration/require-fixtures-spec.js rename to examples/fundamentals__fixtures/cypress/e2e/require-fixtures-spec.cy.js diff --git a/examples/fundamentals__fixtures/cypress/integration/sanity-js-spec.js b/examples/fundamentals__fixtures/cypress/e2e/sanity-js-spec.cy.js similarity index 61% rename from examples/fundamentals__fixtures/cypress/integration/sanity-js-spec.js rename to examples/fundamentals__fixtures/cypress/e2e/sanity-js-spec.cy.js index ced53ba6d..152fe4af6 100644 --- a/examples/fundamentals__fixtures/cypress/integration/sanity-js-spec.js +++ b/examples/fundamentals__fixtures/cypress/e2e/sanity-js-spec.cy.js @@ -7,9 +7,9 @@ const EOL = Cypress.platform === 'win32' ? '\\' : '/' /** * Joins parts of the file path using the EOL * @example - * join('cypress', 'integration') - * // "cypress/integration" on non-Windows - * // "cypress\integration" on Windows + * join('cypress', 'e2e') + * "cypress/e2e" on non-Windows + * "cypress\e2e" on Windows */ const join = (...paths) => paths.join(EOL) @@ -18,15 +18,15 @@ describe('sanity JavaScript tests', () => { it('has __dirname', () => { expect(__dirname).to.be.a('string') - // on Windows OS the directory is "cypress\integration" - // on other operating systems it is "cypress/integration" - expect(__dirname).to.equal(join('cypress', 'integration')) + // on Windows OS the directory is "cypress\e2e" + // on other operating systems it is "cypress/e2e" + expect(__dirname).to.equal(join('cypress', 'e2e')) }) it('has __filename', () => { expect(__filename).to.be.a('string') expect(__filename).to.equal( - join('cypress', 'integration', 'sanity-js-spec.js') + join('cypress', 'e2e', 'sanity-js-spec.cy.js') ) }) }) diff --git a/examples/fundamentals__fixtures/cypress/integration/single-fixture-spec.js b/examples/fundamentals__fixtures/cypress/e2e/single-fixture-spec.cy.js similarity index 100% rename from examples/fundamentals__fixtures/cypress/integration/single-fixture-spec.js rename to examples/fundamentals__fixtures/cypress/e2e/single-fixture-spec.cy.js diff --git a/examples/fundamentals__fixtures/cypress/support/index.js b/examples/fundamentals__fixtures/cypress/support/e2e.js similarity index 100% rename from examples/fundamentals__fixtures/cypress/support/index.js rename to examples/fundamentals__fixtures/cypress/support/e2e.js diff --git a/examples/fundamentals__fixtures/package.json b/examples/fundamentals__fixtures/package.json index 335418bee..d51276e20 100644 --- a/examples/fundamentals__fixtures/package.json +++ b/examples/fundamentals__fixtures/package.json @@ -6,8 +6,6 @@ "cypress:open": "../../node_modules/.bin/cypress open", "cypress:run": "../../node_modules/.bin/cypress run", "test:ci": "../../node_modules/.bin/cypress run", - "test:ci:record": "../../node_modules/.bin/cypress run --record", - "test:ci:windows": "bin-up cypress run", - "test:ci:windows:record": "bin-up cypress run --record --group fundamentals__fixtures" + "test:ci:record": "../../node_modules/.bin/cypress run --record" } } diff --git a/examples/fundamentals__module-api-wrap/cypress.config.js b/examples/fundamentals__module-api-wrap/cypress.config.js new file mode 100644 index 000000000..4415f5033 --- /dev/null +++ b/examples/fundamentals__module-api-wrap/cypress.config.js @@ -0,0 +1,8 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + fixturesFolder: false, + e2e: { + supportFile: false, + }, +}) diff --git a/examples/fundamentals__module-api-wrap/cypress.json b/examples/fundamentals__module-api-wrap/cypress.json deleted file mode 100644 index e81c35571..000000000 --- a/examples/fundamentals__module-api-wrap/cypress.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "fixturesFolder": false, - "pluginsFile": false, - "supportFile": false -} diff --git a/examples/fundamentals__module-api-wrap/cypress/integration/spec.js b/examples/fundamentals__module-api-wrap/cypress/e2e/spec.cy.js similarity index 100% rename from examples/fundamentals__module-api-wrap/cypress/integration/spec.js rename to examples/fundamentals__module-api-wrap/cypress/e2e/spec.cy.js diff --git a/examples/fundamentals__module-api/README.md b/examples/fundamentals__module-api/README.md index db64c4681..22ab799e8 100644 --- a/examples/fundamentals__module-api/README.md +++ b/examples/fundamentals__module-api/README.md @@ -18,9 +18,9 @@ require('cypress').run({ ## Example -In this recipe, execute `npm run cypress:run` script which calls [e2e-tests.js](e2e-tests.js) that finds all spec files in [cypress/integration](cypress/integration), sorts them by the last modified timestamp and runs them using Cypress one by one. +In this recipe, execute `npm run cypress:run` script which calls [e2e-tests.js](e2e-tests.js) that finds all spec files in [cypress/e2e](cypress/e2e), sorts them by the last modified timestamp and runs them using Cypress one by one. -For example, if I add a comment to `second-spec.js`, then it will be executed first +For example, if I add a comment to `second-spec.cy.js`, then it will be executed first ``` npm run cypress:run @@ -29,9 +29,9 @@ Running last modified spec first --------------------------------------------------- filename time ------------------------------------ ------------- -./cypress/integration/second-spec.js 1555069051000 -./cypress/integration/third-spec.js 1555067795000 -./cypress/integration/first-spec.js 1555067777000 +./cypress/e2e/second-spec.cy.js 1555069051000 +./cypress/e2e/third-spec.cy.js 1555067795000 +./cypress/e2e/first-spec.cy.js 1555067777000 ... Cypress output for each spec file @@ -42,9 +42,9 @@ Test run summary --------------------------------------- spec tests passes failures -------------- ----- ------ -------- -second-spec.js 1 1 0 -third-spec.js 1 1 0 -first-spec.js 1 1 0 +second-spec.cy.js 1 1 0 +third-spec.cy.js 1 1 0 +first-spec.cy.js 1 1 0 ``` **Note:** this only uses the file system modified time, thus does not work with files checked out from a Git repository - they all will have the same modified timestamp. diff --git a/examples/fundamentals__module-api/cypress.config.js b/examples/fundamentals__module-api/cypress.config.js new file mode 100644 index 000000000..2709c41d1 --- /dev/null +++ b/examples/fundamentals__module-api/cypress.config.js @@ -0,0 +1,5 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + fixturesFolder: false, +}) diff --git a/examples/fundamentals__module-api/cypress.json b/examples/fundamentals__module-api/cypress.json deleted file mode 100644 index 1500460fe..000000000 --- a/examples/fundamentals__module-api/cypress.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "fixturesFolder": false, - "pluginsFile": false -} \ No newline at end of file diff --git a/examples/fundamentals__module-api/cypress/integration/first-spec.js b/examples/fundamentals__module-api/cypress/e2e/first-spec.cy.js similarity index 100% rename from examples/fundamentals__module-api/cypress/integration/first-spec.js rename to examples/fundamentals__module-api/cypress/e2e/first-spec.cy.js diff --git a/examples/fundamentals__module-api/cypress/integration/second-spec.js b/examples/fundamentals__module-api/cypress/e2e/second-spec.cy.js similarity index 100% rename from examples/fundamentals__module-api/cypress/integration/second-spec.js rename to examples/fundamentals__module-api/cypress/e2e/second-spec.cy.js diff --git a/examples/fundamentals__module-api/cypress/integration/third-spec.js b/examples/fundamentals__module-api/cypress/e2e/third-spec.cy.js similarity index 100% rename from examples/fundamentals__module-api/cypress/integration/third-spec.js rename to examples/fundamentals__module-api/cypress/e2e/third-spec.cy.js diff --git a/examples/fundamentals__module-api/cypress/support/index.js b/examples/fundamentals__module-api/cypress/support/e2e.js similarity index 92% rename from examples/fundamentals__module-api/cypress/support/index.js rename to examples/fundamentals__module-api/cypress/support/e2e.js index 3dead829b..706cc2e24 100644 --- a/examples/fundamentals__module-api/cypress/support/index.js +++ b/examples/fundamentals__module-api/cypress/support/e2e.js @@ -1,5 +1,5 @@ // *********************************************************** -// This example support/index.js is processed and +// This example support/e2e.js is processed and // loaded automatically before your other test files. // // This is a great place to put global configuration and diff --git a/examples/fundamentals__module-api/e2e-tests.js b/examples/fundamentals__module-api/e2e-tests.js index 4cc594761..cff85393b 100644 --- a/examples/fundamentals__module-api/e2e-tests.js +++ b/examples/fundamentals__module-api/e2e-tests.js @@ -35,7 +35,7 @@ const runOneSpec = (spec) => { }) } -globby('./cypress/integration/*-spec.js') +globby('./cypress/e2e/*-spec.cy.js') .then(sortByLastModified) .then((specs) => { console.table('Running last modified spec first', specs) diff --git a/examples/fundamentals__node-modules/README.md b/examples/fundamentals__node-modules/README.md index 2a0b75daa..1a51aa1c6 100644 --- a/examples/fundamentals__node-modules/README.md +++ b/examples/fundamentals__node-modules/README.md @@ -1,7 +1,7 @@ # es2015-commonsjs-modules > Use NPM modules from Cypress specs -Thanks to the built-in JS bundler, Cypress bundles modules that use ES5 `require` and/or ES6 `import` mechanism. See [cypress/integration/es2015-commonjs-modules-spec.js](cypress/integration/es2015-commonjs-modules-spec.js) +Thanks to the built-in JS bundler, Cypress bundles modules that use ES5 `require` and/or ES6 `import` mechanism. See [cypress/e2e/es2015-commonjs-modules-spec.cy.js](cypress/e2e/es2015-commonjs-modules-spec.cy.js) - Import ES2015 modules. - Require CommonJS modules. diff --git a/examples/fundamentals__node-modules/cypress.config.js b/examples/fundamentals__node-modules/cypress.config.js new file mode 100644 index 000000000..2709c41d1 --- /dev/null +++ b/examples/fundamentals__node-modules/cypress.config.js @@ -0,0 +1,5 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + fixturesFolder: false, +}) diff --git a/examples/fundamentals__node-modules/cypress.json b/examples/fundamentals__node-modules/cypress.json deleted file mode 100644 index 1500460fe..000000000 --- a/examples/fundamentals__node-modules/cypress.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "fixturesFolder": false, - "pluginsFile": false -} \ No newline at end of file diff --git a/examples/fundamentals__node-modules/cypress/integration/es2015-commonjs-modules-spec.js b/examples/fundamentals__node-modules/cypress/e2e/es2015-commonjs-modules-spec.cy.js similarity index 98% rename from examples/fundamentals__node-modules/cypress/integration/es2015-commonjs-modules-spec.js rename to examples/fundamentals__node-modules/cypress/e2e/es2015-commonjs-modules-spec.cy.js index e37b3ebe5..98a3b9a5e 100644 --- a/examples/fundamentals__node-modules/cypress/integration/es2015-commonjs-modules-spec.js +++ b/examples/fundamentals__node-modules/cypress/e2e/es2015-commonjs-modules-spec.cy.js @@ -1,5 +1,5 @@ // By default we expect you to put global configuration -// in cypress/support/index.js. +// in cypress/support/e2e.js. // // But you can also store reusable util functions // in cypress/support and simply require them diff --git a/examples/fundamentals__node-modules/cypress/support/index.js b/examples/fundamentals__node-modules/cypress/support/e2e.js similarity index 92% rename from examples/fundamentals__node-modules/cypress/support/index.js rename to examples/fundamentals__node-modules/cypress/support/e2e.js index 1840b58c7..1c983d3b1 100644 --- a/examples/fundamentals__node-modules/cypress/support/index.js +++ b/examples/fundamentals__node-modules/cypress/support/e2e.js @@ -1,5 +1,5 @@ // *********************************************************** -// This example support/index.js is processed and +// This example support/e2e.js is processed and // loaded automatically before your other test files. // // This is a great place to put global configuration and diff --git a/examples/fundamentals__node-modules/package.json b/examples/fundamentals__node-modules/package.json index 247bd11f9..9186901ae 100644 --- a/examples/fundamentals__node-modules/package.json +++ b/examples/fundamentals__node-modules/package.json @@ -6,8 +6,6 @@ "cypress:open": "../../node_modules/.bin/cypress open", "cypress:run": "../../node_modules/.bin/cypress run", "test:ci": "../../node_modules/.bin/cypress run", - "test:ci:record": "../../node_modules/.bin/cypress run --record", - "test:ci:windows": "bin-up cypress run", - "test:ci:windows:record": "bin-up cypress run --record --group fundamentals__node_modules" + "test:ci:record": "../../node_modules/.bin/cypress run --record" } } diff --git a/examples/fundamentals__timeout/README.md b/examples/fundamentals__timeout/README.md index 3896aaead..296d09ce3 100644 --- a/examples/fundamentals__timeout/README.md +++ b/examples/fundamentals__timeout/README.md @@ -1,8 +1,8 @@ # Test timeout -The example shows how to stop a test if it takes too long to execute, similar to [Mocha's timeout](https://mochajs.org/#test-level) option. The timeout function is in [cypress/integration/timeout.js](cypress/integration/timeout.js). +The example shows how to stop a test if it takes too long to execute, similar to [Mocha's timeout](https://mochajs.org/#test-level) option. The timeout function is in [cypress/e2e/timeout.cy.js](cypress/e2e/timeout.cy.js). -You can set timeout inside the test only, see [cypress/integration/spec.js](cypress/integration/spec.js) +You can set timeout inside the test only, see [cypress/e2e/spec.cy.js](cypress/e2e/spec.cy.js) ```js // this test fails after two seconds due to timeout @@ -14,4 +14,4 @@ it('does not finish long tests', () => { ![Test is too long](images/test-is-too-long.png) -You can set global timeout that applies to every test, see [cypress/integration/all-tests-spec.js](cypress/integration/all-tests-spec.js) using `Cypress.on('test:before:run' ...` event +You can set global timeout that applies to every test, see [cypress/e2e/all-tests-spec.cy.js](cypress/e2e/all-tests-spec.cy.js) using `Cypress.on('test:before:run' ...` event diff --git a/examples/fundamentals__timeout/cypress.config.js b/examples/fundamentals__timeout/cypress.config.js new file mode 100644 index 000000000..1b6aac414 --- /dev/null +++ b/examples/fundamentals__timeout/cypress.config.js @@ -0,0 +1,9 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + fixturesFolder: false, + e2e: { + supportFile: false, + specPattern: 'cypress/e2e/**/*.cy.{js,jsx,ts,tsx}', + }, +}) diff --git a/examples/fundamentals__timeout/cypress.json b/examples/fundamentals__timeout/cypress.json deleted file mode 100644 index cae247b9b..000000000 --- a/examples/fundamentals__timeout/cypress.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "fixturesFolder": false, - "pluginsFile": false, - "supportFile": false, - "testFiles": "**/*spec.js" -} diff --git a/examples/fundamentals__timeout/cypress/integration/all-tests-spec.js b/examples/fundamentals__timeout/cypress/e2e/all-tests-spec.cy.js similarity index 96% rename from examples/fundamentals__timeout/cypress/integration/all-tests-spec.js rename to examples/fundamentals__timeout/cypress/e2e/all-tests-spec.cy.js index a962e2112..a9a3be987 100644 --- a/examples/fundamentals__timeout/cypress/integration/all-tests-spec.js +++ b/examples/fundamentals__timeout/cypress/e2e/all-tests-spec.cy.js @@ -1,6 +1,6 @@ /// -import { seconds, testTimeout } from './timeout' +import { seconds, testTimeout } from './timeout.cy' describe('Global timeout of 3 seconds', () => { // Let's try to time limit _every test_ diff --git a/examples/fundamentals__timeout/cypress/integration/spec.js b/examples/fundamentals__timeout/cypress/e2e/spec.cy.js similarity index 91% rename from examples/fundamentals__timeout/cypress/integration/spec.js rename to examples/fundamentals__timeout/cypress/e2e/spec.cy.js index 9cbf29708..2c73b8e38 100644 --- a/examples/fundamentals__timeout/cypress/integration/spec.js +++ b/examples/fundamentals__timeout/cypress/e2e/spec.cy.js @@ -1,6 +1,6 @@ /// -import { seconds, testTimeout } from './timeout' +import { seconds, testTimeout } from './timeout.cy' describe('Sets timeout in every test', () => { // this test runs fine, because it finishes diff --git a/examples/fundamentals__timeout/cypress/integration/timeout.js b/examples/fundamentals__timeout/cypress/e2e/timeout.cy.js similarity index 100% rename from examples/fundamentals__timeout/cypress/integration/timeout.js rename to examples/fundamentals__timeout/cypress/e2e/timeout.cy.js diff --git a/examples/fundamentals__typescript/README.Md b/examples/fundamentals__typescript/README.Md index b5df6eb00..af97dd6c7 100644 --- a/examples/fundamentals__typescript/README.Md +++ b/examples/fundamentals__typescript/README.Md @@ -4,7 +4,7 @@ From Cypress 4.4.0, you can write tests in TypeScript without setting up preprocessors. See [the official doc](https://on.cypress.io/typescript-support) for more details. - Use out-of-the-box TypeScript. -- Write spec, plugin, support files in TypeScript. +- Write spec files, support files and configuration in TypeScript. - Define type for the custom commands. - Check types in the spec files. - Show difference between Test Runner `window` and `AUTWindow` types. And how to extend `AUTWindow` type. diff --git a/examples/fundamentals__typescript/cypress.config.js b/examples/fundamentals__typescript/cypress.config.js new file mode 100644 index 000000000..76b973b96 --- /dev/null +++ b/examples/fundamentals__typescript/cypress.config.js @@ -0,0 +1,7 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + e2e: { + specPattern: 'cypress/e2e/**/*.cy.{js,jsx,ts,tsx}', + }, +}) diff --git a/examples/fundamentals__typescript/cypress.json b/examples/fundamentals__typescript/cypress.json deleted file mode 100644 index 0967ef424..000000000 --- a/examples/fundamentals__typescript/cypress.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/fundamentals__typescript/cypress/integration/tests.spec.ts b/examples/fundamentals__typescript/cypress/e2e/tests.spec.cy.ts similarity index 100% rename from examples/fundamentals__typescript/cypress/integration/tests.spec.ts rename to examples/fundamentals__typescript/cypress/e2e/tests.spec.cy.ts diff --git a/examples/fundamentals__typescript/cypress/plugins/index.ts b/examples/fundamentals__typescript/cypress/plugins/index.ts deleted file mode 100644 index aba156038..000000000 --- a/examples/fundamentals__typescript/cypress/plugins/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -/// - -export default (on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions) => { - -} diff --git a/examples/fundamentals__typescript/cypress/support/index.ts b/examples/fundamentals__typescript/cypress/support/e2e.js similarity index 92% rename from examples/fundamentals__typescript/cypress/support/index.ts rename to examples/fundamentals__typescript/cypress/support/e2e.js index d68db96df..d1dd1353e 100644 --- a/examples/fundamentals__typescript/cypress/support/index.ts +++ b/examples/fundamentals__typescript/cypress/support/e2e.js @@ -1,5 +1,5 @@ // *********************************************************** -// This example support/index.js is processed and +// This example support/e2e.js is processed and // loaded automatically before your test files. // // This is a great place to put global configuration and diff --git a/examples/fundamentals__typescript/cypress/types.d.ts b/examples/fundamentals__typescript/cypress/types.d.ts index c3e43e81a..7da9eea39 100644 --- a/examples/fundamentals__typescript/cypress/types.d.ts +++ b/examples/fundamentals__typescript/cypress/types.d.ts @@ -2,7 +2,6 @@ // in most of the cases, simple will do. /// /// -/// /// /// /// diff --git a/examples/fundamentals__typescript/package.json b/examples/fundamentals__typescript/package.json index cc93f318e..0725e6043 100644 --- a/examples/fundamentals__typescript/package.json +++ b/examples/fundamentals__typescript/package.json @@ -9,7 +9,6 @@ "lint": "../../node_modules/.bin/tslint --project ./tsconfig.json", "postlint": "npm run tsc", "test:ci": "../../node_modules/.bin/cypress run", - "test:ci:windows": "bin-up cypress run", "tsc": "../../node_modules/.bin/tsc --pretty --noEmit" } } diff --git a/examples/fundamentals__typescript/tsconfig.json b/examples/fundamentals__typescript/tsconfig.json index 698a066e7..f3fea11d0 100644 --- a/examples/fundamentals__typescript/tsconfig.json +++ b/examples/fundamentals__typescript/tsconfig.json @@ -1,7 +1,7 @@ // This file is required to make `npm run tsc` work. { "include": [ - "cypress/integration/*.ts", - "cypress/integration/**/*.ts", + "cypress/e2e/*.ts", + "cypress/e2e/**/*.ts", ] } diff --git a/examples/fundamentals__window-size/README.md b/examples/fundamentals__window-size/README.md index 00776faeb..6b34ae2b8 100644 --- a/examples/fundamentals__window-size/README.md +++ b/examples/fundamentals__window-size/README.md @@ -4,7 +4,7 @@ The browser window, the command log, and the application's iframe sizes are printed. -The [plugin file](./cypress/plugins/index.js) increases the browser window size when running in the headless mode to produce high quality video. See [launch api](https://on.cypress.io/browser-launch-api) for more documentation. +The [setupNodeEvents](cypress.config.js) function increases the browser window size when running in the headless mode to produce high quality video. See [launch api](https://on.cypress.io/browser-launch-api) for more documentation. **Note:** increasing the browser window size seems to not work very well in Electron browser diff --git a/examples/fundamentals__window-size/cypress.config.js b/examples/fundamentals__window-size/cypress.config.js new file mode 100644 index 000000000..3aa1ae83d --- /dev/null +++ b/examples/fundamentals__window-size/cypress.config.js @@ -0,0 +1,62 @@ +/* eslint-disable no-console */ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + fixturesFolder: false, + e2e: { + supportFile: false, + setupNodeEvents (on, config) { + // configure plugins here + on('task', { + log ({ message, o }) { + console.log(message) + + if (o) { + console.log(JSON.stringify(o, null, 2)) + } + + return null + }, + }) + + // let's increase the browser window size when running headlessly + // this will produce higher resolution images and videos + // https://on.cypress.io/browser-launch-api + on('before:browser:launch', (browser = {}, launchOptions) => { + console.log( + 'launching browser %s is headless? %s', + browser.name, + browser.isHeadless + ) + + // the browser width and height we want to get + // our screenshots and videos will be of that resolution + const width = 1920 + const height = 1080 + + console.log('setting the browser window size to %d x %d', width, height) + + if (browser.name === 'chrome' && browser.isHeadless) { + launchOptions.args.push(`--window-size=${width},${height}`) + + // force screen to be non-retina and just use our given resolution + launchOptions.args.push('--force-device-scale-factor=1') + } + + if (browser.name === 'electron' && browser.isHeadless) { + // might not work on CI for some reason + launchOptions.preferences.width = width + + launchOptions.preferences.height = height + } + + if (browser.name === 'firefox' && browser.isHeadless) { + launchOptions.args.push(`--width=${width}`) + launchOptions.args.push(`--height=${height}`) + } + + return launchOptions + }) + }, + }, +}) diff --git a/examples/fundamentals__window-size/cypress.json b/examples/fundamentals__window-size/cypress.json deleted file mode 100644 index a84f6e38c..000000000 --- a/examples/fundamentals__window-size/cypress.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "fixturesFolder": false, - "supportFile": false -} diff --git a/examples/fundamentals__window-size/cypress/integration/spec.js b/examples/fundamentals__window-size/cypress/e2e/spec.cy.js similarity index 90% rename from examples/fundamentals__window-size/cypress/integration/spec.js rename to examples/fundamentals__window-size/cypress/e2e/spec.cy.js index 48e52ea62..ee4fb796b 100644 --- a/examples/fundamentals__window-size/cypress/integration/spec.js +++ b/examples/fundamentals__window-size/cypress/e2e/spec.cy.js @@ -3,8 +3,8 @@ describe('window size', () => { /** * Collects window and iframe sizes in pixels and prints - * them to the command log. Also sends the to the plugins file - * via cy.task to be printed in the terminal + * them to the command log. Also sends the to the `setupNodeEvents` + * function via cy.task to be printed in the terminal */ const logSizes = () => { // let's get the total opened browser dimensions @@ -15,7 +15,7 @@ describe('window size', () => { cy.task('log', { message: 'browser window', o: { windowWidth, windowHeight } }, { log: false }) // part of the browser window is taken up the command log - const commandLog = window.top.document.querySelector('.reporter-wrap') + const commandLog = window.top.document.querySelector('.container') const commandLogWidth = commandLog.offsetWidth const commandLogHeight = commandLog.offsetHeight diff --git a/examples/fundamentals__window-size/cypress/plugins/index.js b/examples/fundamentals__window-size/cypress/plugins/index.js deleted file mode 100644 index d6756489e..000000000 --- a/examples/fundamentals__window-size/cypress/plugins/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/* eslint-disable no-console */ -module.exports = function (on, config) { - // configure plugins here - on('task', { - log ({ message, o }) { - console.log(message) - if (o) { - console.log(JSON.stringify(o, null, 2)) - } - - return null - }, - }) - - // let's increase the browser window size when running headlessly - // this will produce higher resolution images and videos - // https://on.cypress.io/browser-launch-api - on('before:browser:launch', (browser = {}, launchOptions) => { - console.log('launching browser %s is headless? %s', browser.name, browser.isHeadless) - - // the browser width and height we want to get - // our screenshots and videos will be of that resolution - const width = 1920 - const height = 1080 - - console.log('setting the browser window size to %d x %d', width, height) - - if (browser.name === 'chrome' && browser.isHeadless) { - launchOptions.args.push(`--window-size=${width},${height}`) - - // force screen to be non-retina and just use our given resolution - launchOptions.args.push('--force-device-scale-factor=1') - } - - if (browser.name === 'electron' && browser.isHeadless) { - // might not work on CI for some reason - launchOptions.preferences.width = width - launchOptions.preferences.height = height - } - - if (browser.name === 'firefox' && browser.isHeadless) { - launchOptions.args.push(`--width=${width}`) - launchOptions.args.push(`--height=${height}`) - } - - return launchOptions - }) -} diff --git a/examples/logging-in__basic-auth/README.md b/examples/logging-in__basic-auth/README.md index 51d123b56..badc0db15 100644 --- a/examples/logging-in__basic-auth/README.md +++ b/examples/logging-in__basic-auth/README.md @@ -3,4 +3,4 @@ Shows how to visit the page protected by the [Basic Authentication](https://deve The static site from [public folder](./public) is protected by the basic authentication, see [server.js](./server.js). -The [cypress/integration/spec.js](./cypress/integration/spec.js) shows how to pass the username and the password when calling [cy.visit](https://on.cypress.io/visit) and [cy.request](https://on.cypress.io/request) commands. +The [cypress/e2e/spec.cy.js](./cypress/e2e/spec.cy.js) shows how to pass the username and the password when calling [cy.visit](https://on.cypress.io/visit) and [cy.request](https://on.cypress.io/request) commands. diff --git a/examples/logging-in__basic-auth/cypress.config.js b/examples/logging-in__basic-auth/cypress.config.js new file mode 100644 index 000000000..344b34436 --- /dev/null +++ b/examples/logging-in__basic-auth/cypress.config.js @@ -0,0 +1,11 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + fixturesFolder: false, + viewportHeight: 200, + viewportWidth: 200, + e2e: { + baseUrl: 'http://localhost:7065', + supportFile: false, + }, +}) diff --git a/examples/logging-in__basic-auth/cypress.json b/examples/logging-in__basic-auth/cypress.json deleted file mode 100644 index 8bc398548..000000000 --- a/examples/logging-in__basic-auth/cypress.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "baseUrl": "http://localhost:7065", - "fixturesFolder": false, - "pluginsFile": false, - "supportFile": false, - "viewportHeight": 200, - "viewportWidth": 200 -} diff --git a/examples/logging-in__basic-auth/cypress/integration/spec.js b/examples/logging-in__basic-auth/cypress/e2e/spec.cy.js similarity index 100% rename from examples/logging-in__basic-auth/cypress/integration/spec.js rename to examples/logging-in__basic-auth/cypress/e2e/spec.cy.js diff --git a/examples/logging-in__csrf-tokens/README.md b/examples/logging-in__csrf-tokens/README.md index b081a7997..9dad1f87f 100644 --- a/examples/logging-in__csrf-tokens/README.md +++ b/examples/logging-in__csrf-tokens/README.md @@ -12,7 +12,7 @@ If you start this application with `npm start` and open `localhost:7076` you wil - Expose CSRF via a route. - Disable CSRF when not in production. -The tests in [cypress/integration/logging-in-csrf-tokens-spec.js](cypress/integration/logging-in-csrf-tokens-spec.js) show various approaches to logging with CSRF token, utilizing [`cy.request`](https://on.cypress.io/request) to log in. +The tests in [cypress/e2e/logging-in-csrf-tokens-spec.cy.js](cypress/e2e/logging-in-csrf-tokens-spec.cy.js) show various approaches to logging with CSRF token, utilizing [`cy.request`](https://on.cypress.io/request) to log in. ![Tests](images/tests.png) diff --git a/examples/logging-in__csrf-tokens/cypress.config.js b/examples/logging-in__csrf-tokens/cypress.config.js new file mode 100644 index 000000000..a509449fe --- /dev/null +++ b/examples/logging-in__csrf-tokens/cypress.config.js @@ -0,0 +1,9 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + fixturesFolder: false, + e2e: { + baseUrl: 'http://localhost:7076', + supportFile: false, + }, +}) diff --git a/examples/logging-in__csrf-tokens/cypress.json b/examples/logging-in__csrf-tokens/cypress.json deleted file mode 100644 index 83f91b2a0..000000000 --- a/examples/logging-in__csrf-tokens/cypress.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "baseUrl": "http://localhost:7076", - "fixturesFolder": false, - "pluginsFile": false, - "supportFile": false -} \ No newline at end of file diff --git a/examples/logging-in__csrf-tokens/cypress/integration/logging-in-csrf-tokens-spec.js b/examples/logging-in__csrf-tokens/cypress/e2e/logging-in-csrf-tokens-spec.cy.js similarity index 100% rename from examples/logging-in__csrf-tokens/cypress/integration/logging-in-csrf-tokens-spec.js rename to examples/logging-in__csrf-tokens/cypress/e2e/logging-in-csrf-tokens-spec.cy.js diff --git a/examples/logging-in__html-web-forms/README.md b/examples/logging-in__html-web-forms/README.md index 32cc13427..0b64843e9 100644 --- a/examples/logging-in__html-web-forms/README.md +++ b/examples/logging-in__html-web-forms/README.md @@ -1,6 +1,6 @@ # logging-in-html-web-form -The tests in [cypress/integration/logging-in-html-web-form-spec.js](cypress/integration/logging-in-html-web-form-spec.js) show how log into protected website using a regular form like this: +The tests in [cypress/e2e/logging-in-html-web-form-spec.cy.js](cypress/e2e/logging-in-html-web-form-spec.cy.js) show how log into protected website using a regular form like this: ![Login form](images/login.png) diff --git a/examples/logging-in__html-web-forms/cypress.config.js b/examples/logging-in__html-web-forms/cypress.config.js new file mode 100644 index 000000000..9b0268a82 --- /dev/null +++ b/examples/logging-in__html-web-forms/cypress.config.js @@ -0,0 +1,9 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + fixturesFolder: false, + e2e: { + baseUrl: 'http://localhost:7077', + supportFile: false, + }, +}) diff --git a/examples/logging-in__html-web-forms/cypress.json b/examples/logging-in__html-web-forms/cypress.json deleted file mode 100644 index b7d7b63ea..000000000 --- a/examples/logging-in__html-web-forms/cypress.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "baseUrl": "http://localhost:7077", - "fixturesFolder": false, - "pluginsFile": false, - "supportFile": false -} \ No newline at end of file diff --git a/examples/logging-in__html-web-forms/cypress/integration/logging-in-html-web-form-spec.js b/examples/logging-in__html-web-forms/cypress/e2e/logging-in-html-web-form-spec.cy.js similarity index 100% rename from examples/logging-in__html-web-forms/cypress/integration/logging-in-html-web-form-spec.js rename to examples/logging-in__html-web-forms/cypress/e2e/logging-in-html-web-form-spec.cy.js diff --git a/examples/logging-in__jwt/README.md b/examples/logging-in__jwt/README.md index 003881444..7680615d5 100644 --- a/examples/logging-in__jwt/README.md +++ b/examples/logging-in__jwt/README.md @@ -36,5 +36,5 @@ All Ajax requests to the protected resources need to have `Authorization` header ## Tests -- [cypress/integration/using-ui-spec.js](cypress/integration/using-ui-spec.js) tests the login user interface form -- [cypress/integration/spec.js](cypress/integration/spec.js) shows how to log in once using [cy.request](https://on.cypress.io/request) and then set the JWT in the `localStorage` to log in instantly before each test +- [cypress/e2e/using-ui-spec.cy.js](cypress/e2e/using-ui-spec.cy.js) tests the login user interface form +- [cypress/e2e/spec.cy.js](cypress/e2e/spec.cy.js) shows how to log in once using [cy.request](https://on.cypress.io/request) and then set the JWT in the `localStorage` to log in instantly before each test diff --git a/examples/logging-in__jwt/cypress.config.js b/examples/logging-in__jwt/cypress.config.js new file mode 100644 index 000000000..82232e570 --- /dev/null +++ b/examples/logging-in__jwt/cypress.config.js @@ -0,0 +1,13 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + fixturesFolder: false, + env: { + username: 'test', + password: 'test', + }, + e2e: { + baseUrl: 'http://localhost:8081', + supportFile: false, + }, +}) diff --git a/examples/logging-in__jwt/cypress.json b/examples/logging-in__jwt/cypress.json deleted file mode 100644 index 9ea4767cf..000000000 --- a/examples/logging-in__jwt/cypress.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "baseUrl": "http://localhost:8081", - "env": { - "username": "test", - "password": "test" - }, - "fixturesFolder": false, - "pluginsFile": false, - "supportFile": false -} \ No newline at end of file diff --git a/examples/logging-in__jwt/cypress/integration/spec.js b/examples/logging-in__jwt/cypress/e2e/spec.cy.js similarity index 100% rename from examples/logging-in__jwt/cypress/integration/spec.js rename to examples/logging-in__jwt/cypress/e2e/spec.cy.js diff --git a/examples/logging-in__jwt/cypress/integration/using-ui-spec.js b/examples/logging-in__jwt/cypress/e2e/using-ui-spec.cy.js similarity index 100% rename from examples/logging-in__jwt/cypress/integration/using-ui-spec.js rename to examples/logging-in__jwt/cypress/e2e/using-ui-spec.cy.js diff --git a/examples/logging-in__single-sign-on/README.md b/examples/logging-in__single-sign-on/README.md index 99e7d20bc..531fe9761 100644 --- a/examples/logging-in__single-sign-on/README.md +++ b/examples/logging-in__single-sign-on/README.md @@ -1,14 +1,14 @@ # logging-in-single-sign-on > Login when authentication is done on a 3rd party server. -The app server [app_server.js](app_server.js) runs on port 7074 and the auth server [auth_server.js](auth_server.js) runs on port 7075. File [cypress/integration/logging-in-single-sign-on-spec.js](cypress/integration/logging-in-single-sign-on-spec.js) describes the overall authentication flow and implements tests that follow it. +The app server [app_server.js](app_server.js) runs on port 7074 and the auth server [auth_server.js](auth_server.js) runs on port 7075. File [cypress/e2e/logging-in-single-sign-on-spec.cy.js](cypress/e2e/logging-in-single-sign-on-spec.cy.js) describes the overall authentication flow and implements tests that follow it. The tests show how to: - Login when authentication is done on a 3rd party server. - Automatically parse tokens using [`cy.request()`](https://on.cypress.io/request) and set as cookies - Manually set tokens on local storage (similar to SPA flow). -- Map external hosts like `auth.corp.com:7075` and point to local servers `127.0.0.1:7075` in [cypress.json](cypress.json) +- Map external hosts like `auth.corp.com:7075` and point to local servers `127.0.0.1:7075` in [cypress.config.js](cypress.config.js) - Get the authentication token just once and set it before each test (should make tests faster) **tip** to start the server and run Cypress GUI use script `npm run dev` diff --git a/examples/logging-in__single-sign-on/cypress.config.js b/examples/logging-in__single-sign-on/cypress.config.js new file mode 100644 index 000000000..3f800b44b --- /dev/null +++ b/examples/logging-in__single-sign-on/cypress.config.js @@ -0,0 +1,11 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + hosts: { + 'auth.corp.com': '127.0.0.1', + }, + fixturesFolder: false, + e2e: { + baseUrl: 'http://localhost:7074', + }, +}) diff --git a/examples/logging-in__single-sign-on/cypress.json b/examples/logging-in__single-sign-on/cypress.json deleted file mode 100644 index c9d58cc56..000000000 --- a/examples/logging-in__single-sign-on/cypress.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "baseUrl": "http://localhost:7074", - "hosts": { - "auth.corp.com": "127.0.0.1" - }, - "fixturesFolder": false, - "pluginsFile": false -} \ No newline at end of file diff --git a/examples/logging-in__single-sign-on/cypress/integration/logging-in-single-sign-on-spec.js b/examples/logging-in__single-sign-on/cypress/e2e/logging-in-single-sign-on-spec.cy.js similarity index 99% rename from examples/logging-in__single-sign-on/cypress/integration/logging-in-single-sign-on-spec.js rename to examples/logging-in__single-sign-on/cypress/e2e/logging-in-single-sign-on-spec.cy.js index 7d2e3b276..7b20bf636 100644 --- a/examples/logging-in__single-sign-on/cypress/integration/logging-in-single-sign-on-spec.js +++ b/examples/logging-in__single-sign-on/cypress/e2e/logging-in-single-sign-on-spec.cy.js @@ -6,7 +6,7 @@ // There is a web security restriction in Cypress that prevents // you from visiting two different super domains in the same test -// without setting {chromeWebSecurity: false} in cypress.json. +// without setting {chromeWebSecurity: false} in cypress.config.js. // However this restriction is easy to bypass (and is much more // performant and less brittle) with cy.request @@ -19,7 +19,7 @@ // NOTE: We are able to use auth.corp.com without modifying our // local /etc/hosts file because cypress supports hosts mapping -// in cypress.json +// in cypress.config.js // Most 3rd party authentication works like this: diff --git a/examples/blogs__e2e-snapshots/cypress/support/index.js b/examples/logging-in__single-sign-on/cypress/support/e2e.js similarity index 92% rename from examples/blogs__e2e-snapshots/cypress/support/index.js rename to examples/logging-in__single-sign-on/cypress/support/e2e.js index d68db96df..d1dd1353e 100644 --- a/examples/blogs__e2e-snapshots/cypress/support/index.js +++ b/examples/logging-in__single-sign-on/cypress/support/e2e.js @@ -1,5 +1,5 @@ // *********************************************************** -// This example support/index.js is processed and +// This example support/e2e.js is processed and // loaded automatically before your test files. // // This is a great place to put global configuration and diff --git a/examples/logging-in__using-app-code/README.md b/examples/logging-in__using-app-code/README.md index 3a0700627..8fbd84939 100644 --- a/examples/logging-in__using-app-code/README.md +++ b/examples/logging-in__using-app-code/README.md @@ -3,10 +3,10 @@ Application copied from [../logging-in__jwt](../logging-in__jwt) example. -This example shows how you can use your own application code to log in. The "normal" application logs in at [src/_services/user.service.js](src/_services/user.service.js) given username and password. From our [cypress/integration/spec.js](cypress/integration/spec.js) file, we can import this service and use [`cy.wrap()`](https://on.cypress.io/wrap) to wait for the returned promise to resolve before continuing with the test. +This example shows how you can use your own application code to log in. The "normal" application logs in at [src/_services/user.service.js](src/_services/user.service.js) given username and password. From our [cypress/e2e/spec.cy.js](cypress/e2e/spec.cy.js) file, we can import this service and use [`cy.wrap()`](https://on.cypress.io/wrap) to wait for the returned promise to resolve before continuing with the test. ![Passing test](images/login.png) The spec also shows how to wrap application code in a custom command, which is automatically wrapped. -**note:** in order to import the login service, we need to bundle the spec code using the same webpack bundler configuration as the application code. We do it by using the [cypress-webpack-preprocessor](https://github.com/cypress-io/cypress-webpack-preprocessor), see [cypress/plugins/index.js](cypress/plugins/index.js) +**note:** in order to import the login service, we need to bundle the spec code using the same webpack bundler configuration as the application code. We do it by using the [cypress-webpack-preprocessor](https://github.com/cypress-io/cypress-webpack-preprocessor), see [cypress.config.js](cypress.config.js) diff --git a/examples/logging-in__using-app-code/cypress.config.js b/examples/logging-in__using-app-code/cypress.config.js new file mode 100644 index 000000000..93d434a16 --- /dev/null +++ b/examples/logging-in__using-app-code/cypress.config.js @@ -0,0 +1,25 @@ +const { defineConfig } = require('cypress') + +const webpack = require('@cypress/webpack-preprocessor') + +module.exports = defineConfig({ + env: { + username: 'test', + password: 'test', + }, + e2e: { + baseUrl: 'http://localhost:8081', + supportFile: false, + setupNodeEvents (on, config) { + // bundle spec files using same webpack logic as "normal" application + const options = { + // send in the options from your webpack.config.js, so it works the same + // as your app's code + webpackOptions: require('./webpack.config'), + watchOptions: {}, + } + + on('file:preprocessor', webpack(options)) + }, + }, +}) diff --git a/examples/logging-in__using-app-code/cypress.json b/examples/logging-in__using-app-code/cypress.json deleted file mode 100644 index 21d11bd15..000000000 --- a/examples/logging-in__using-app-code/cypress.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "baseUrl": "http://localhost:8081", - "env": { - "username": "test", - "password": "test" - }, - "supportFile": false -} \ No newline at end of file diff --git a/examples/logging-in__using-app-code/cypress/integration/spec.js b/examples/logging-in__using-app-code/cypress/e2e/spec.cy.js similarity index 100% rename from examples/logging-in__using-app-code/cypress/integration/spec.js rename to examples/logging-in__using-app-code/cypress/e2e/spec.cy.js diff --git a/examples/logging-in__using-app-code/cypress/plugins/index.js b/examples/logging-in__using-app-code/cypress/plugins/index.js deleted file mode 100644 index 718e2f099..000000000 --- a/examples/logging-in__using-app-code/cypress/plugins/index.js +++ /dev/null @@ -1,13 +0,0 @@ -const webpack = require('@cypress/webpack-preprocessor') - -module.exports = (on) => { - // bundle spec files using same webpack logic as "normal" application - const options = { - // send in the options from your webpack.config.js, so it works the same - // as your app's code - webpackOptions: require('../../webpack.config'), - watchOptions: {}, - } - - on('file:preprocessor', webpack(options)) -} diff --git a/examples/logging-in__xhr-web-forms/README.md b/examples/logging-in__xhr-web-forms/README.md index 5dc18ecfc..b70e3ca3c 100644 --- a/examples/logging-in__xhr-web-forms/README.md +++ b/examples/logging-in__xhr-web-forms/README.md @@ -14,12 +14,12 @@ See the login XHR code in [login.hbs](login.hbs) - Bypass needing to use your actual UI. - Increase speed of testing with [`cy.request()`](https://on.cypress.io/request). -Test files in [cypress/integration](cypress/integration) folder show: +Test files in [cypress/e2e](cypress/e2e) folder show: -- in [logging-in-xhr-web-form-spec.js](cypress/integration/logging-in-xhr-web-form-spec.js) how to log in using the UI -- in [logging-via-request-spec.js](cypress/integration/logging-via-request-spec.js) how to login using [`cy.request`](https://on.cypress.io/request) -- in [custom-command-spec.js](cypress/integration/custom-command-spec.js) how to write a custom `cy.loginByJSON` command to abstract the quick login using `cy.request` -- in [slow-login-spec.js](cypress/integration/slow-login-spec.js) how to login just once and then reuse the session cookie in each test +- in [logging-in-xhr-web-form-spec.cy.js](cypress/e2e/logging-in-xhr-web-form-spec.cy.js) how to log in using the UI +- in [logging-via-request-spec.cy.js](cypress/e2e/logging-via-request-spec.cy.js) how to login using [`cy.request`](https://on.cypress.io/request) +- in [custom-command-spec.cy.js](cypress/e2e/custom-command-spec.cy.js) how to write a custom `cy.loginByJSON` command to abstract the quick login using `cy.request` +- in [slow-login-spec.cy.js](cypress/e2e/slow-login-spec.cy.js) how to login just once and then reuse the session cookie in each test **tip** to start the server and run Cypress GUI use script `npm run dev` diff --git a/examples/logging-in__xhr-web-forms/cypress.config.js b/examples/logging-in__xhr-web-forms/cypress.config.js new file mode 100644 index 000000000..ea6b981fa --- /dev/null +++ b/examples/logging-in__xhr-web-forms/cypress.config.js @@ -0,0 +1,9 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + fixturesFolder: false, + e2e: { + baseUrl: 'http://localhost:7079', + supportFile: false, + }, +}) diff --git a/examples/logging-in__xhr-web-forms/cypress.json b/examples/logging-in__xhr-web-forms/cypress.json deleted file mode 100644 index 20a32bc65..000000000 --- a/examples/logging-in__xhr-web-forms/cypress.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "baseUrl": "http://localhost:7079", - "fixturesFolder": false, - "pluginsFile": false, - "supportFile": false -} \ No newline at end of file diff --git a/examples/logging-in__xhr-web-forms/cypress/integration/custom-command-spec.js b/examples/logging-in__xhr-web-forms/cypress/e2e/custom-command-spec.cy.js similarity index 100% rename from examples/logging-in__xhr-web-forms/cypress/integration/custom-command-spec.js rename to examples/logging-in__xhr-web-forms/cypress/e2e/custom-command-spec.cy.js diff --git a/examples/logging-in__xhr-web-forms/cypress/integration/logging-in-xhr-web-form-spec.js b/examples/logging-in__xhr-web-forms/cypress/e2e/logging-in-xhr-web-form-spec.cy.js similarity index 100% rename from examples/logging-in__xhr-web-forms/cypress/integration/logging-in-xhr-web-form-spec.js rename to examples/logging-in__xhr-web-forms/cypress/e2e/logging-in-xhr-web-form-spec.cy.js diff --git a/examples/logging-in__xhr-web-forms/cypress/integration/logging-via-request-spec.js b/examples/logging-in__xhr-web-forms/cypress/e2e/logging-via-request-spec.cy.js similarity index 100% rename from examples/logging-in__xhr-web-forms/cypress/integration/logging-via-request-spec.js rename to examples/logging-in__xhr-web-forms/cypress/e2e/logging-via-request-spec.cy.js diff --git a/examples/logging-in__xhr-web-forms/cypress/integration/slow-login-spec.js b/examples/logging-in__xhr-web-forms/cypress/e2e/slow-login-spec.cy.js similarity index 100% rename from examples/logging-in__xhr-web-forms/cypress/integration/slow-login-spec.js rename to examples/logging-in__xhr-web-forms/cypress/e2e/slow-login-spec.cy.js diff --git a/examples/preprocessors__flow-browserify/README.md b/examples/preprocessors__flow-browserify/README.md index e591c2972..3ffe550d4 100644 --- a/examples/preprocessors__flow-browserify/README.md +++ b/examples/preprocessors__flow-browserify/README.md @@ -12,6 +12,6 @@ and [@babel/preset-flow](https://github.com/babel/babel/tree/master/packages/bab `npm install --save-dev @cypress/browserify-preprocessor @babel/preset-flow` See: -- [cypress/plugins/index.js](cypress/plugins/index.js) -- [example test](cypress/integration/spec.js) +- [cypress.config.js](cypress.config.js) +- [example test](cypress/e2e/spec.cy.js) - [support/add.js](cypress/support/add.js) diff --git a/examples/preprocessors__flow-browserify/cypress.config.js b/examples/preprocessors__flow-browserify/cypress.config.js new file mode 100644 index 000000000..5ebc36ea0 --- /dev/null +++ b/examples/preprocessors__flow-browserify/cypress.config.js @@ -0,0 +1,16 @@ +const { defineConfig } = require("cypress") + +const browserify = require("@cypress/browserify-preprocessor") + +module.exports = defineConfig({ + fixturesFolder: false, + e2e: { + setupNodeEvents(on, config) { + const options = browserify.defaultOptions + options.browserifyOptions.transform[1][1].presets.push( + "@babel/preset-flow" + ) + on("file:preprocessor", browserify(options)) + }, + }, +}) diff --git a/examples/preprocessors__flow-browserify/cypress.json b/examples/preprocessors__flow-browserify/cypress.json deleted file mode 100644 index 4ec54f375..000000000 --- a/examples/preprocessors__flow-browserify/cypress.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "fixturesFolder": false -} diff --git a/examples/preprocessors__flow-browserify/cypress/integration/spec.js b/examples/preprocessors__flow-browserify/cypress/e2e/spec.cy.js similarity index 100% rename from examples/preprocessors__flow-browserify/cypress/integration/spec.js rename to examples/preprocessors__flow-browserify/cypress/e2e/spec.cy.js diff --git a/examples/preprocessors__flow-browserify/cypress/plugins/index.js b/examples/preprocessors__flow-browserify/cypress/plugins/index.js deleted file mode 100644 index 888c05c76..000000000 --- a/examples/preprocessors__flow-browserify/cypress/plugins/index.js +++ /dev/null @@ -1,8 +0,0 @@ -const browserify = require('@cypress/browserify-preprocessor') - -module.exports = (on, config) => { - const options = browserify.defaultOptions - - options.browserifyOptions.transform[1][1].presets.push('@babel/preset-flow') - on('file:preprocessor', browserify(options)) -} diff --git a/examples/logging-in__single-sign-on/cypress/support/index.js b/examples/preprocessors__flow-browserify/cypress/support/e2e.js similarity index 92% rename from examples/logging-in__single-sign-on/cypress/support/index.js rename to examples/preprocessors__flow-browserify/cypress/support/e2e.js index d68db96df..d1dd1353e 100644 --- a/examples/logging-in__single-sign-on/cypress/support/index.js +++ b/examples/preprocessors__flow-browserify/cypress/support/e2e.js @@ -1,5 +1,5 @@ // *********************************************************** -// This example support/index.js is processed and +// This example support/e2e.js is processed and // loaded automatically before your test files. // // This is a great place to put global configuration and diff --git a/examples/preprocessors__grep/README.md b/examples/preprocessors__grep/README.md index a179cc60b..c077857f0 100644 --- a/examples/preprocessors__grep/README.md +++ b/examples/preprocessors__grep/README.md @@ -33,7 +33,7 @@ produces ```text Running: feature-a.js... (1 of 2) -picking tests to run in file cypress/integration/feature-a.js +picking tests to run in file cypress/e2e/feature-a.js feature A @@ -45,7 +45,7 @@ picking tests to run in file cypress/integration/feature-a.js 2 pending Running: feature-b.js... (2 of 2) -picking tests to run in file cypress/integration/feature-b.js +picking tests to run in file cypress/e2e/feature-b.js feature B @@ -99,4 +99,4 @@ $ npm run cypress:run -- --env grep='feature A' ## Details -See [cypress/plugins/index.js](cypress/plugins/index.js) file how to configure test selection preprocessor, built on top of [Cypress Browserify preprocessor](https://github.com/cypress-io/cypress-browserify-preprocessor). +See the [setupNodeEvents](cypress.config.js) function for how to configure test selection preprocessor, built on top of [Cypress Browserify preprocessor](https://github.com/cypress-io/cypress-browserify-preprocessor). diff --git a/examples/preprocessors__grep/cypress.config.js b/examples/preprocessors__grep/cypress.config.js new file mode 100644 index 000000000..f2f8098cb --- /dev/null +++ b/examples/preprocessors__grep/cypress.config.js @@ -0,0 +1,12 @@ +const { defineConfig } = require('cypress') + +const selectTestsWithGrep = require('cypress-select-tests/grep') + +module.exports = defineConfig({ + e2e: { + supportFile: false, + setupNodeEvents (on, config) { + on('file:preprocessor', selectTestsWithGrep(config)) + }, + }, +}) diff --git a/examples/preprocessors__grep/cypress.json b/examples/preprocessors__grep/cypress.json deleted file mode 100644 index 0967ef424..000000000 --- a/examples/preprocessors__grep/cypress.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/preprocessors__grep/cypress/integration/feature-a.js b/examples/preprocessors__grep/cypress/e2e/feature-a.cy.js similarity index 100% rename from examples/preprocessors__grep/cypress/integration/feature-a.js rename to examples/preprocessors__grep/cypress/e2e/feature-a.cy.js diff --git a/examples/preprocessors__grep/cypress/integration/feature-b.js b/examples/preprocessors__grep/cypress/e2e/feature-b.cy.js similarity index 100% rename from examples/preprocessors__grep/cypress/integration/feature-b.js rename to examples/preprocessors__grep/cypress/e2e/feature-b.cy.js diff --git a/examples/preprocessors__grep/cypress/plugins/index.js b/examples/preprocessors__grep/cypress/plugins/index.js deleted file mode 100644 index d4dee4527..000000000 --- a/examples/preprocessors__grep/cypress/plugins/index.js +++ /dev/null @@ -1,5 +0,0 @@ -const selectTestsWithGrep = require('cypress-select-tests/grep') - -module.exports = (on, config) => { - on('file:preprocessor', selectTestsWithGrep(config)) -} diff --git a/examples/preprocessors__grep/cypress/support/index.js b/examples/preprocessors__grep/cypress/support/index.js deleted file mode 100644 index 2b0545c63..000000000 --- a/examples/preprocessors__grep/cypress/support/index.js +++ /dev/null @@ -1 +0,0 @@ -// no additional commands diff --git a/examples/preprocessors__typescript-browserify/README.md b/examples/preprocessors__typescript-browserify/README.md index dc9341568..6efc5816d 100644 --- a/examples/preprocessors__typescript-browserify/README.md +++ b/examples/preprocessors__typescript-browserify/README.md @@ -7,5 +7,5 @@ via [@cypress/browserify-preprocessor](https://github.com/cypress-io/cypress-bro See: - [tsconfig.json](tsconfig.json) -- [cypress/plugins/index.js](cypress/plugins/index.js) -- [example test](cypress/integration/spec.ts) +- [cypress.config.js](cypress.config.js) +- [example test](cypress/e2e/spec.ts) diff --git a/examples/preprocessors__typescript-browserify/cypress.config.js b/examples/preprocessors__typescript-browserify/cypress.config.js new file mode 100644 index 000000000..b060c42b7 --- /dev/null +++ b/examples/preprocessors__typescript-browserify/cypress.config.js @@ -0,0 +1,17 @@ +const { defineConfig } = require('cypress') + +const browserify = require('@cypress/browserify-preprocessor') + +module.exports = defineConfig({ + fixturesFolder: false, + e2e: { + supportFile: false, + setupNodeEvents (on, config) { + const options = { + typescript: require.resolve('typescript'), + } + + on('file:preprocessor', browserify(options)) + }, + }, +}) diff --git a/examples/preprocessors__typescript-browserify/cypress.json b/examples/preprocessors__typescript-browserify/cypress.json deleted file mode 100644 index abee5fa74..000000000 --- a/examples/preprocessors__typescript-browserify/cypress.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "fixturesFolder": false, - "supportFile": false -} \ No newline at end of file diff --git a/examples/preprocessors__typescript-browserify/cypress/integration/spec.ts b/examples/preprocessors__typescript-browserify/cypress/e2e/spec.cy.ts similarity index 100% rename from examples/preprocessors__typescript-browserify/cypress/integration/spec.ts rename to examples/preprocessors__typescript-browserify/cypress/e2e/spec.cy.ts diff --git a/examples/preprocessors__typescript-browserify/cypress/plugins/index.js b/examples/preprocessors__typescript-browserify/cypress/plugins/index.js deleted file mode 100644 index 6e6f03bd8..000000000 --- a/examples/preprocessors__typescript-browserify/cypress/plugins/index.js +++ /dev/null @@ -1,9 +0,0 @@ -const browserify = require('@cypress/browserify-preprocessor') - -module.exports = (on) => { - const options = { - typescript: require.resolve('typescript'), - } - - on('file:preprocessor', browserify(options)) -} diff --git a/examples/preprocessors__typescript-webpack/README.md b/examples/preprocessors__typescript-webpack/README.md index f29d55d51..b44040e65 100644 --- a/examples/preprocessors__typescript-webpack/README.md +++ b/examples/preprocessors__typescript-webpack/README.md @@ -17,8 +17,8 @@ Because this recipe is part of the monorepo with lots of examples, we don't want ## See - [webpack.config.js](webpack.config.js) -- [cypress/plugins/index.js](cypress/plugins/index.js) -- [cypress/integration/spec.ts](cypress/integration/spec.ts) +- [cypress.config.js](cypress.config.js) +- [cypress/e2e/spec.ts](cypress/e2e/spec.ts) ## Run diff --git a/examples/preprocessors__typescript-webpack/cypress.config.js b/examples/preprocessors__typescript-webpack/cypress.config.js new file mode 100644 index 000000000..d0b14a86c --- /dev/null +++ b/examples/preprocessors__typescript-webpack/cypress.config.js @@ -0,0 +1,17 @@ +const { defineConfig } = require('cypress') + +const wp = require('@cypress/webpack-preprocessor') + +module.exports = defineConfig({ + fixturesFolder: false, + e2e: { + supportFile: 'cypress/support/e2e.ts', + setupNodeEvents (on, config) { + const options = { + webpackOptions: require('./webpack.config'), + } + + on('file:preprocessor', wp(options)) + }, + }, +}) diff --git a/examples/preprocessors__typescript-webpack/cypress.json b/examples/preprocessors__typescript-webpack/cypress.json deleted file mode 100644 index 3eb1d8870..000000000 --- a/examples/preprocessors__typescript-webpack/cypress.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "supportFile": "cypress/support/index.ts", - "fixturesFolder": false -} \ No newline at end of file diff --git a/examples/preprocessors__typescript-webpack/cypress/integration/spec.ts b/examples/preprocessors__typescript-webpack/cypress/e2e/spec.cy.ts similarity index 94% rename from examples/preprocessors__typescript-webpack/cypress/integration/spec.ts rename to examples/preprocessors__typescript-webpack/cypress/e2e/spec.cy.ts index c29815abc..135b4194c 100644 --- a/examples/preprocessors__typescript-webpack/cypress/integration/spec.ts +++ b/examples/preprocessors__typescript-webpack/cypress/e2e/spec.cy.ts @@ -41,9 +41,9 @@ describe('TypeScript', () => { // cy.boo() // }) - it('adds numbers', () => { - expect(add(2, 3)).to.equal(5) - }) + // it('adds numbers', () => { + // expect(add(2, 3)).to.equal(5) + // }) it('uses custom command cy.foo()', () => { cy.foo().should('be.equal', 'foo') diff --git a/examples/preprocessors__typescript-webpack/cypress/plugins/index.js b/examples/preprocessors__typescript-webpack/cypress/plugins/index.js deleted file mode 100644 index 38db3be51..000000000 --- a/examples/preprocessors__typescript-webpack/cypress/plugins/index.js +++ /dev/null @@ -1,9 +0,0 @@ -const wp = require('@cypress/webpack-preprocessor') - -module.exports = (on) => { - const options = { - webpackOptions: require('../../webpack.config'), - } - - on('file:preprocessor', wp(options)) -} diff --git a/examples/preprocessors__typescript-webpack/cypress/support/commands.ts b/examples/preprocessors__typescript-webpack/cypress/support/commands.ts index a10420678..049a34897 100644 --- a/examples/preprocessors__typescript-webpack/cypress/support/commands.ts +++ b/examples/preprocessors__typescript-webpack/cypress/support/commands.ts @@ -35,6 +35,6 @@ Cypress.Commands.add('foo', () => 'foo') declare namespace Cypress { // tslint:disable-next-line interface-name interface Chainable { - foo: () => string + foo: () => Chainable } } diff --git a/examples/preprocessors__typescript-webpack/cypress/support/e2e.ts b/examples/preprocessors__typescript-webpack/cypress/support/e2e.ts new file mode 100644 index 000000000..ed5730de1 --- /dev/null +++ b/examples/preprocessors__typescript-webpack/cypress/support/e2e.ts @@ -0,0 +1,20 @@ +// *********************************************************** +// This example support/e2e.ts is processed and +// loaded automatically before your test files. +// +// This is a great place to put global configuration and +// behavior that modifies Cypress. +// +// You can change the location of this file or turn off +// automatically serving support files with the +// 'supportFile' configuration option. +// +// You can read more here: +// https://on.cypress.io/configuration +// *********************************************************** + +// Import commands.js using ES2015 syntax: +import './commands' + +// Alternatively you can use CommonJS syntax: +// require('./commands') diff --git a/examples/preprocessors__typescript-webpack/cypress/support/index.ts b/examples/preprocessors__typescript-webpack/cypress/support/index.ts deleted file mode 100644 index d68db96df..000000000 --- a/examples/preprocessors__typescript-webpack/cypress/support/index.ts +++ /dev/null @@ -1,20 +0,0 @@ -// *********************************************************** -// This example support/index.js is processed and -// loaded automatically before your test files. -// -// This is a great place to put global configuration and -// behavior that modifies Cypress. -// -// You can change the location of this file or turn off -// automatically serving support files with the -// 'supportFile' configuration option. -// -// You can read more here: -// https://on.cypress.io/configuration -// *********************************************************** - -// Import commands.js using ES2015 syntax: -import './commands' - -// Alternatively you can use CommonJS syntax: -// require('./commands') diff --git a/examples/preprocessors__typescript-webpack/package.json b/examples/preprocessors__typescript-webpack/package.json index aeaf22b28..c110d7661 100644 --- a/examples/preprocessors__typescript-webpack/package.json +++ b/examples/preprocessors__typescript-webpack/package.json @@ -3,7 +3,7 @@ "version": "1.0.0", "description": "Example showing TypeScript tests with Cypress", "scripts": { - "build": "../../node_modules/.bin/webpack --output-filename out.js --entry ./cypress/integration/*.ts", + "build": "../../node_modules/.bin/webpack --output-filename out.js --entry ./cypress/e2e/*.ts", "cypress:open": "../../node_modules/.bin/cypress open", "precypress:run": "npm run lint", "cypress:run": "../../node_modules/.bin/cypress run", diff --git a/examples/server-communication__bootstrapping-your-app/README.md b/examples/server-communication__bootstrapping-your-app/README.md index 9efe5a256..43badfc16 100644 --- a/examples/server-communication__bootstrapping-your-app/README.md +++ b/examples/server-communication__bootstrapping-your-app/README.md @@ -6,7 +6,7 @@ - Stub an XHR to seed with test data. - Wait on an XHR to finish. -See [cypress/integration/bootstrapping_your_app_spec.js](cypress/integration/bootstrapping_your_app_spec.js) for two solutions. +See [cypress/e2e/bootstrapping_your_app_spec.cy.js](cypress/e2e/bootstrapping_your_app_spec.cy.js) for two solutions. ## 1. Injecting object into `window` diff --git a/examples/server-communication__bootstrapping-your-app/cypress.config.js b/examples/server-communication__bootstrapping-your-app/cypress.config.js new file mode 100644 index 000000000..b329a2224 --- /dev/null +++ b/examples/server-communication__bootstrapping-your-app/cypress.config.js @@ -0,0 +1,8 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + e2e: { + baseUrl: 'http://localhost:7070', + supportFile: false, + }, +}) diff --git a/examples/server-communication__bootstrapping-your-app/cypress.json b/examples/server-communication__bootstrapping-your-app/cypress.json deleted file mode 100644 index 085015766..000000000 --- a/examples/server-communication__bootstrapping-your-app/cypress.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "baseUrl": "http://localhost:7070", - "pluginsFile": false, - "supportFile": false -} \ No newline at end of file diff --git a/examples/server-communication__bootstrapping-your-app/cypress/integration/bootstrapping_your_app_spec.js b/examples/server-communication__bootstrapping-your-app/cypress/e2e/bootstrapping_your_app_spec.cy.js similarity index 100% rename from examples/server-communication__bootstrapping-your-app/cypress/integration/bootstrapping_your_app_spec.js rename to examples/server-communication__bootstrapping-your-app/cypress/e2e/bootstrapping_your_app_spec.cy.js diff --git a/examples/server-communication__env-variables/.env b/examples/server-communication__env-variables/.env index be60f62e9..8c7889d62 100644 --- a/examples/server-communication__env-variables/.env +++ b/examples/server-communication__env-variables/.env @@ -1,4 +1,4 @@ -# these variables will be read by the plugins file +# these variables will be read by the `setupNodeEvents` function in the Cypress configuration FOO=42 BAR=baz USER_NAME=aTester diff --git a/examples/server-communication__env-variables/README.md b/examples/server-communication__env-variables/README.md index e1a5adb8b..bac57db2f 100644 --- a/examples/server-communication__env-variables/README.md +++ b/examples/server-communication__env-variables/README.md @@ -2,7 +2,7 @@ This recipe shows how to pass [environment variables to your tests](https://on.cypress.io/environment-variables) -- See [package.json](package.json) file which runs Cypress with environment variables set. The variables that start with `CYPRESS_` are extracted automatically. Other variables are copied from `process.env` in the script [cypress/plugins/index.js](cypress/plugins/index.js) -- Additional variables can be passed via `env` object in [cypress.json](cypress.json) -- Extract any other variable from `process.env` using `cypress/plugins/index.js` callback. -- Uses [dotenv](https://github.com/motdotla/dotenv#readme) package to read the `.env` file in the plugins file +- See [package.json](package.json) file which runs Cypress with environment variables set. The variables that start with `CYPRESS_` are extracted automatically. Other variables are copied from `process.env` in the [setupNodeEvents](cypress.config.js) function +- Additional variables can be passed via `env` object in [cypress.config.js](cypress.config.js) +- Extract any other variable from `process.env` using the `setupNodeEvents` function. +- Uses [dotenv](https://github.com/motdotla/dotenv#readme) package to read the `.env` file in the Cypress configuraton diff --git a/examples/server-communication__env-variables/cypress.config.js b/examples/server-communication__env-variables/cypress.config.js new file mode 100644 index 000000000..83917e3e6 --- /dev/null +++ b/examples/server-communication__env-variables/cypress.config.js @@ -0,0 +1,31 @@ +/* eslint-disable no-console */ +const { defineConfig } = require('cypress') + +// load the environment variables from the local .env file +require('dotenv').config() + +// This function is called when a project is opened or re-opened (e.g. due to +// the project's config changing) +module.exports = defineConfig({ + env: { + 'my-var': 'ok', + }, + fixturesFolder: false, + e2e: { + supportFile: false, + setupNodeEvents (on, config) { + // we can grab some process environment variables + // and stick it into config.env before returning the updated config + config.env = config.env || {} + + // you could extract only specific variables + // and rename them if necessary + config.env.FOO = process.env.FOO + config.env.BAR = process.env.BAR + config.env.username = process.env.USER_NAME + console.log('extended config.env with process.env.{FOO, BAR, USER_NAME}') + + return config + }, + }, +}) diff --git a/examples/server-communication__env-variables/cypress.json b/examples/server-communication__env-variables/cypress.json deleted file mode 100644 index 71c4d5da2..000000000 --- a/examples/server-communication__env-variables/cypress.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "env": { - "my-var": "ok" - }, - "fixturesFolder": false, - "supportFile": false -} \ No newline at end of file diff --git a/examples/server-communication__env-variables/cypress/integration/spec.js b/examples/server-communication__env-variables/cypress/e2e/spec.cy.js similarity index 91% rename from examples/server-communication__env-variables/cypress/integration/spec.js rename to examples/server-communication__env-variables/cypress/e2e/spec.cy.js index e41a103a6..0320c89b8 100644 --- a/examples/server-communication__env-variables/cypress/integration/spec.js +++ b/examples/server-communication__env-variables/cypress/e2e/spec.cy.js @@ -1,13 +1,14 @@ /// // https://on.cypress.io/environment-variables describe('process environment variables', () => { - it('has variable my-var from cypress.json', () => { + it('has variable my-var from cypress.config.js', () => { expect(Cypress.env('my-var')).to.equal('ok') }) it('has variables FOO and BAR from process.env', () => { // FOO=42 BAR=baz cypress open - // see how FOO and BAR were copied in "cypress/plugins/index.js" + // see how FOO and BAR were copied in the `setupNodeEvents` function + // in the Cypress configuration expect(Cypress.env()).to.contain({ FOO: '42', BAR: 'baz', @@ -21,7 +22,7 @@ describe('process environment variables', () => { }) it('has variable loaded from .env file', () => { - // loaded in the plugins file + // loaded in the `setupNodeEvents` function in the Cypress configuration expect(Cypress.env('username')).to.equal('aTester') }) diff --git a/examples/server-communication__env-variables/cypress/plugins/index.js b/examples/server-communication__env-variables/cypress/plugins/index.js deleted file mode 100644 index ed22f926d..000000000 --- a/examples/server-communication__env-variables/cypress/plugins/index.js +++ /dev/null @@ -1,30 +0,0 @@ -/* eslint-disable no-console */ -// *********************************************************** -// This example plugins/index.js can be used to load plugins -// -// You can change the location of this file or turn off loading -// the plugins file with the 'pluginsFile' configuration option. -// -// You can read more here: -// https://on.cypress.io/plugins-guide -// *********************************************************** - -// This function is called when a project is opened or re-opened (e.g. due to -// the project's config changing) - -// load the environment variables from the local .env file -require('dotenv').config() - -module.exports = (on, config) => { - // we can grab some process environment variables - // and stick it into config.env before returning the updated config - config.env = config.env || {} - // you could extract only specific variables - // and rename them if necessary - config.env.FOO = process.env.FOO - config.env.BAR = process.env.BAR - config.env.username = process.env.USER_NAME - console.log('extended config.env with process.env.{FOO, BAR, USER_NAME}') - - return config -} diff --git a/examples/server-communication__offline/README.md b/examples/server-communication__offline/README.md index e4f52e9d6..633dac418 100644 --- a/examples/server-communication__offline/README.md +++ b/examples/server-communication__offline/README.md @@ -1,5 +1,8 @@ # Offline network test -- [offline-spec.js](cypress/integration/offline-spec.js) emulates offline network connection using Chrome Debugger Protocol and tests how the application handles it +NOTE: This test has known issues related to bug in Chrome where "Offline Mode" does not impact websockets. +This execution is not recommended and will be refactored to use cy.intercept() at a later date. + +- [offline-spec.cy.js](cypress/e2e/offline-spec.cy.js) emulates offline network connection using Chrome Debugger Protocol and tests how the application handles it ![Network status test](images/offline.gif) diff --git a/examples/server-communication__offline/cypress.config.js b/examples/server-communication__offline/cypress.config.js new file mode 100644 index 000000000..032953c85 --- /dev/null +++ b/examples/server-communication__offline/cypress.config.js @@ -0,0 +1,12 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + fixturesFolder: false, + viewportWidth: 500, + viewportHeight: 400, + defaultCommandTimeout: 8000, + e2e: { + baseUrl: 'http://localhost:7080', + supportFile: false, + }, +}) diff --git a/examples/server-communication__offline/cypress.json b/examples/server-communication__offline/cypress.json deleted file mode 100644 index ca2c5e345..000000000 --- a/examples/server-communication__offline/cypress.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "baseUrl": "http://localhost:7080", - "fixturesFolder": false, - "pluginsFile": false, - "supportFile": false, - "viewportWidth": 500, - "viewportHeight": 400, - "defaultCommandTimeout": 8000 -} diff --git a/examples/server-communication__offline/cypress/integration/offline-spec.js b/examples/server-communication__offline/cypress/e2e/offline-spec.cy.js similarity index 100% rename from examples/server-communication__offline/cypress/integration/offline-spec.js rename to examples/server-communication__offline/cypress/e2e/offline-spec.cy.js diff --git a/examples/server-communication__pass-value-between-specs/README.md b/examples/server-communication__pass-value-between-specs/README.md index 3db9bf88f..f173c4f6d 100644 --- a/examples/server-communication__pass-value-between-specs/README.md +++ b/examples/server-communication__pass-value-between-specs/README.md @@ -3,10 +3,10 @@ ## using task -The tests in [first-spec.js](cypress/integration/first-spec.js) store a Todo item retrieved from the API. The Todo item is stored in the [plugin file](./cypress/plugins/index.js) which is the background process continuously running while the browser relaunches for every spec. +The tests in [first-spec.cy.js](cypress/e2e/first-spec.cy.js) store a Todo item retrieved from the API. The Todo item is stored in the [setupNodeEvents](cypress.config.js) function which is the background process continuously running while the browser relaunches for every spec. ```js -// cypress/integration/first-spec.js +// cypress/e2e/first-spcy.ec.cy.js const url = 'https://jsonplaceholder.cypress.io/todos/1' cy.request(url).its('body').then(todo => { cy.task('setItem', { @@ -16,18 +16,18 @@ cy.request(url).its('body').then(todo => { }) ``` -The [second spec](./cypress/integration/second-spec.js) that always runs _after_ the first one retrieves the saved item +The [second spec](./cypress/e2e/second-spec.cy.js) that always runs _after_ the first one retrieves the saved item ```js -// cypress/integration/second-spec.js +// cypress/e2e/second-spec.cy.js cy.task('getItem', 'todo') .should('deep.equal', expectedTodo) ``` -The console log messages from the plugin file show the saved and retrieved items +The console log messages from the `setupNodeEvents` function show the saved and retrieved items ```text - Running: first-spec.js (1 of 2) + Running: first-spec.cy.js (1 of 2) First spec setting todo @@ -38,7 +38,7 @@ returning item todo 2 passing (469ms) - Running: second-spec.js (2 of 2) + Running: second-spec.cy.js (2 of 2) Second spec returning item todo @@ -49,7 +49,7 @@ returning item todo ## Warning ⚠️ -Saving an item in the plugin file only works as expected if the specs run in the expected order on the same machine. If you are using parallelization with `--parallel` flag the order of specs is determined by their historical timings, and the specs are split amongst all participating machines. Thus the specs might run in the wrong order, or only the second spec might execute on the machine, breaking the test. +Saving an item in the `setupNodeEvents` function only works as expected if the specs run in the expected order on the same machine. If you are using parallelization with `--parallel` flag the order of specs is determined by their historical timings, and the specs are split amongst all participating machines. Thus the specs might run in the wrong order, or only the second spec might execute on the machine, breaking the test. ## See also diff --git a/examples/server-communication__pass-value-between-specs/cypress.config.js b/examples/server-communication__pass-value-between-specs/cypress.config.js new file mode 100644 index 000000000..192c49802 --- /dev/null +++ b/examples/server-communication__pass-value-between-specs/cypress.config.js @@ -0,0 +1,45 @@ +/* eslint-disable no-console */ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + fixturesFolder: false, + e2e: { + supportFile: false, + setupNodeEvents (on, config) { + const items = {} + + // cy.task() requires returning a Promise + // or anything BUT undefined to signal that + // the task is finished + // see https://on.cypress.io/task + on('task', { + setItem ({ name, value }) { + console.log('setting %s', name) + + if (typeof value === 'undefined') { + // since we cannot return undefined from the cy.task + // let's not allow storing undefined + throw new Error(`Cannot store undefined value for item "${name}"`) + } + + items[name] = value + + return null + }, + + getItem (name) { + if (name in items) { + console.log('returning item %s', name) + + return items[name] + } + + const msg = `Missing item "${name}"` + + console.error(msg) + throw new Error(msg) + }, + }) + }, + }, +}) diff --git a/examples/server-communication__pass-value-between-specs/cypress.json b/examples/server-communication__pass-value-between-specs/cypress.json deleted file mode 100644 index a84f6e38c..000000000 --- a/examples/server-communication__pass-value-between-specs/cypress.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "fixturesFolder": false, - "supportFile": false -} diff --git a/examples/server-communication__pass-value-between-specs/cypress/integration/first-spec.js b/examples/server-communication__pass-value-between-specs/cypress/e2e/first-spec.cy.js similarity index 90% rename from examples/server-communication__pass-value-between-specs/cypress/integration/first-spec.js rename to examples/server-communication__pass-value-between-specs/cypress/e2e/first-spec.cy.js index 64744d90c..73de71076 100644 --- a/examples/server-communication__pass-value-between-specs/cypress/integration/first-spec.js +++ b/examples/server-communication__pass-value-between-specs/cypress/e2e/first-spec.cy.js @@ -26,7 +26,8 @@ describe('First spec', () => { it('2 - has the saved item in the next test', () => { // if the previous test has passed, we should have - // the item stored in the plugin file + // the item stored in the `setupNodeEvents` function in the + // Cypress configuration cy.task('getItem', 'todo').should('deep.equal', expectedTodo) }) }) diff --git a/examples/server-communication__pass-value-between-specs/cypress/integration/second-spec.js b/examples/server-communication__pass-value-between-specs/cypress/e2e/second-spec.cy.js similarity index 81% rename from examples/server-communication__pass-value-between-specs/cypress/integration/second-spec.js rename to examples/server-communication__pass-value-between-specs/cypress/e2e/second-spec.cy.js index 019821f33..6e7fc6dbc 100644 --- a/examples/server-communication__pass-value-between-specs/cypress/integration/second-spec.js +++ b/examples/server-communication__pass-value-between-specs/cypress/e2e/second-spec.cy.js @@ -10,7 +10,8 @@ describe('Second spec', () => { it('has the saved item from the first spec', () => { // if the previous spec file has passed, we should have - // the item stored in the plugin file + // the item stored in the `setupNodeEvents` function in the + // Cypress configuration cy.task('getItem', 'todo').should('deep.equal', expectedTodo) }) }) diff --git a/examples/server-communication__pass-value-between-specs/cypress/plugins/index.js b/examples/server-communication__pass-value-between-specs/cypress/plugins/index.js deleted file mode 100644 index d3626c046..000000000 --- a/examples/server-communication__pass-value-between-specs/cypress/plugins/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/// -// *********************************************************** -// This example plugins/index.js can be used to load plugins -// -// You can change the location of this file or turn off loading -// the plugins file with the 'pluginsFile' configuration option. -// -// You can read more here: -// https://on.cypress.io/plugins-guide -// *********************************************************** - -/* eslint-disable no-console */ - -// This function is called when a project is opened or re-opened (e.g. due to -// the project's config changing) - -/** - * @type {Cypress.PluginConfig} - */ -module.exports = (on, config) => { - const items = {} - - // cy.task() requires returning a Promise - // or anything BUT undefined to signal that - // the task is finished - // see https://on.cypress.io/task - on('task', { - setItem ({ name, value }) { - console.log('setting %s', name) - if (typeof value === 'undefined') { - // since we cannot return undefined from the cy.task - // let's not allow storing undefined - throw new Error(`Cannot store undefined value for item "${name}"`) - } - - items[name] = value - - return null - }, - - getItem (name) { - if (name in items) { - console.log('returning item %s', name) - - return items[name] - } - - const msg = `Missing item "${name}"` - - console.error(msg) - throw new Error(msg) - }, - }) -} diff --git a/examples/server-communication__request/README.md b/examples/server-communication__request/README.md index f693da161..4b7fba357 100644 --- a/examples/server-communication__request/README.md +++ b/examples/server-communication__request/README.md @@ -1,7 +1,7 @@ # Making HTTP requests > How to use `cy.request`, `window.fetch`, and `cy.task` commands to make HTTP requests to the server with and without cookies -The [cypress/integration/spec.js](./cypress/integration/spec.js) shows how to make HTTP requests with or without cookies. Read the blog post [Cypress request and cookies](https://glebbahmutov.com/blog/cypress-request-and-cookies/) for details. +The [cypress/e2e/spec.cy.js](./cypress/e2e/spec.cy.js) shows how to make HTTP requests with or without cookies. Read the blog post [Cypress request and cookies](https://glebbahmutov.com/blog/cypress-request-and-cookies/) for details. To run assuming the dependencies were installed in the root folder: diff --git a/examples/server-communication__request/cypress.config.js b/examples/server-communication__request/cypress.config.js new file mode 100644 index 000000000..3c50925e1 --- /dev/null +++ b/examples/server-communication__request/cypress.config.js @@ -0,0 +1,26 @@ +/* eslint-disable no-console */ +const { defineConfig } = require('cypress') + +const got = require('got') + +module.exports = defineConfig({ + fixturesFolder: false, + viewportHeight: 200, + viewportWidth: 300, + e2e: { + baseUrl: 'http://localhost:3000', + supportFile: false, + setupNodeEvents (on, config) { + on('task', { + httpRequest (params) { + console.log('making the HTTP request:') + console.log(params) + + // use the "got" module to make HTTP requests + // https://github.com/sindresorhus/got#readme + return got(params).then((r) => r.body) + }, + }) + }, + }, +}) diff --git a/examples/server-communication__request/cypress.json b/examples/server-communication__request/cypress.json deleted file mode 100644 index 940009c55..000000000 --- a/examples/server-communication__request/cypress.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "baseUrl": "http://localhost:3000", - "fixturesFolder": false, - "supportFile": false, - "viewportHeight": 200, - "viewportWidth": 300 -} diff --git a/examples/server-communication__request/cypress/integration/spec.js b/examples/server-communication__request/cypress/e2e/spec.cy.js similarity index 100% rename from examples/server-communication__request/cypress/integration/spec.js rename to examples/server-communication__request/cypress/e2e/spec.cy.js diff --git a/examples/server-communication__request/cypress/plugins/index.js b/examples/server-communication__request/cypress/plugins/index.js deleted file mode 100644 index ed624d2cb..000000000 --- a/examples/server-communication__request/cypress/plugins/index.js +++ /dev/null @@ -1,21 +0,0 @@ -/// -const got = require('got') - -/* eslint-disable no-console */ - -/** - * @type {Cypress.PluginConfig} - */ -// eslint-disable-next-line no-unused-vars -module.exports = (on, config) => { - on('task', { - httpRequest (params) { - console.log('making the HTTP request:') - console.log(params) - - // use the "got" module to make HTTP requests - // https://github.com/sindresorhus/got#readme - return got(params).then((r) => r.body) - }, - }) -} diff --git a/examples/server-communication__seeding-database-in-node/.babelrc b/examples/server-communication__seeding-database-in-node/.babelrc deleted file mode 100644 index cd9b31730..000000000 --- a/examples/server-communication__seeding-database-in-node/.babelrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "plugins": ["transform-es2015-modules-commonjs"] -} diff --git a/examples/server-communication__seeding-database-in-node/README.md b/examples/server-communication__seeding-database-in-node/README.md index 0f4653132..340294dfc 100644 --- a/examples/server-communication__seeding-database-in-node/README.md +++ b/examples/server-communication__seeding-database-in-node/README.md @@ -1,14 +1,9 @@ # Seeding Your Database in Node -This recipe demonstrates two things: +This recipe demonstrates: * Seeding your database with node.js using [`cy.task()`](https://on.cypress.io/task) -* Using ES modules `import`/`export` syntax in your plugins ## Seeding your database -If you use Node.js for your app, you can re-use your app code to help set up and manipulate data for your tests. In this example, we utilize [`cy.task()`](https://on.cypress.io/task) to connect with node via the `pluginsFile` to re-use the `server/db.js` and seed the database. - -## Using ES modules in plugins - -You can not use `import`/`export` directly in your `pluginsFile`, but you can wrap it so that any subsequently required files can utilize `import`/`export` and any other syntax that is configured in your `.babelrc`. +If you use Node.js for your app, you can re-use your app code to help set up and manipulate data for your tests. In this example, we utilize [`cy.task()`](https://on.cypress.io/task) to connect with node via the `setupNodeEvents` function to re-use the `server/db.js` and seed the database. diff --git a/examples/server-communication__seeding-database-in-node/cypress.config.js b/examples/server-communication__seeding-database-in-node/cypress.config.js new file mode 100644 index 000000000..eb23185e2 --- /dev/null +++ b/examples/server-communication__seeding-database-in-node/cypress.config.js @@ -0,0 +1,19 @@ +const { defineConfig } = require('cypress') + +const { seed } = require('./server/db') + +module.exports = defineConfig({ + e2e: { + baseUrl: 'http://localhost:7082', + supportFile: false, + setupNodeEvents (on, config) { + on('task', { + 'seed:db' (data) { + return seed(data).then(() => { + return data + }) + }, + }) + }, + }, +}) diff --git a/examples/server-communication__seeding-database-in-node/cypress.json b/examples/server-communication__seeding-database-in-node/cypress.json deleted file mode 100644 index dbb17b8a8..000000000 --- a/examples/server-communication__seeding-database-in-node/cypress.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "baseUrl": "http://localhost:7082", - "supportFile": false -} diff --git a/examples/server-communication__seeding-database-in-node/cypress/integration/seeding_database_in_node_spec.js b/examples/server-communication__seeding-database-in-node/cypress/e2e/seeding_database_in_node_spec.cy.js similarity index 80% rename from examples/server-communication__seeding-database-in-node/cypress/integration/seeding_database_in_node_spec.js rename to examples/server-communication__seeding-database-in-node/cypress/e2e/seeding_database_in_node_spec.cy.js index 993f7bd6e..b25f49896 100644 --- a/examples/server-communication__seeding-database-in-node/cypress/integration/seeding_database_in_node_spec.js +++ b/examples/server-communication__seeding-database-in-node/cypress/e2e/seeding_database_in_node_spec.cy.js @@ -6,8 +6,8 @@ describe('Seeding Database in Node', function () { }) it('can use fixture data to seed database', function () { - // We can use cy.task to communicate with node via the pluginsFile - // See cypress/plugins/main.js for the implementation of the 'seed:db' task + // We can use cy.task to communicate with node via the `setupNodeEvents` function + // See cypress.config.js for the implementation of the 'seed:db' task cy.task('seed:db', this.seed) cy.visit('/index.html') cy.get('#posts li').should('have.length', 3) diff --git a/examples/server-communication__seeding-database-in-node/cypress/plugins/index.js b/examples/server-communication__seeding-database-in-node/cypress/plugins/index.js deleted file mode 100644 index d9f9df5a4..000000000 --- a/examples/server-communication__seeding-database-in-node/cypress/plugins/index.js +++ /dev/null @@ -1,10 +0,0 @@ -// This enables using import/export in plugins/main.js -// and any files it requires -// -// Support for other syntax and features (not supported -// by the version of node run by Cypress) can -// be configured via babel plugins in the .babelrc - -require('babel-register') - -module.exports = require('./main').default diff --git a/examples/server-communication__seeding-database-in-node/cypress/plugins/main.js b/examples/server-communication__seeding-database-in-node/cypress/plugins/main.js deleted file mode 100644 index 146aa9f29..000000000 --- a/examples/server-communication__seeding-database-in-node/cypress/plugins/main.js +++ /dev/null @@ -1,12 +0,0 @@ -// We're able to import and re-use the same code we use in our app -import { seed } from '../../server/db' - -export default (on) => { - on('task', { - 'seed:db' (data) { - return seed(data).then(() => { - return data - }) - }, - }) -} diff --git a/examples/server-communication__seeding-database-in-node/server/db.js b/examples/server-communication__seeding-database-in-node/server/db.js index 58222e564..38854cdea 100644 --- a/examples/server-communication__seeding-database-in-node/server/db.js +++ b/examples/server-communication__seeding-database-in-node/server/db.js @@ -1,15 +1,20 @@ -import fs from 'fs-extra' -import path from 'path' +const fs = require('fs-extra') +const path = require('path') const filePath = path.join(__dirname, 'db.json') -export function seed (data) { +function seed (data) { return fs.outputJson(filePath, data) } -export function getPosts () { +function getPosts () { return fs.readJson(filePath) .then((data = {}) => { return data.posts }) } + +module.exports = { + seed, + getPosts, +} diff --git a/examples/server-communication__seeding-database-in-node/server/routes.js b/examples/server-communication__seeding-database-in-node/server/routes.js index ca3be43f0..47a9729cf 100644 --- a/examples/server-communication__seeding-database-in-node/server/routes.js +++ b/examples/server-communication__seeding-database-in-node/server/routes.js @@ -1,7 +1,7 @@ -import path from 'path' -import minimist from 'minimist' -import express from 'express' -import { getPosts } from './db' +const path = require('path') +const minimist = require('minimist') +const express = require('express') +const { getPosts } = require('./db') const app = express() diff --git a/examples/server-communication__server-timing/README.md b/examples/server-communication__server-timing/README.md index ae5cf2a8a..024319df7 100644 --- a/examples/server-communication__server-timing/README.md +++ b/examples/server-communication__server-timing/README.md @@ -1,7 +1,7 @@ # Server Timing > Show server timing results from Cypress visit -Imagine the server collects its performance timings while preparing and serving the `/` page. The server can send these timings using [Server-Timing](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Server-Timing) header (see [index.js](index.js)), and we can inspect these numbers from the Cypress test. See [cypress/integration/spec.js](cypress/integration/spec.js) file. +Imagine the server collects its performance timings while preparing and serving the `/` page. The server can send these timings using [Server-Timing](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Server-Timing) header (see [index.js](index.js)), and we can inspect these numbers from the Cypress test. See [cypress/e2e/spec.cy.js](cypress/e2e/spec.cy.js) file. We can intercept the `/` load using [cy.intercept](https://on.cypress.io/intercept) and inspect the response's headers. We have to find the `server-timing` header and parse it ourselves. diff --git a/examples/server-communication__server-timing/cypress.config.js b/examples/server-communication__server-timing/cypress.config.js new file mode 100644 index 000000000..40d652cf3 --- /dev/null +++ b/examples/server-communication__server-timing/cypress.config.js @@ -0,0 +1,9 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + fixturesFolder: false, + e2e: { + baseUrl: 'http://localhost:3000', + supportFile: false, + }, +}) diff --git a/examples/server-communication__server-timing/cypress.json b/examples/server-communication__server-timing/cypress.json deleted file mode 100644 index 4eff7d57e..000000000 --- a/examples/server-communication__server-timing/cypress.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "baseUrl": "http://localhost:3000", - "fixturesFolder": false, - "supportFile": false, - "pluginsFile": false -} diff --git a/examples/server-communication__server-timing/cypress/README.md b/examples/server-communication__server-timing/cypress/README.md index 3d50c9e06..8e4b8057a 100644 --- a/examples/server-communication__server-timing/cypress/README.md +++ b/examples/server-communication__server-timing/cypress/README.md @@ -7,13 +7,12 @@ These folders hold end-to-end tests and supporting files for the Cypress Test Runner. - [fixtures](fixtures) holds optional JSON data for mocking, [read more](https://on.cypress.io/fixture) -- [integration](integration) holds the actual test files, [read more](https://on.cypress.io/writing-and-organizing-tests) -- [plugins](plugins) allow you to customize how tests are loaded, [read more](https://on.cypress.io/plugins) +- [e2e](e2e) holds the actual test files, [read more](https://on.cypress.io/writing-and-organizing-tests) - [support](support) file runs before all tests and is a great place to write or load additional custom commands, [read more](https://on.cypress.io/writing-and-organizing-tests#Support-file) -## `cypress.json` file +## Cypress configuration -You can configure project options in the [../cypress.json](../cypress.json) file, see [Cypress configuration doc](https://on.cypress.io/configuration). +You can configure project options in [cypress.config.js](../cypress.config.js), see [Cypress configuration doc](https://on.cypress.io/configuration). ## More information diff --git a/examples/server-communication__server-timing/cypress/integration/spec.js b/examples/server-communication__server-timing/cypress/e2e/spec.cy.js similarity index 100% rename from examples/server-communication__server-timing/cypress/integration/spec.js rename to examples/server-communication__server-timing/cypress/e2e/spec.cy.js diff --git a/examples/server-communication__stream-tests/README.md b/examples/server-communication__stream-tests/README.md index 28a0bd59b..fc8e1c6c8 100644 --- a/examples/server-communication__stream-tests/README.md +++ b/examples/server-communication__stream-tests/README.md @@ -29,10 +29,10 @@ ipc.serve(() => { }) ``` -When Cypress starts, its background process is executing using Node the code in [cypress/plugins/index.js](cypress/plugins/index.js) file. This file can send messages back to the `cypressListener` process using IPC communication. In this particular recipe, we want to notify the `cypressListener` as soon as a test finishes running, we can do it on receiving a message from the Test Runner running in the browser via [cy.task](https://on.cypress.io/task) command. +When Cypress starts, its background process is executing using Node in the [setupNodeEvents](cypress.config.js) function. This file can send messages back to the `cypressListener` process using IPC communication. In this particular recipe, we want to notify the `cypressListener` as soon as a test finishes running, we can do it on receiving a message from the Test Runner running in the browser via [cy.task](https://on.cypress.io/task) command. ```js -// cypress/plugins/index.js +// cypress.config.js const ipc = require('node-ipc') ipc.connectTo('cypressListener') on('task', { @@ -50,10 +50,10 @@ on('task', { }) ``` -Finally, in the browser, after each test we save the test final attributes: the title, the state, the duration (there are more, but we are only interested in those), and send them to the plugins background process either at the start of the next test, or after all tests finish, see [cypress/support/index.js](cypress/support/index.js) file. +Finally, in the browser, after each test we save the test final attributes: the title, the state, the duration (there are more, but we are only interested in those), and send them to the `setupNodeEvents` background process either at the start of the next test, or after all tests finish, see [setupNodeEvents](cypress.config.js) file. ```js -// cypress/support/index.js +// cypress/support/e2e.js let testAttributesToSend const sendTestAttributes = () => { @@ -80,8 +80,8 @@ Cypress.on('test:after:run', (attributes, test) => { }) ``` -Every time the test finishes, its status and other attributes are saved. When the next test starts, the previous test results are sent to the plugins background process, where they are forwarded via IPC communication channel to the `cypressListener` server process. The server process can do any action desired: send notifications as soon as a test fails, push an event, etc. For example, it can print the test status in the terminal. +Every time the test finishes, its status and other attributes are saved. When the next test starts, the previous test results are sent to the `setupNodeEvents` background process, where they are forwarded via IPC communication channel to the `cypressListener` server process. The server process can do any action desired: send notifications as soon as a test fails, push an event, etc. For example, it can print the test status in the terminal. ![Test statuses](images/tests.png) -**Note:** we cannot invoke the `cy.task('testFinished')` from `Cypress.on('test:after:run')` callback, because it does not allow async code to execute, thus we need to use `beforeEach + after` trick to actually send each test result to the plugins background process. +**Note:** we cannot invoke the `cy.task('testFinished')` from `Cypress.on('test:after:run')` callback, because it does not allow async code to execute, thus we need to use `beforeEach + after` trick to actually send each test result to the `setupNodeEvents` background process. diff --git a/examples/server-communication__stream-tests/cypress.config.js b/examples/server-communication__stream-tests/cypress.config.js new file mode 100644 index 000000000..4f599ac35 --- /dev/null +++ b/examples/server-communication__stream-tests/cypress.config.js @@ -0,0 +1,32 @@ +/* eslint-disable no-console */ +const { defineConfig } = require('cypress') + +// http://riaevangelist.github.io/node-ipc/ +const ipc = require('node-ipc') + +ipc.connectTo('cypressListener', () => { + ipc.of.cypressListener.on('connect', () => { + ipc.log('## connected to Cypress listener ##') + }) +}) + +module.exports = defineConfig({ + fixturesFolder: false, + e2e: { + setupNodeEvents (on, config) { + on('task', { + testFinished (attributes) { + console.log('%s: "%s" %dms', attributes.state, attributes.title, attributes.duration) + + ipc.of.cypressListener.emit('test:after:run', { + state: attributes.state, + title: attributes.title, + duration: attributes.duration, + }) + + return null + }, + }) + }, + }, +}) diff --git a/examples/server-communication__stream-tests/cypress.json b/examples/server-communication__stream-tests/cypress.json deleted file mode 100644 index 4ec54f375..000000000 --- a/examples/server-communication__stream-tests/cypress.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "fixturesFolder": false -} diff --git a/examples/server-communication__stream-tests/cypress/integration/spec.js b/examples/server-communication__stream-tests/cypress/e2e/spec.cy.js similarity index 100% rename from examples/server-communication__stream-tests/cypress/integration/spec.js rename to examples/server-communication__stream-tests/cypress/e2e/spec.cy.js diff --git a/examples/server-communication__stream-tests/cypress/plugins/index.js b/examples/server-communication__stream-tests/cypress/plugins/index.js deleted file mode 100644 index 287198007..000000000 --- a/examples/server-communication__stream-tests/cypress/plugins/index.js +++ /dev/null @@ -1,30 +0,0 @@ -/// -/* eslint-disable no-console */ - -// http://riaevangelist.github.io/node-ipc/ -const ipc = require('node-ipc') - -ipc.connectTo('cypressListener', () => { - ipc.of.cypressListener.on('connect', () => { - ipc.log('## connected to Cypress listener ##') - }) -}) - -/** - * @type {Cypress.PluginConfig} - */ -module.exports = (on, config) => { - on('task', { - testFinished (attributes) { - // console.log(name) - console.log('%s: "%s" %dms', attributes.state, attributes.title, attributes.duration) - ipc.of.cypressListener.emit('test:after:run', { - state: attributes.state, - title: attributes.title, - duration: attributes.duration, - }) - - return null - }, - }) -} diff --git a/examples/server-communication__stream-tests/cypress/support/index.js b/examples/server-communication__stream-tests/cypress/support/e2e.js similarity index 100% rename from examples/server-communication__stream-tests/cypress/support/index.js rename to examples/server-communication__stream-tests/cypress/support/e2e.js diff --git a/examples/server-communication__visit-2nd-domain/README.md b/examples/server-communication__visit-2nd-domain/README.md index 5d6651c15..2bce1cae9 100644 --- a/examples/server-communication__visit-2nd-domain/README.md +++ b/examples/server-communication__visit-2nd-domain/README.md @@ -31,19 +31,19 @@ describe('Two domains', () => { If you run the above spec you might notice a curious thing: the `myValue` is undefined in the second test, even if it was set correctly in the first test. The variable is set to null because Cypress has to reload the entire spec when visiting the second domain. This "restarts" the spec, losing all local closure variables. -The solution is to save the `myValue` not in a local variable, but in a more permanent location, unaffected by the spec restart. This recipe shows two such places: a file on disk and a variable in the plugin file. +The solution is to save the `myValue` not in a local variable, but in a more permanent location, unaffected by the spec restart. This recipe shows two such places: a file on disk and a variable in the `setupNodeEvents` function. ## using task -The tests in [using-task-spec.js](cypress/integration/using-task-spec.js) store the intermediate URL in the plugins process. +The tests in [using-task-spec.cy.js](cypress/e2e/using-task-spec.cy.js) store the intermediate URL in the `setupNodeEvents` process. -The first test visits the first domain `https://www.cypress.io/`, finds link to Cypress Test Runner's GitHub repo and saves the `href` in the plugins process by using [cy.task](https://on.cypress.io/task). The plugin process keeps running preserving the variables, while the specs are started and stopped. +The first test visits the first domain `https://www.cypress.io/`, finds link to Cypress Test Runner's GitHub repo and saves the `href` in the `setupNodeEvents` process by using [cy.task](https://on.cypress.io/task). The `setupNodeEvents` process keeps running preserving the variables, while the specs are started and stopped. -The second test gets the URL from the plugins process using [cy.task](https://on.cypress.io/task) and calls `cy.visit()` and then confirms the GitHub page opens. +The second test gets the URL from the `setupNodeEvents` process using [cy.task](https://on.cypress.io/task) and calls `cy.visit()` and then confirms the GitHub page opens. ## using file -The tests in [using-file-spec.js](cypress/integration/using-file-spec.js) save the extracted URL in a local JSON file. +The tests in [using-file-spec.cy.js](cypress/e2e/using-file-spec.cy.js) save the extracted URL in a local JSON file. ## See also diff --git a/examples/server-communication__visit-2nd-domain/cypress.config.js b/examples/server-communication__visit-2nd-domain/cypress.config.js new file mode 100644 index 000000000..b668d49bf --- /dev/null +++ b/examples/server-communication__visit-2nd-domain/cypress.config.js @@ -0,0 +1,28 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + fixturesFolder: false, + e2e: { + supportFile: false, + setupNodeEvents (on, config) { + // the URL will set by the first test + let href + + on('task', { + saveUrl (url) { + href = url + + // cy.task() requires returning a Promise + // or anything BUT undefined to signal that + // the task is finished + // see https://on.cypress.io/task + return null + }, + + getUrl () { + return href + }, + }) + }, + }, +}) diff --git a/examples/server-communication__visit-2nd-domain/cypress.json b/examples/server-communication__visit-2nd-domain/cypress.json deleted file mode 100644 index a84f6e38c..000000000 --- a/examples/server-communication__visit-2nd-domain/cypress.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "fixturesFolder": false, - "supportFile": false -} diff --git a/examples/server-communication__visit-2nd-domain/cypress/integration/using-file-spec.js b/examples/server-communication__visit-2nd-domain/cypress/e2e/using-file-spec.cy.js similarity index 100% rename from examples/server-communication__visit-2nd-domain/cypress/integration/using-file-spec.js rename to examples/server-communication__visit-2nd-domain/cypress/e2e/using-file-spec.cy.js diff --git a/examples/server-communication__visit-2nd-domain/cypress/integration/using-task-spec.js b/examples/server-communication__visit-2nd-domain/cypress/e2e/using-task-spec.cy.js similarity index 94% rename from examples/server-communication__visit-2nd-domain/cypress/integration/using-task-spec.js rename to examples/server-communication__visit-2nd-domain/cypress/e2e/using-task-spec.cy.js index 1ab06b6a4..c7567c302 100644 --- a/examples/server-communication__visit-2nd-domain/cypress/integration/using-task-spec.js +++ b/examples/server-communication__visit-2nd-domain/cypress/e2e/using-task-spec.cy.js @@ -10,7 +10,7 @@ describe('Two domains', () => { // get the "href" value .invoke('attr', 'href') .then((url) => { - // save the value in the plugins process + // save the value in the `setupNodeEvents` process // that is preserved between browser page reloads expect(url).to.be.a('string') cy.task('saveUrl', url) diff --git a/examples/server-communication__visit-2nd-domain/cypress/plugins/index.js b/examples/server-communication__visit-2nd-domain/cypress/plugins/index.js deleted file mode 100644 index 5fd0174f0..000000000 --- a/examples/server-communication__visit-2nd-domain/cypress/plugins/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/// -// *********************************************************** -// This example plugins/index.js can be used to load plugins -// -// You can change the location of this file or turn off loading -// the plugins file with the 'pluginsFile' configuration option. -// -// You can read more here: -// https://on.cypress.io/plugins-guide -// *********************************************************** - -// This function is called when a project is opened or re-opened (e.g. due to -// the project's config changing) - -/** - * @type {Cypress.PluginConfig} - */ -module.exports = (on, config) => { - // the URL will set by the first test - let href - - on('task', { - saveUrl (url) { - href = url - - // cy.task() requires returning a Promise - // or anything BUT undefined to signal that - // the task is finished - // see https://on.cypress.io/task - return null - }, - - getUrl () { - return href - }, - }) -} diff --git a/examples/server-communication__wait-for-api/cypress.config.js b/examples/server-communication__wait-for-api/cypress.config.js new file mode 100644 index 000000000..2e324f89c --- /dev/null +++ b/examples/server-communication__wait-for-api/cypress.config.js @@ -0,0 +1,13 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + fixturesFolder: false, + viewportHeight: 300, + viewportWidth: 500, + defaultCommandTimeout: 1000, + requestTimeout: 1000, + e2e: { + baseUrl: 'http://localhost:7668', + supportFile: false, + }, +}) diff --git a/examples/server-communication__wait-for-api/cypress.json b/examples/server-communication__wait-for-api/cypress.json deleted file mode 100644 index e8d3dc0c6..000000000 --- a/examples/server-communication__wait-for-api/cypress.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "fixturesFolder": false, - "supportFile": false, - "pluginsFile": false, - "viewportHeight": 300, - "viewportWidth": 500, - "baseUrl": "http://localhost:7668", - "defaultCommandTimeout": 1000, - "requestTimeout": 1000 -} diff --git a/examples/server-communication__wait-for-api/cypress/integration/spec.js b/examples/server-communication__wait-for-api/cypress/e2e/spec.cy.js similarity index 100% rename from examples/server-communication__wait-for-api/cypress/integration/spec.js rename to examples/server-communication__wait-for-api/cypress/e2e/spec.cy.js diff --git a/examples/server-communication__xhr-assertions/README.md b/examples/server-communication__xhr-assertions/README.md index 38dffaf5f..9437fe2c5 100644 --- a/examples/server-communication__xhr-assertions/README.md +++ b/examples/server-communication__xhr-assertions/README.md @@ -2,11 +2,11 @@ This recipe shows how to spy on a network call and assert its request and response data. -[cypress/integration/spec.js](cypress/integration/spec.js) runs multiple assertions against an XHR object +[cypress/e2e/spec.cy.js](cypress/e2e/spec.cy.js) runs multiple assertions against an XHR object ![Multiple assertions](images/assertions.png) -[cypress/integration/spok-spec.js](cypress/integration/spok-spec.js) asserts multiple values and schema properties using [cy-spok](https://github.com/bahmutov/cy-spok) plugin built on top of [spok](https://github.com/thlorenz/spok) +[cypress/e2e/spok-spec.cy.js](cypress/e2e/spok-spec.cy.js) asserts multiple values and schema properties using [cy-spok](https://github.com/bahmutov/cy-spok) plugin built on top of [spok](https://github.com/thlorenz/spok) ![Spok assertions](images/spok.png) @@ -41,7 +41,7 @@ cy.wait('@post').should('have.property', 'status', 201) ![cy.wait works](images/cy-wait-example.png) -Find the above tests in [cypress/integration/wait-vs-get.js](cypress/integration/wait-vs-get.js) +Find the above tests in [cypress/e2e/wait-vs-get.cy.js](cypress/e2e/wait-vs-get.cy.js) **Tip:** you can inspect the full XHR object by logging it to the console @@ -53,19 +53,19 @@ cy.wait('@post').then(console.log) ## Multiple requests -[cypress/integration/multiple-requests.js](cypress/integration/multiple-requests.js) shows how to wait for multiple matching requests and how to retrieve them all, or individually. +[cypress/e2e/multiple-requests.cy.js](cypress/e2e/multiple-requests.cy.js) shows how to wait for multiple matching requests and how to retrieve them all, or individually. ![multiple requests](images/multiple.png) ## Controlling the clock -We can skip the initial 1 second delay set using `setTimeout(..., 1000)` inside the application by controlling the application's clock. See [cypress/integration/clock-control.js](cypress/integration/clock-control.js). +We can skip the initial 1 second delay set using `setTimeout(..., 1000)` inside the application by controlling the application's clock. See [cypress/e2e/clock-control.cy.js](cypress/e2e/clock-control.cy.js). ![Fast test via clock control](images/clock.gif) ## Test retries -If we decide to assert the network call's duration yet avoid specifying extremely large limit to avoid spurious test failures, we can use test retries to re-run the test. See [cypress/integration/duration-spec.js](cypress/integration/duration-spec.js) +If we decide to assert the network call's duration yet avoid specifying extremely large limit to avoid spurious test failures, we can use test retries to re-run the test. See [cypress/e2e/duration-spec.cy.js](cypress/e2e/duration-spec.cy.js) ```js it('is faster than 300ms', { retries: 3 }, () => { @@ -78,7 +78,7 @@ it('is faster than 300ms', { retries: 3 }, () => { ## XML responses -If the server is returning a XML response, you can parse it into a plain object and then confirm its properties. See the [server.js](./server.js) and the [cypress/integration/xml-spec.js](./cypress/integration/xml-spec.js) files. +If the server is returning a XML response, you can parse it into a plain object and then confirm its properties. See the [server.js](./server.js) and the [cypress/e2e/xml-spec.cy.js](./cypress/e2e/xml-spec.cy.js) files. ## See also diff --git a/examples/server-communication__xhr-assertions/cypress.config.js b/examples/server-communication__xhr-assertions/cypress.config.js new file mode 100644 index 000000000..fabffb1d3 --- /dev/null +++ b/examples/server-communication__xhr-assertions/cypress.config.js @@ -0,0 +1,10 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + fixturesFolder: false, + viewportHeight: 300, + viewportWidth: 500, + e2e: { + supportFile: false, + }, +}) diff --git a/examples/server-communication__xhr-assertions/cypress.json b/examples/server-communication__xhr-assertions/cypress.json deleted file mode 100644 index bd63a47a0..000000000 --- a/examples/server-communication__xhr-assertions/cypress.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "fixturesFolder": false, - "supportFile": false, - "pluginsFile": false, - "viewportHeight": 300, - "viewportWidth": 500 -} diff --git a/examples/server-communication__xhr-assertions/cypress/integration/clock-control.js b/examples/server-communication__xhr-assertions/cypress/e2e/clock-control.cy.js similarity index 100% rename from examples/server-communication__xhr-assertions/cypress/integration/clock-control.js rename to examples/server-communication__xhr-assertions/cypress/e2e/clock-control.cy.js diff --git a/examples/server-communication__xhr-assertions/cypress/integration/duration-spec.js b/examples/server-communication__xhr-assertions/cypress/e2e/duration-spec.cy.js similarity index 100% rename from examples/server-communication__xhr-assertions/cypress/integration/duration-spec.js rename to examples/server-communication__xhr-assertions/cypress/e2e/duration-spec.cy.js diff --git a/examples/server-communication__xhr-assertions/cypress/integration/multiple-requests.js b/examples/server-communication__xhr-assertions/cypress/e2e/multiple-requests.cy.js similarity index 100% rename from examples/server-communication__xhr-assertions/cypress/integration/multiple-requests.js rename to examples/server-communication__xhr-assertions/cypress/e2e/multiple-requests.cy.js diff --git a/examples/server-communication__xhr-assertions/cypress/integration/spec.js b/examples/server-communication__xhr-assertions/cypress/e2e/spec.cy.js similarity index 100% rename from examples/server-communication__xhr-assertions/cypress/integration/spec.js rename to examples/server-communication__xhr-assertions/cypress/e2e/spec.cy.js diff --git a/examples/server-communication__xhr-assertions/cypress/integration/spok-spec.js b/examples/server-communication__xhr-assertions/cypress/e2e/spok-spec.cy.js similarity index 100% rename from examples/server-communication__xhr-assertions/cypress/integration/spok-spec.js rename to examples/server-communication__xhr-assertions/cypress/e2e/spok-spec.cy.js diff --git a/examples/server-communication__xhr-assertions/cypress/integration/wait-vs-get.js b/examples/server-communication__xhr-assertions/cypress/e2e/wait-vs-get.cy.js similarity index 100% rename from examples/server-communication__xhr-assertions/cypress/integration/wait-vs-get.js rename to examples/server-communication__xhr-assertions/cypress/e2e/wait-vs-get.cy.js diff --git a/examples/server-communication__xhr-assertions/cypress/integration/xml-spec.js b/examples/server-communication__xhr-assertions/cypress/e2e/xml-spec.cy.js similarity index 100% rename from examples/server-communication__xhr-assertions/cypress/integration/xml-spec.js rename to examples/server-communication__xhr-assertions/cypress/e2e/xml-spec.cy.js diff --git a/examples/stubbing-spying__console/README.md b/examples/stubbing-spying__console/README.md index 78e564e6c..8f6d5ec94 100644 --- a/examples/stubbing-spying__console/README.md +++ b/examples/stubbing-spying__console/README.md @@ -1,6 +1,6 @@ # Stubbing Console -The spec file [cypress/integration/spec.js](cypress/integration/spec.js) shows how to spy on and stub methods of the `console` object. See [index.html](index.html) to see what the "application" is logging on load. +The spec file [cypress/e2e/spec.cy.js](cypress/e2e/spec.cy.js) shows how to spy on and stub methods of the `console` object. See [index.html](index.html) to see what the "application" is logging on load. ![Test example](images/console-example.png) diff --git a/examples/stubbing-spying__console/cypress.config.js b/examples/stubbing-spying__console/cypress.config.js new file mode 100644 index 000000000..4415f5033 --- /dev/null +++ b/examples/stubbing-spying__console/cypress.config.js @@ -0,0 +1,8 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + fixturesFolder: false, + e2e: { + supportFile: false, + }, +}) diff --git a/examples/stubbing-spying__console/cypress.json b/examples/stubbing-spying__console/cypress.json deleted file mode 100644 index e21846330..000000000 --- a/examples/stubbing-spying__console/cypress.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "pluginsFile": false, - "supportFile": false, - "fixturesFolder": false -} \ No newline at end of file diff --git a/examples/stubbing-spying__console/cypress/integration/spec.js b/examples/stubbing-spying__console/cypress/e2e/spec.cy.js similarity index 100% rename from examples/stubbing-spying__console/cypress/integration/spec.js rename to examples/stubbing-spying__console/cypress/e2e/spec.cy.js diff --git a/examples/stubbing-spying__functions/cypress.config.js b/examples/stubbing-spying__functions/cypress.config.js new file mode 100644 index 000000000..4415f5033 --- /dev/null +++ b/examples/stubbing-spying__functions/cypress.config.js @@ -0,0 +1,8 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + fixturesFolder: false, + e2e: { + supportFile: false, + }, +}) diff --git a/examples/stubbing-spying__functions/cypress.json b/examples/stubbing-spying__functions/cypress.json deleted file mode 100644 index e20ef7c43..000000000 --- a/examples/stubbing-spying__functions/cypress.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "fixturesFolder": false, - "pluginsFile": false, - "supportFile": false -} \ No newline at end of file diff --git a/examples/stubbing-spying__functions/cypress/integration/unit-test-stubbing-dependencies-spec.js b/examples/stubbing-spying__functions/cypress/e2e/unit-test-stubbing-dependencies-spec.cy.js similarity index 100% rename from examples/stubbing-spying__functions/cypress/integration/unit-test-stubbing-dependencies-spec.js rename to examples/stubbing-spying__functions/cypress/e2e/unit-test-stubbing-dependencies-spec.cy.js diff --git a/examples/stubbing-spying__google-analytics/README.md b/examples/stubbing-spying__google-analytics/README.md index a23eacbfe..b6556630c 100644 --- a/examples/stubbing-spying__google-analytics/README.md +++ b/examples/stubbing-spying__google-analytics/README.md @@ -32,7 +32,7 @@ Using our Cypress tests we can confirm the application is making the right calls ## Stubbing `window.ga` method -The first example in [ga-method-stubbing.js](cypress/integration/ga-method-stubbing.js) blocks all requests to domain `www.google-analytics.com`. Even though we are preventing the actual `GA` script from loading, we can still stub the `window.ga` object and ensure its being called correctly. +The first example in [ga-method-stubbing.cy.js](cypress/e2e/ga-method-stubbing.cy.js) blocks all requests to domain `www.google-analytics.com`. Even though we are preventing the actual `GA` script from loading, we can still stub the `window.ga` object and ensure its being called correctly. - Use [`cy.intercept`](https://on.cypress.io/intercept) to block Google Analytics from receiving requests. - Use [`cy.stub()`](https://on.cypress.io/stub) to verify that `window.ga(...)` was called with the correct arguments @@ -55,7 +55,7 @@ We can do more than just stub `window.ga` calls. We can confirm that the actual **Note:** the XHR call goes to `https://www.google-analytics.com/j/collect` endpoint, while the image resource is loaded from `https://www.google-analytics.com/collect` -The spec file [ga-network-stubbing.js](cypress/integration/ga-network-stubbing.js) shows how to stub both +The spec file [ga-network-stubbing.cy.js](cypress/e2e/ga-network-stubbing.cy.js) shows how to stub both ```js cy.intercept('POST', 'https://www.google-analytics.com/j/collect', diff --git a/examples/stubbing-spying__google-analytics/cypress.config.js b/examples/stubbing-spying__google-analytics/cypress.config.js new file mode 100644 index 000000000..074bf0934 --- /dev/null +++ b/examples/stubbing-spying__google-analytics/cypress.config.js @@ -0,0 +1,21 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + fixturesFolder: false, + viewportHeight: 200, + viewportWidth: 250, + e2e: { + supportFile: false, + setupNodeEvents (on, config) { + // `on` is used to hook into various events Cypress emits + // `config` is the resolved Cypress config + on('before:browser:launch', (browser, launchOptions) => { + if (browser.family === 'chromium') { + launchOptions.args.push('--enable-logging', '--v=1') + + return launchOptions + } + }) + }, + }, +}) diff --git a/examples/stubbing-spying__google-analytics/cypress.json b/examples/stubbing-spying__google-analytics/cypress.json deleted file mode 100644 index 38e37fc07..000000000 --- a/examples/stubbing-spying__google-analytics/cypress.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "fixturesFolder": false, - "supportFile": false, - "viewportHeight": 200, - "viewportWidth": 250 -} diff --git a/examples/stubbing-spying__google-analytics/cypress/integration/ga-method-stubbing.js b/examples/stubbing-spying__google-analytics/cypress/e2e/ga-method-stubbing.cy.js similarity index 100% rename from examples/stubbing-spying__google-analytics/cypress/integration/ga-method-stubbing.js rename to examples/stubbing-spying__google-analytics/cypress/e2e/ga-method-stubbing.cy.js diff --git a/examples/stubbing-spying__google-analytics/cypress/integration/ga-network-stubbing.js b/examples/stubbing-spying__google-analytics/cypress/e2e/ga-network-stubbing.cy.js similarity index 100% rename from examples/stubbing-spying__google-analytics/cypress/integration/ga-network-stubbing.js rename to examples/stubbing-spying__google-analytics/cypress/e2e/ga-network-stubbing.cy.js diff --git a/examples/stubbing-spying__google-analytics/cypress/plugins/index.js b/examples/stubbing-spying__google-analytics/cypress/plugins/index.js deleted file mode 100644 index 93dbaaa17..000000000 --- a/examples/stubbing-spying__google-analytics/cypress/plugins/index.js +++ /dev/null @@ -1,24 +0,0 @@ -// *********************************************************** -// This example plugins/index.js can be used to load plugins -// -// You can change the location of this file or turn off loading -// the plugins file with the 'pluginsFile' configuration option. -// -// You can read more here: -// https://on.cypress.io/plugins-guide -// *********************************************************** - -// This function is called when a project is opened or re-opened (e.g. due to -// the project's config changing) - -module.exports = (on, config) => { - // `on` is used to hook into various events Cypress emits - // `config` is the resolved Cypress config - on('before:browser:launch', (browser, launchOptions) => { - if (browser.family === 'chromium') { - launchOptions.args.push('--enable-logging', '--v=1') - - return launchOptions - } - }) -} diff --git a/examples/stubbing-spying__intercept/README.md b/examples/stubbing-spying__intercept/README.md index 658f90e39..a7f4c44b7 100644 --- a/examples/stubbing-spying__intercept/README.md +++ b/examples/stubbing-spying__intercept/README.md @@ -1,24 +1,24 @@ # Stubbing application requests using [cy.intercept](https://on.cypress.io/intercept) -- [control-clock-spec.js](cypress/integration/control-clock-spec.js) shows how to reply with different responses to an ajax request -- [count-spec.js](cypress/integration/count-spec.js) uses `cy.intercept` and `cy.spy|cy.stub` combination to count the number of intercepted network calls -- [form-spec.js](./cypress/integration/form-spec.js) shows how to stub form submission request and verify the submitted form fields (`application/x-www-form-urlencoded` or `multipart/form-data`) -- [headers-spec.js](./cypress/integration/header-spec.js) adds a custom header to the outgoing request. Note that this request header won't be shown by the browser's Network tab, since the request has already left the browser. -- [html-css-spec.js](cypress/integration/html-css-spec.js) modifies the page itself and changes the CSS requested by the page. -- [image-spec.js](cypress/integration/image-spec.js) shows how to spy and stub static resources like images -- [jsonp-spec.js](cypress/integration/jsonp-spec.js) shows how to spy on or stub a JSONP data request -- [loading-element-spec.js](./cypress/integration/loading-element-spec.js) shows how to test the loading element that appears while the app is fetching the data -- [matching-spec.js](cypress/integration/matching-spec.js) shows how the same request can match multiple `cy.intercept` matchers -- [ping-spec.js](./cypress/integration/ping-spec.js) shows how to confirm `` really is making a POST request -- [redirect-spec.js](cypress/integration/redirect-spec.js) shows how to spy on a redirect, and how to stub the redirect response from the server to avoid loading a second domain, for example -- [repeat-spec.js](cypress/integration/repeat-spec.js) stress tests GET and POST calls by running the tests multiple times, as described in [Retry, Rerun, Repeat](https://www.cypress.io/blog/2020/12/03/retry-rerun-repeat/) -- [spy-on-fetch-spec.js](cypress/integration/spy-on-fetch-spec.js) shows how to spy on the `fetch` call -- [stub-fetch-spec.js](cypress/integration/stub-fetch-spec.js) shows how to stub `fetch` calls from the application, event depending on the object sent -- [stubbed-api-spec.js](cypress/integration/stubbed-api-spec.js) shows how stubbed requests work without any backend API -- [times-spec.js](cypress/integration/times-spec.js) shows how to use the `cy.intercept` "times" option -- [glob-matching-intercept-url.spec.js](cypress/integration/glob-matching-intercept-url.spec.js) shows how glob matching urls works -- [intercept-force404.spec.js](cypress/integration/intercept-force404.spec) shows how to implement an equivalent of `force404` (a feature of `cy.route()`) with `cy.intercept()` -- [intercept-events.spec.js](cypress/integration/) shows how to use intercept events -- [middleware-intercept.spec.js](cypress/integration/middleware-intercept.spec.js) shows how to set middleware handlers that apply before all others +- [control-clock-spec.cy.js](cypress/e2e/control-clock-spec.cy.js) shows how to reply with different responses to an ajax request +- [count-spec.cy.js](cypress/e2e/count-spec.cy.js) uses `cy.intercept` and `cy.spy|cy.stub` combination to count the number of intercepted network calls +- [form-spec.cy.js](./cypress/e2e/form-spec.cy.js) shows how to stub form submission request and verify the submitted form fields (`application/x-www-form-urlencoded` or `multipart/form-data`) +- [headers-spec.cy.js](./cypress/e2e/header-spec.cy.js) adds a custom header to the outgoing request. Note that this request header won't be shown by the browser's Network tab, since the request has already left the browser. +- [html-css-spec.cy.js](cypress/e2e/html-css-spec.cy.js) modifies the page itself and changes the CSS requested by the page. +- [image-spec.cy.js](cypress/e2e/image-spec.cy.js) shows how to spy and stub static resources like images +- [jsonp-spec.cy.js](cypress/e2e/jsonp-spec.cy.js) shows how to spy on or stub a JSONP data request +- [loading-element-spec.cy.js](./cypress/e2e/loading-element-spec.cy.js) shows how to test the loading element that appears while the app is fetching the data +- [matching-spec.cy.js](cypress/e2e/matching-spec.cy.js) shows how the same request can match multiple `cy.intercept` matchers +- [ping-spec.cy.js](./cypress/e2e/ping-spec.cy.js) shows how to confirm `` really is making a POST request +- [redirect-spec.cy.js](cypress/e2e/redirect-spec.cy.js) shows how to spy on a redirect, and how to stub the redirect response from the server to avoid loading a second domain, for example +- [repeat-spec.cy.js](cypress/e2e/repeat-spec.cy.js) stress tests GET and POST calls by running the tests multiple times, as described in [Retry, Rerun, Repeat](https://www.cypress.io/blog/2020/12/03/retry-rerun-repeat/) +- [spy-on-fetch-spec.cy.js](cypress/e2e/spy-on-fetch-spec.cy.js) shows how to spy on the `fetch` call +- [stub-fetch-spec.cy.js](cypress/e2e/stub-fetch-spec.cy.js) shows how to stub `fetch` calls from the application, event depending on the object sent +- [stubbed-api-spec.cy.js](cypress/e2e/stubbed-api-spec.cy.js) shows how stubbed requests work without any backend API +- [times-spec.cy.js](cypress/e2e/times-spec.cy.js) shows how to use the `cy.intercept` "times" option +- [glob-matching-intercept-url.spec.cy.js](cypress/e2e/glob-matching-intercept-url.spec.cy.js) shows how glob matching urls works +- [intercept-force404.spec.cy.js](cypress/e2e/intercept-force404.spec.cy.js) shows how to implement an equivalent of `force404` (a feature of `cy.route()`) with `cy.intercept()` +- [intercept-events.spec.cy.js](cypress/e2e/intercept-events.spec.cy.js) shows how to use intercept events +- [middleware-intercept.spec.cy.js](cypress/e2e/middleware-intercept.spec.cy.js) shows how to set middleware handlers that apply before all others For more `cy.intercept` examples and tips read the [Cypress cy.intercept Problems](https://glebbahmutov.com/blog/cypress-intercept-problems/) blog post diff --git a/examples/stubbing-spying__intercept/cypress.config.js b/examples/stubbing-spying__intercept/cypress.config.js new file mode 100644 index 000000000..3dcae896e --- /dev/null +++ b/examples/stubbing-spying__intercept/cypress.config.js @@ -0,0 +1,24 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + defaultCommandTimeout: 8000, + e2e: { + baseUrl: 'http://localhost:7080', + supportFile: false, + excludeSpecPattern: 'deferred.js', + setupNodeEvents (on, config) { + on('before:browser:launch', (browser = {}, launchOptions) => { + if (browser.family === 'firefox') { + // One of the tests uses feature that + // is behind a flag in Firefox browser. + // We can programmatically enable an option + // in Firefox using launch options + launchOptions.preferences['browser.send_pings'] = true + } + + // whatever you return here becomes the launchOptions + return launchOptions + }) + }, + }, +}) diff --git a/examples/stubbing-spying__intercept/cypress.json b/examples/stubbing-spying__intercept/cypress.json deleted file mode 100644 index 54babc51a..000000000 --- a/examples/stubbing-spying__intercept/cypress.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "baseUrl": "http://localhost:7080", - "ignoreTestFiles": "deferred.js", - "supportFile": false, - "defaultCommandTimeout": 8000 -} diff --git a/examples/stubbing-spying__intercept/cypress/integration/control-clock-spec.js b/examples/stubbing-spying__intercept/cypress/e2e/control-clock-spec.cy.js similarity index 100% rename from examples/stubbing-spying__intercept/cypress/integration/control-clock-spec.js rename to examples/stubbing-spying__intercept/cypress/e2e/control-clock-spec.cy.js diff --git a/examples/stubbing-spying__intercept/cypress/integration/count-spec.js b/examples/stubbing-spying__intercept/cypress/e2e/count-spec.cy.js similarity index 100% rename from examples/stubbing-spying__intercept/cypress/integration/count-spec.js rename to examples/stubbing-spying__intercept/cypress/e2e/count-spec.cy.js diff --git a/examples/stubbing-spying__intercept/cypress/integration/form-spec.js b/examples/stubbing-spying__intercept/cypress/e2e/form-spec.cy.js similarity index 100% rename from examples/stubbing-spying__intercept/cypress/integration/form-spec.js rename to examples/stubbing-spying__intercept/cypress/e2e/form-spec.cy.js diff --git a/examples/stubbing-spying__intercept/cypress/integration/glob-matching-intercept-url.spec.js b/examples/stubbing-spying__intercept/cypress/e2e/glob-matching-intercept-url.spec.cy.js similarity index 100% rename from examples/stubbing-spying__intercept/cypress/integration/glob-matching-intercept-url.spec.js rename to examples/stubbing-spying__intercept/cypress/e2e/glob-matching-intercept-url.spec.cy.js diff --git a/examples/stubbing-spying__intercept/cypress/integration/header-spec.js b/examples/stubbing-spying__intercept/cypress/e2e/header-spec.cy.js similarity index 100% rename from examples/stubbing-spying__intercept/cypress/integration/header-spec.js rename to examples/stubbing-spying__intercept/cypress/e2e/header-spec.cy.js diff --git a/examples/stubbing-spying__intercept/cypress/integration/html-css-spec.js b/examples/stubbing-spying__intercept/cypress/e2e/html-css-spec.cy.js similarity index 100% rename from examples/stubbing-spying__intercept/cypress/integration/html-css-spec.js rename to examples/stubbing-spying__intercept/cypress/e2e/html-css-spec.cy.js diff --git a/examples/stubbing-spying__intercept/cypress/integration/image-spec.js b/examples/stubbing-spying__intercept/cypress/e2e/image-spec.cy.js similarity index 100% rename from examples/stubbing-spying__intercept/cypress/integration/image-spec.js rename to examples/stubbing-spying__intercept/cypress/e2e/image-spec.cy.js diff --git a/examples/stubbing-spying__intercept/cypress/integration/intercept-events.spec.js b/examples/stubbing-spying__intercept/cypress/e2e/intercept-events.spec.cy.js similarity index 100% rename from examples/stubbing-spying__intercept/cypress/integration/intercept-events.spec.js rename to examples/stubbing-spying__intercept/cypress/e2e/intercept-events.spec.cy.js diff --git a/examples/stubbing-spying__intercept/cypress/integration/intercept-force404.spec.js b/examples/stubbing-spying__intercept/cypress/e2e/intercept-force404.spec.cy.js similarity index 100% rename from examples/stubbing-spying__intercept/cypress/integration/intercept-force404.spec.js rename to examples/stubbing-spying__intercept/cypress/e2e/intercept-force404.spec.cy.js diff --git a/examples/stubbing-spying__intercept/cypress/integration/jsonp-spec.js b/examples/stubbing-spying__intercept/cypress/e2e/jsonp-spec.cy.js similarity index 100% rename from examples/stubbing-spying__intercept/cypress/integration/jsonp-spec.js rename to examples/stubbing-spying__intercept/cypress/e2e/jsonp-spec.cy.js diff --git a/examples/stubbing-spying__intercept/cypress/integration/loading-element-spec.js b/examples/stubbing-spying__intercept/cypress/e2e/loading-element-spec.cy.js similarity index 100% rename from examples/stubbing-spying__intercept/cypress/integration/loading-element-spec.js rename to examples/stubbing-spying__intercept/cypress/e2e/loading-element-spec.cy.js diff --git a/examples/stubbing-spying__intercept/cypress/integration/matching-spec.js b/examples/stubbing-spying__intercept/cypress/e2e/matching-spec.cy.js similarity index 100% rename from examples/stubbing-spying__intercept/cypress/integration/matching-spec.js rename to examples/stubbing-spying__intercept/cypress/e2e/matching-spec.cy.js diff --git a/examples/stubbing-spying__intercept/cypress/integration/middleware-intercept.spec.js b/examples/stubbing-spying__intercept/cypress/e2e/middleware-intercept.spec.cy.js similarity index 100% rename from examples/stubbing-spying__intercept/cypress/integration/middleware-intercept.spec.js rename to examples/stubbing-spying__intercept/cypress/e2e/middleware-intercept.spec.cy.js diff --git a/examples/stubbing-spying__intercept/cypress/integration/ping-spec.js b/examples/stubbing-spying__intercept/cypress/e2e/ping-spec.cy.js similarity index 81% rename from examples/stubbing-spying__intercept/cypress/integration/ping-spec.js rename to examples/stubbing-spying__intercept/cypress/e2e/ping-spec.cy.js index 1ad5afbbc..41953fa2a 100644 --- a/examples/stubbing-spying__intercept/cypress/integration/ping-spec.js +++ b/examples/stubbing-spying__intercept/cypress/e2e/ping-spec.cy.js @@ -1,7 +1,8 @@ /// // syntax is behind a flag in Firefox // https://caniuse.com/?search=anchor%20ping -// Thus make sure to enable it in the plugin file via the browser launch options +// Thus make sure to enable it in the `setupNodeEvents` function in the +// Cypress configuration via the browser launch options describe('intercept', () => { it('stubs anchor ping', () => { cy.visit('/') diff --git a/examples/stubbing-spying__intercept/cypress/integration/redirect-spec.js b/examples/stubbing-spying__intercept/cypress/e2e/redirect-spec.cy.js similarity index 100% rename from examples/stubbing-spying__intercept/cypress/integration/redirect-spec.js rename to examples/stubbing-spying__intercept/cypress/e2e/redirect-spec.cy.js diff --git a/examples/stubbing-spying__intercept/cypress/integration/repeat-spec.js b/examples/stubbing-spying__intercept/cypress/e2e/repeat-spec.cy.js similarity index 100% rename from examples/stubbing-spying__intercept/cypress/integration/repeat-spec.js rename to examples/stubbing-spying__intercept/cypress/e2e/repeat-spec.cy.js diff --git a/examples/stubbing-spying__intercept/cypress/integration/spy-on-fetch-spec.js b/examples/stubbing-spying__intercept/cypress/e2e/spy-on-fetch-spec.cy.js similarity index 100% rename from examples/stubbing-spying__intercept/cypress/integration/spy-on-fetch-spec.js rename to examples/stubbing-spying__intercept/cypress/e2e/spy-on-fetch-spec.cy.js diff --git a/examples/stubbing-spying__intercept/cypress/integration/stub-fetch-spec.js b/examples/stubbing-spying__intercept/cypress/e2e/stub-fetch-spec.cy.js similarity index 100% rename from examples/stubbing-spying__intercept/cypress/integration/stub-fetch-spec.js rename to examples/stubbing-spying__intercept/cypress/e2e/stub-fetch-spec.cy.js diff --git a/examples/stubbing-spying__intercept/cypress/integration/stubbed-api-spec.js b/examples/stubbing-spying__intercept/cypress/e2e/stubbed-api-spec.cy.js similarity index 100% rename from examples/stubbing-spying__intercept/cypress/integration/stubbed-api-spec.js rename to examples/stubbing-spying__intercept/cypress/e2e/stubbed-api-spec.cy.js diff --git a/examples/stubbing-spying__intercept/cypress/integration/times-spec.js b/examples/stubbing-spying__intercept/cypress/e2e/times-spec.cy.js similarity index 100% rename from examples/stubbing-spying__intercept/cypress/integration/times-spec.js rename to examples/stubbing-spying__intercept/cypress/e2e/times-spec.cy.js diff --git a/examples/stubbing-spying__intercept/cypress/plugins/index.js b/examples/stubbing-spying__intercept/cypress/plugins/index.js deleted file mode 100644 index 220d411d3..000000000 --- a/examples/stubbing-spying__intercept/cypress/plugins/index.js +++ /dev/null @@ -1,14 +0,0 @@ -module.exports = (on, config) => { - on('before:browser:launch', (browser = {}, launchOptions) => { - if (browser.family === 'firefox') { - // One of the tests uses feature that - // is behind a flag in Firefox browser. - // We can programmatically enable an option - // in Firefox using launch options - launchOptions.preferences['browser.send_pings'] = true - } - - // whatever you return here becomes the launchOptions - return launchOptions - }) -} diff --git a/examples/stubbing-spying__navigator/README.md b/examples/stubbing-spying__navigator/README.md index ddbf61a7c..e4e59ba4a 100644 --- a/examples/stubbing-spying__navigator/README.md +++ b/examples/stubbing-spying__navigator/README.md @@ -8,7 +8,7 @@ The application [index.html](index.html) displays a different message depending ## The tests -- [cypress/integration/spec.js](cypress/integration/spec.js) stubs the `window.navigator.cookieEnabled` method using [`cy.stub()`](https://on.cypress.io/stub). We create the method stub within the `onBeforeLoad` of the [`cy.visit()`](https://on.cypress.io/visit) +- [cypress/e2e/spec.cy.js](cypress/e2e/spec.cy.js) stubs the `window.navigator.cookieEnabled` method using [`cy.stub()`](https://on.cypress.io/stub). We create the method stub within the `onBeforeLoad` of the [`cy.visit()`](https://on.cypress.io/visit) ![Window open stub](images/navigator-cookie-enabled.png) diff --git a/examples/stubbing-spying__navigator/cypress.config.js b/examples/stubbing-spying__navigator/cypress.config.js new file mode 100644 index 000000000..4415f5033 --- /dev/null +++ b/examples/stubbing-spying__navigator/cypress.config.js @@ -0,0 +1,8 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + fixturesFolder: false, + e2e: { + supportFile: false, + }, +}) diff --git a/examples/stubbing-spying__navigator/cypress.json b/examples/stubbing-spying__navigator/cypress.json deleted file mode 100644 index e21846330..000000000 --- a/examples/stubbing-spying__navigator/cypress.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "pluginsFile": false, - "supportFile": false, - "fixturesFolder": false -} \ No newline at end of file diff --git a/examples/stubbing-spying__navigator/cypress/integration/spec.js b/examples/stubbing-spying__navigator/cypress/e2e/spec.cy.js similarity index 100% rename from examples/stubbing-spying__navigator/cypress/integration/spec.js rename to examples/stubbing-spying__navigator/cypress/e2e/spec.cy.js diff --git a/examples/stubbing-spying__window-fetch/README.md b/examples/stubbing-spying__window-fetch/README.md index abdf1c809..186a6b1e4 100644 --- a/examples/stubbing-spying__window-fetch/README.md +++ b/examples/stubbing-spying__window-fetch/README.md @@ -3,17 +3,17 @@ You can spy and stub `window.fetch` directly, or, to recreate the same [Network support](https://on.cypress.io/network-requests) experience, remove `window.fetch` completely and let your application fall back to `XMLHttpRequest` protocol. If the application does NOT have fallback mechanism, then the Cypress tests can provide it using a polyfill. -See individual spec files in [cypress/integration](cypress/integration) folder. +See individual spec files in [cypress/e2e](cypress/e2e) folder. Spec | Description --- | --- -[spy-on-fetch-spec.js](cypress/integration/spy-on-fetch-spec.js) | Observes calls the application makes using `window.fetch` via [`cy.spy()`](https://on.cypress.io/spy) -[stub-fetch-spec.js](cypress/integration/stub-fetch-spec.js) | Uses Cypress default network stubbing to intercept `fetch` calls from the application -[control-clock-spec.js](cypress/integration/control-clock-spec.js) | **Bonus:** shows how to "speed-up" application to make Ajax calls by controlling time using [`cy.clock()`](https://on.cypress.io/clock) and [`cy.tick()`](https://on.cypress.io/tick) +[spy-on-fetch-spec.cy.js](cypress/e2e/spy-on-fetch-spec.cy.js) | Observes calls the application makes using `window.fetch` via [`cy.spy()`](https://on.cypress.io/spy) +[stub-fetch-spec.cy.js](cypress/e2e/stub-fetch-spec.cy.js) | Uses Cypress default network stubbing to intercept `fetch` calls from the application +[control-clock-spec.cy.js](cypress/e2e/control-clock-spec.cy.js) | **Bonus:** shows how to "speed-up" application to make Ajax calls by controlling time using [`cy.clock()`](https://on.cypress.io/clock) and [`cy.tick()`](https://on.cypress.io/tick) ## Stubbing `fetch` -Cypress wraps the native XMLHttpRequest object to allow observing and stubbing network requests from the application. It also polyfills the native `window.fetch` method to work via wrapped XMLHttpRequest - this is how we allow network stubbing for applications that use `fetch` calls. See [cypress.json](cypress.json) +Cypress wraps the native XMLHttpRequest object to allow observing and stubbing network requests from the application. It also polyfills the native `window.fetch` method to work via wrapped XMLHttpRequest - this is how we allow network stubbing for applications that use `fetch` calls. See [cypress.config.js](cypress.config.js) ```json { diff --git a/examples/stubbing-spying__window-fetch/cypress.config.js b/examples/stubbing-spying__window-fetch/cypress.config.js new file mode 100644 index 000000000..6636bcb52 --- /dev/null +++ b/examples/stubbing-spying__window-fetch/cypress.config.js @@ -0,0 +1,10 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + fixturesFolder: false, + experimentalFetchPolyfill: true, + e2e: { + baseUrl: 'http://localhost:7080', + excludeSpecPattern: 'deferred.js', + }, +}) diff --git a/examples/stubbing-spying__window-fetch/cypress.json b/examples/stubbing-spying__window-fetch/cypress.json deleted file mode 100644 index 60a721f85..000000000 --- a/examples/stubbing-spying__window-fetch/cypress.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "baseUrl": "http://localhost:7080", - "ignoreTestFiles": "deferred.js", - "fixturesFolder": false, - "pluginsFile": false, - "experimentalFetchPolyfill": true -} diff --git a/examples/stubbing-spying__window-fetch/cypress/integration/control-clock-spec.js b/examples/stubbing-spying__window-fetch/cypress/e2e/control-clock-spec.cy.js similarity index 100% rename from examples/stubbing-spying__window-fetch/cypress/integration/control-clock-spec.js rename to examples/stubbing-spying__window-fetch/cypress/e2e/control-clock-spec.cy.js diff --git a/examples/stubbing-spying__window-fetch/cypress/integration/spy-on-fetch-spec.js b/examples/stubbing-spying__window-fetch/cypress/e2e/spy-on-fetch-spec.cy.js similarity index 100% rename from examples/stubbing-spying__window-fetch/cypress/integration/spy-on-fetch-spec.js rename to examples/stubbing-spying__window-fetch/cypress/e2e/spy-on-fetch-spec.cy.js diff --git a/examples/stubbing-spying__window-fetch/cypress/integration/stub-fetch-spec.js b/examples/stubbing-spying__window-fetch/cypress/e2e/stub-fetch-spec.cy.js similarity index 100% rename from examples/stubbing-spying__window-fetch/cypress/integration/stub-fetch-spec.js rename to examples/stubbing-spying__window-fetch/cypress/e2e/stub-fetch-spec.cy.js diff --git a/examples/stubbing-spying__window-fetch/cypress/support/e2e.js b/examples/stubbing-spying__window-fetch/cypress/support/e2e.js new file mode 100644 index 000000000..d1dd1353e --- /dev/null +++ b/examples/stubbing-spying__window-fetch/cypress/support/e2e.js @@ -0,0 +1,20 @@ +// *********************************************************** +// This example support/e2e.js is processed and +// loaded automatically before your test files. +// +// This is a great place to put global configuration and +// behavior that modifies Cypress. +// +// You can change the location of this file or turn off +// automatically serving support files with the +// 'supportFile' configuration option. +// +// You can read more here: +// https://on.cypress.io/configuration +// *********************************************************** + +// Import commands.js using ES2015 syntax: +import './commands' + +// Alternatively you can use CommonJS syntax: +// require('./commands') diff --git a/examples/stubbing-spying__window-fetch/cypress/support/index.js b/examples/stubbing-spying__window-fetch/cypress/support/index.js deleted file mode 100644 index d68db96df..000000000 --- a/examples/stubbing-spying__window-fetch/cypress/support/index.js +++ /dev/null @@ -1,20 +0,0 @@ -// *********************************************************** -// This example support/index.js is processed and -// loaded automatically before your test files. -// -// This is a great place to put global configuration and -// behavior that modifies Cypress. -// -// You can change the location of this file or turn off -// automatically serving support files with the -// 'supportFile' configuration option. -// -// You can read more here: -// https://on.cypress.io/configuration -// *********************************************************** - -// Import commands.js using ES2015 syntax: -import './commands' - -// Alternatively you can use CommonJS syntax: -// require('./commands') diff --git a/examples/stubbing-spying__window-print/README.md b/examples/stubbing-spying__window-print/README.md index e10541a14..acec87ad3 100644 --- a/examples/stubbing-spying__window-print/README.md +++ b/examples/stubbing-spying__window-print/README.md @@ -8,6 +8,6 @@ The page [index.html](index.html) calls `window.print` on button click. Without ![System print dialog](images/print-dialog.png) -By stubbing the `window.print` the [spec.js](cypress/integration/spec.js) can confirm the call has happened. +By stubbing the `window.print` the [spec.cy.js](cypress/e2e/spec.cy.js) can confirm the call has happened. ![Stub window print test](images/stub-print.png) diff --git a/examples/stubbing-spying__window-print/cypress.config.js b/examples/stubbing-spying__window-print/cypress.config.js new file mode 100644 index 000000000..4415f5033 --- /dev/null +++ b/examples/stubbing-spying__window-print/cypress.config.js @@ -0,0 +1,8 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + fixturesFolder: false, + e2e: { + supportFile: false, + }, +}) diff --git a/examples/stubbing-spying__window-print/cypress.json b/examples/stubbing-spying__window-print/cypress.json deleted file mode 100644 index e20ef7c43..000000000 --- a/examples/stubbing-spying__window-print/cypress.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "fixturesFolder": false, - "pluginsFile": false, - "supportFile": false -} \ No newline at end of file diff --git a/examples/stubbing-spying__window-print/cypress/integration/spec.js b/examples/stubbing-spying__window-print/cypress/e2e/spec.cy.js similarity index 100% rename from examples/stubbing-spying__window-print/cypress/integration/spec.js rename to examples/stubbing-spying__window-print/cypress/e2e/spec.cy.js diff --git a/examples/stubbing-spying__window/README.md b/examples/stubbing-spying__window/README.md index 5b5d1d289..4f7d1b7ef 100644 --- a/examples/stubbing-spying__window/README.md +++ b/examples/stubbing-spying__window/README.md @@ -8,10 +8,10 @@ The application [index.html](index.html) has a single button that executes `wind ## The tests -- [cypress/integration/spec.js](cypress/integration/spec.js) stubs the `window.open` method using [`cy.stub()`](https://on.cypress.io/stub). Because the application executes `window.open` after the click we create the method stub after [`cy.visit`](https://on.cypress.io/visit) +- [cypress/e2e/spec.cy.js](cypress/e2e/spec.cy.js) stubs the `window.open` method using [`cy.stub()`](https://on.cypress.io/stub). Because the application executes `window.open` after the click we create the method stub after [`cy.visit`](https://on.cypress.io/visit) ![Window open stub](images/window-open-stub.png) -- [cypress/integration/spy-before-load.js](cypress/integration/spy-before-load.js) starts spying on `console.log` during [`cy.visit`](https://on.cypress.io/visit) to confirm that `console.log('hello')` is called when the page loads. +- [cypress/e2e/spy-before-load.cy.js](cypress/e2e/spy-before-load.cy.js) starts spying on `console.log` during [`cy.visit`](https://on.cypress.io/visit) to confirm that `console.log('hello')` is called when the page loads. ![Spy on console.log](images/spy-before-load.png) diff --git a/examples/stubbing-spying__window/cypress.config.js b/examples/stubbing-spying__window/cypress.config.js new file mode 100644 index 000000000..4415f5033 --- /dev/null +++ b/examples/stubbing-spying__window/cypress.config.js @@ -0,0 +1,8 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + fixturesFolder: false, + e2e: { + supportFile: false, + }, +}) diff --git a/examples/stubbing-spying__window/cypress.json b/examples/stubbing-spying__window/cypress.json deleted file mode 100644 index e20ef7c43..000000000 --- a/examples/stubbing-spying__window/cypress.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "fixturesFolder": false, - "pluginsFile": false, - "supportFile": false -} \ No newline at end of file diff --git a/examples/stubbing-spying__window/cypress/integration/spec.js b/examples/stubbing-spying__window/cypress/e2e/spec.cy.js similarity index 100% rename from examples/stubbing-spying__window/cypress/integration/spec.js rename to examples/stubbing-spying__window/cypress/e2e/spec.cy.js diff --git a/examples/stubbing-spying__window/cypress/integration/spy-before-load.js b/examples/stubbing-spying__window/cypress/e2e/spy-before-load.cy.js similarity index 100% rename from examples/stubbing-spying__window/cypress/integration/spy-before-load.js rename to examples/stubbing-spying__window/cypress/e2e/spy-before-load.cy.js diff --git a/examples/stubbing__resources/README.md b/examples/stubbing__resources/README.md index b5782bc52..5caff7d57 100644 --- a/examples/stubbing__resources/README.md +++ b/examples/stubbing__resources/README.md @@ -1,6 +1,6 @@ # Stubbing Resources -The spec file [cypress/integration/spec.js](cypress/integration/spec.js) shows how to stub resources that are loaded e.g. by `img` tag. This works by observing DOM mutations and changing the `src` attribute. +The spec file [cypress/e2e/spec.cy.js](cypress/e2e/spec.cy.js) shows how to stub resources that are loaded e.g. by `img` tag. This works by observing DOM mutations and changing the `src` attribute. When clicking onto the button in the `index.html`, a new `img` tag is created that is supposed to load [images/rose.png](images/rose.png). Instead we load a red image from the fixture file [cypress/fixtures/picture.png](cypress/fixtures/picture.png). diff --git a/examples/stubbing__resources/cypress.config.js b/examples/stubbing__resources/cypress.config.js new file mode 100644 index 000000000..fab2f4bd0 --- /dev/null +++ b/examples/stubbing__resources/cypress.config.js @@ -0,0 +1,8 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + fixturesFolder: 'cypress/fixtures', + e2e: { + supportFile: false, + }, +}) diff --git a/examples/stubbing__resources/cypress.json b/examples/stubbing__resources/cypress.json deleted file mode 100644 index 79348b922..000000000 --- a/examples/stubbing__resources/cypress.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "pluginsFile": false, - "supportFile": false, - "fixturesFolder": "cypress/fixtures" -} \ No newline at end of file diff --git a/examples/stubbing__resources/cypress/integration/spec.js b/examples/stubbing__resources/cypress/e2e/spec.cy.js similarity index 100% rename from examples/stubbing__resources/cypress/integration/spec.js rename to examples/stubbing__resources/cypress/e2e/spec.cy.js diff --git a/examples/testing-dom__clipboard/README.md b/examples/testing-dom__clipboard/README.md index ed1f9d7d4..65902a42b 100644 --- a/examples/testing-dom__clipboard/README.md +++ b/examples/testing-dom__clipboard/README.md @@ -5,7 +5,7 @@ The widget to copy text is `@github/clipboard-copy-element` custom element that ![Copy / paste test](./images/copy-paste.gif) -See the [cypress/integration/spec.js](./cypress/integration/spec.js) file. The test currently work only in Electron where the clipboard permission is granted when Cypress starts it. +See the [cypress/e2e/spec.cy.js](./cypress/e2e/spec.cy.js) file. The test currently work only in Electron where the clipboard permission is granted when Cypress starts it. The page [index.html](./index.html) shows the copy button on "mouseover" event. When the text is copied to the clipboard, it shows a [tiny toast](https://github.com/bahmutov/tiny-toast) popup. diff --git a/examples/testing-dom__clipboard/cypress.config.js b/examples/testing-dom__clipboard/cypress.config.js new file mode 100644 index 000000000..1fa5c8583 --- /dev/null +++ b/examples/testing-dom__clipboard/cypress.config.js @@ -0,0 +1,10 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + fixturesFolder: false, + viewportWidth: 400, + viewportHeight: 300, + e2e: { + supportFile: false, + }, +}) diff --git a/examples/testing-dom__clipboard/cypress.json b/examples/testing-dom__clipboard/cypress.json deleted file mode 100644 index 48219963e..000000000 --- a/examples/testing-dom__clipboard/cypress.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "fixturesFolder": false, - "supportFile": false, - "pluginsFile": false, - "viewportWidth": 400, - "viewportHeight": 300 -} diff --git a/examples/testing-dom__clipboard/cypress/integration/permissions-spec.js b/examples/testing-dom__clipboard/cypress/e2e/permissions-spec.cy.js similarity index 100% rename from examples/testing-dom__clipboard/cypress/integration/permissions-spec.js rename to examples/testing-dom__clipboard/cypress/e2e/permissions-spec.cy.js diff --git a/examples/testing-dom__clipboard/cypress/integration/spec.js b/examples/testing-dom__clipboard/cypress/e2e/spec.cy.js similarity index 100% rename from examples/testing-dom__clipboard/cypress/integration/spec.js rename to examples/testing-dom__clipboard/cypress/e2e/spec.cy.js diff --git a/examples/testing-dom__csv-table/README.md b/examples/testing-dom__csv-table/README.md index a4dfb5608..4aff21671 100644 --- a/examples/testing-dom__csv-table/README.md +++ b/examples/testing-dom__csv-table/README.md @@ -6,7 +6,7 @@ Uses [neat-csv](https://github.com/sindresorhus/neat-csv) to parse the loaded CS ## Tests -- [spec.js](cypress/integration/spec.js) loads the CSV file using [`cy.readFile`](https://on.cypress.io/readfile), parses the text into list of objects, then goes through the rows of the table element comparing cell text content to the records. +- [spec.cy.js](cypress/e2e/spec.cy.js) loads the CSV file using [`cy.readFile`](https://on.cypress.io/readfile), parses the text into list of objects, then goes through the rows of the table element comparing cell text content to the records. ![Table test](images/rows.png) diff --git a/examples/testing-dom__csv-table/cypress.config.js b/examples/testing-dom__csv-table/cypress.config.js new file mode 100644 index 000000000..94cf53c2f --- /dev/null +++ b/examples/testing-dom__csv-table/cypress.config.js @@ -0,0 +1,10 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + fixturesFolder: false, + viewportWidth: 500, + viewportHeight: 1000, + e2e: { + supportFile: false, + }, +}) diff --git a/examples/testing-dom__csv-table/cypress.json b/examples/testing-dom__csv-table/cypress.json deleted file mode 100644 index 9ca7ac0da..000000000 --- a/examples/testing-dom__csv-table/cypress.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "fixturesFolder": false, - "supportFile": false, - "pluginsFile": false, - "viewportWidth": 500, - "viewportHeight": 1000 -} diff --git a/examples/testing-dom__csv-table/cypress/integration/spec.js b/examples/testing-dom__csv-table/cypress/e2e/spec.cy.js similarity index 100% rename from examples/testing-dom__csv-table/cypress/integration/spec.js rename to examples/testing-dom__csv-table/cypress/e2e/spec.cy.js diff --git a/examples/testing-dom__download/README.md b/examples/testing-dom__download/README.md index d423c7cfd..d3a8010c0 100644 --- a/examples/testing-dom__download/README.md +++ b/examples/testing-dom__download/README.md @@ -12,14 +12,14 @@ Spec file | Description ---|--- -[form-submission-spec.js](./cypress/integration/form-submission-spec.js) | Intercepts and verifies a file downloaded after a form submission -[local-download-spec.js](./cypress/integration/local-download-spec.js) | Downloads files from local domain by using `` anchor links -[location-href-spec.js](./cypress/integration/location-href-spec.js) | Intercepts and verifies a file downloaded via setting `document.location.href=...` URL -[remote-download-spec.js](./cypress/integration/remote-download-spec.js) | Downloads files from another domain by using `` anchor links +[form-submission-spec.cy.js](./cypress/e2e/form-submission-spec.cy.js) | Intercepts and verifies a file downloaded after a form submission +[local-download-spec.cy.js](./cypress/e2e/local-download-spec.cy.js) | Downloads files from local domain by using `` anchor links +[location-href-spec.cy.js](./cypress/e2e/location-href-spec.cy.js) | Intercepts and verifies a file downloaded via setting `document.location.href=...` URL +[remote-download-spec.cy.js](./cypress/e2e/remote-download-spec.cy.js) | Downloads files from another domain by using `` anchor links ## Notes -Text files are validated right from the browser spec, but the binary files like the downloaded Zip archives need to be validated from Node code using the plugins file, see [cypress/plugins/index.js](cypress/plugins/index.js) +Text files are validated right from the browser spec, but the binary files like the downloaded Zip archives need to be validated from Node code, see [setupNodeEvents](cypress.config.js) The spec also shows how to "catch" form submission that downloads a file using [cy.intercept()](https://on.cypress.io/intercept). After intercepting the request and redirecting back at the test, the test shows how to request the file and validate it. diff --git a/examples/testing-dom__download/cypress.config.js b/examples/testing-dom__download/cypress.config.js new file mode 100644 index 000000000..50d6439bc --- /dev/null +++ b/examples/testing-dom__download/cypress.config.js @@ -0,0 +1,150 @@ +const { defineConfig } = require('cypress') + +/* eslint-disable no-console */ +const AdmZip = require('adm-zip') +const globby = require('globby') +const { stripIndent } = require('common-tags') +const { rmdir } = require('fs') + +const { readExcelFile } = require('./document-utils/read-excel') +const { readPdf } = require('./document-utils/read-pdf') + +module.exports = defineConfig({ + fixturesFolder: false, + viewportWidth: 500, + viewportHeight: 900, + chromeWebSecurity: false, + pageLoadTimeout: 5000, + e2e: { + baseUrl: 'http://localhost:8070', + supportFile: false, + specPattern: 'cypress/e2e/**/*.cy.{js,jsx,ts,tsx}', + setupNodeEvents (on, config) { + // `on` is used to hook into various events Cypress emits + // `config` is the resolved Cypress config + // register utility tasks to read and parse Excel files + on('task', { + readExcelFile, + readPdf, + + validateZipFile (filename) { + // now let's validate the downloaded ZIP file + // the validations depend on your projects. For this example + // we will check that the zip has two entries "a.txt" and "b.txt" + // and that the contents of the zipped file "a.txt" are the same as expected + // Tip: use https://github.com/cthackers/adm-zip to load and unzip the Zip contents + console.log('loading zip', filename) + + const zip = new AdmZip(filename) + const zipEntries = zip.getEntries() + const names = zipEntries.map((entry) => entry.entryName).sort() + + console.log('zip file %s has entries %o', filename, names) + + // since this code is running in a Node process we do not have built-in "expect" or "assert" functions + // instead we can throw an Error object which fails the "cy.task" command + if (names.length !== 2) { + throw new Error( + `List of files ${names.join(',')} in ${filename} has extra files` + ) + } + + // if there is no error, let's print positive message to the terminal + // to let the user know this validation was successful + // console.log('✅ number of entries') + + if (!names.includes('a.txt')) { + throw new Error( + `List of files ${names.join(',')} in ${filename} is missing a.txt` + ) + } + + console.log('✅ has a.txt entry') + + if (!names.includes('b.txt')) { + throw new Error( + `List of files ${names.join(',')} in ${filename} is missing b.txt` + ) + } + + console.log('✅ has b.txt entry') + + // confirm the contents of an entry inside the Zip file + // the entry is just a text file in our case + // let's grab its text content and compare to the expected string + const aEntry = zip.readAsText('a.txt').trim() + + const expectedText = stripIndent` + hello zip + and Cypress recipes + ` + + if (aEntry !== expectedText) { + console.error('Expected file a.txt to have text') + console.error('------') + console.error(expectedText) + console.error('------') + console.error('but it had text') + console.error('------') + console.error(aEntry) + console.error('------') + + throw new Error(stripIndent` + Invalid a.txt entry in the zip file ${filename} + See terminal for more details + `) + } + + console.log('✅ a.txt file has the expected contents') + + // any other validations? + return null + }, + + // a task to find one file matching the given mask + // returns just the first matching file + async findFiles (mask) { + if (!mask) { + throw new Error('Missing a file mask to search') + } + + console.log('searching for files %s', mask) + const list = await globby(mask) + + if (!list.length) { + console.log('found no files') + + return null + } + + console.log('found %d files, first one %s', list.length, list[0]) + + return list[0] + }, + + deleteFolder (folderName) { + console.log('deleting folder %s', folderName) + + return new Promise((resolve, reject) => { + rmdir( + folderName, + { + maxRetries: 10, + recursive: true, + }, + (err) => { + if (err) { + console.error(err) + + return reject(err) + } + + resolve(null) + } + ) + }) + }, + }) + }, + }, +}) diff --git a/examples/testing-dom__download/cypress.json b/examples/testing-dom__download/cypress.json deleted file mode 100644 index 72a3e0fbe..000000000 --- a/examples/testing-dom__download/cypress.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "fixturesFolder": false, - "supportFile": false, - "viewportWidth": 500, - "viewportHeight": 900, - "baseUrl": "http://localhost:8070", - "chromeWebSecurity": false, - "pageLoadTimeout": 5000, - "testFiles": "**/*-spec.js" -} diff --git a/examples/testing-dom__download/cypress/integration/form-submission-spec.js b/examples/testing-dom__download/cypress/e2e/form-submission-spec.cy.js similarity index 91% rename from examples/testing-dom__download/cypress/integration/form-submission-spec.js rename to examples/testing-dom__download/cypress/e2e/form-submission-spec.cy.js index b334d2748..ae6dc77f0 100644 --- a/examples/testing-dom__download/cypress/integration/form-submission-spec.js +++ b/examples/testing-dom__download/cypress/e2e/form-submission-spec.cy.js @@ -1,11 +1,11 @@ // @ts-check /// -import { validateCsvList, deleteDownloadsFolder } from './utils' +import { validateCsvList } from './utils' const neatCSV = require('neat-csv') +// console.log() +// console.log() describe('file download', () => { - beforeEach(deleteDownloadsFolder) - context('form submission', () => { it('sends csv', () => { cy.visit('/') diff --git a/examples/testing-dom__download/cypress/integration/local-download-spec.js b/examples/testing-dom__download/cypress/e2e/local-download-spec.cy.js similarity index 95% rename from examples/testing-dom__download/cypress/integration/local-download-spec.js rename to examples/testing-dom__download/cypress/e2e/local-download-spec.cy.js index 81fe2f882..4f1878c7e 100644 --- a/examples/testing-dom__download/cypress/integration/local-download-spec.js +++ b/examples/testing-dom__download/cypress/e2e/local-download-spec.cy.js @@ -3,7 +3,7 @@ import { validateCsvList, validateCsvFile, validateExcelFile, validateTextFile, validateImage, validateZip, - validateBinaryFile, deleteDownloadsFolder, + validateBinaryFile, } from './utils' import { recurse } from 'cypress-recurse' const neatCSV = require('neat-csv') @@ -12,10 +12,6 @@ const path = require('path') describe('file download', () => { const downloadsFolder = Cypress.config('downloadsFolder') - // should we delete all the files in the downloads folder - // before each test? - beforeEach(deleteDownloadsFolder) - context('from local domain localhost:8070', () => { it('CSV file', () => { cy.visit('/') @@ -99,7 +95,7 @@ describe('file download', () => { cy.log('**confirm downloaded PDF**') validateBinaryFile('why-cypress.pdf', 97672) - // let's read PDF in the plugin file and confirm its basics + // let's read PDF and confirm its basics cy.task('readPdf', './cypress/downloads/why-cypress.pdf') // @ts-ignore .then(({ numpages, text }) => { diff --git a/examples/testing-dom__download/cypress/integration/location-href-spec.js b/examples/testing-dom__download/cypress/e2e/location-href-spec.cy.js similarity index 98% rename from examples/testing-dom__download/cypress/integration/location-href-spec.js rename to examples/testing-dom__download/cypress/e2e/location-href-spec.cy.js index 8ba9ddc61..779e0131b 100644 --- a/examples/testing-dom__download/cypress/integration/location-href-spec.js +++ b/examples/testing-dom__download/cypress/e2e/location-href-spec.cy.js @@ -2,13 +2,10 @@ /// import { validateCsv, validateCsvFile, downloadByClicking, - deleteDownloadsFolder, } from './utils' const path = require('path') describe('file download', () => { - beforeEach(deleteDownloadsFolder) - const downloadsFolder = Cypress.config('downloadsFolder') context('using location.href', () => { diff --git a/examples/testing-dom__download/cypress/integration/remote-download-spec.js b/examples/testing-dom__download/cypress/e2e/remote-download-spec.cy.js similarity index 98% rename from examples/testing-dom__download/cypress/integration/remote-download-spec.js rename to examples/testing-dom__download/cypress/e2e/remote-download-spec.cy.js index b39f117de..c397b9d18 100644 --- a/examples/testing-dom__download/cypress/integration/remote-download-spec.js +++ b/examples/testing-dom__download/cypress/e2e/remote-download-spec.cy.js @@ -3,14 +3,12 @@ import { validateCsvList, validateCsvFile, validateExcelFile, validateTextFile, validateImage, validateZip, - validateBinaryFile, deleteDownloadsFolder, + validateBinaryFile, } from './utils' const neatCSV = require('neat-csv') const path = require('path') describe('file download', () => { - beforeEach(deleteDownloadsFolder) - const downloadsFolder = Cypress.config('downloadsFolder') // The next step tries to download an image file located in diff --git a/examples/testing-dom__download/cypress/integration/utils.js b/examples/testing-dom__download/cypress/e2e/utils.js similarity index 91% rename from examples/testing-dom__download/cypress/integration/utils.js rename to examples/testing-dom__download/cypress/e2e/utils.js index 68fc3bb5c..36e5dfca9 100644 --- a/examples/testing-dom__download/cypress/integration/utils.js +++ b/examples/testing-dom__download/cypress/e2e/utils.js @@ -2,16 +2,6 @@ const path = require('path') const neatCSV = require('neat-csv') -/** - * Delete the downloads folder to make sure the test has "clean" - * slate before starting. - */ -export const deleteDownloadsFolder = () => { - const downloadsFolder = Cypress.config('downloadsFolder') - - cy.task('deleteFolder', downloadsFolder) -} - /** * @param {string} csv */ @@ -118,8 +108,8 @@ export const validateZip = () => { cy.readFile(downloadedFilename, 'binary', { timeout: 15000 }).should('have.length.gt', 300) // unzipping and validating a zip file requires the direct access to the file system - // thus it is easier to perform the checks from the plugins file that runs in Node - // see the plugins file "on('task')" code to see how we can read and validate a Zip file + // thus it is easier to perform the checks from the `setupNodeEvents` function in the Cypress configuration that runs in Node + // see the "on('task')" code in the `setupNodeEvents` function to see how we can read and validate a Zip file cy.task('validateZipFile', downloadedFilename) } diff --git a/examples/testing-dom__download/cypress/plugins/index.js b/examples/testing-dom__download/cypress/plugins/index.js deleted file mode 100644 index 8c6edbb1b..000000000 --- a/examples/testing-dom__download/cypress/plugins/index.js +++ /dev/null @@ -1,130 +0,0 @@ -/// -/* eslint-disable no-console */ -const AdmZip = require('adm-zip') -const { stripIndent } = require('common-tags') -const globby = require('globby') -const { rmdir } = require('fs') - -const { readExcelFile } = require('./read-excel') -const { readPdf } = require('./read-pdf') - -/** - * @type {Cypress.PluginConfig} - */ -module.exports = (on, config) => { - // `on` is used to hook into various events Cypress emits - // `config` is the resolved Cypress config - - // register utility tasks to read and parse Excel files - on('task', { - readExcelFile, - - readPdf, - - validateZipFile (filename) { - // now let's validate the downloaded ZIP file - // the validations depend on your projects. For this example - // we will check that the zip has two entries "a.txt" and "b.txt" - // and that the contents of the zipped file "a.txt" are the same as expected - - // Tip: use https://github.com/cthackers/adm-zip to load and unzip the Zip contents - console.log('loading zip', filename) - const zip = new AdmZip(filename) - const zipEntries = zip.getEntries() - - const names = zipEntries.map((entry) => entry.entryName).sort() - - console.log('zip file %s has entries %o', filename, names) - - // since this is plugins code we do not have built-in "expect" or "assert" functions - // instead we can throw an Error object which fails the "cy.task" command - if (names.length !== 2) { - throw new Error(`List of files ${names.join(',')} in ${filename} has extra files`) - } - - // if there is no error, let's print positive message to the terminal - // to let the user know this validation was successful - console.log('✅ number of entries') - - if (!names.includes('a.txt')) { - throw new Error(`List of files ${names.join(',')} in ${filename} is missing a.txt`) - } - - console.log('✅ has a.txt entry') - - if (!names.includes('b.txt')) { - throw new Error(`List of files ${names.join(',')} in ${filename} is missing b.txt`) - } - - console.log('✅ has b.txt entry') - - // confirm the contents of an entry inside the Zip file - // the entry is just a text file in our case - // let's grab its text content and compare to the expected string - const aEntry = zip.readAsText('a.txt').trim() - const expectedText = stripIndent` - hello zip - and Cypress recipes - ` - - if (aEntry !== expectedText) { - console.error('Expected file a.txt to have text') - console.error('------') - console.error(expectedText) - console.error('------') - console.error('but it had text') - console.error('------') - console.error(aEntry) - console.error('------') - throw new Error(stripIndent` - Invalid a.txt entry in the zip file ${filename} - See terminal for more details - `) - } - - console.log('✅ a.txt file has the expected contents') - - // any other validations? - - return null - }, - - // a task to find one file matching the given mask - // returns just the first matching file - async findFiles (mask) { - if (!mask) { - throw new Error('Missing a file mask to search') - } - - console.log('searching for files %s', mask) - - const list = await globby(mask) - - if (!list.length) { - console.log('found no files') - - return null - } - - console.log('found %d files, first one %s', list.length, list[0]) - - return list[0] - }, - - deleteFolder (folderName) { - console.log('deleting folder %s', folderName) - - return new Promise((resolve, reject) => { - rmdir(folderName, { maxRetries: 10, recursive: true }, (err) => { - if (err && err.code !== 'ENOENT') { - console.error(err) - - return reject(err) - } - - resolve(null) - }) - }) - }, - }) -} diff --git a/examples/testing-dom__download/cypress/plugins/read-excel.js b/examples/testing-dom__download/document-utils/read-excel.js similarity index 100% rename from examples/testing-dom__download/cypress/plugins/read-excel.js rename to examples/testing-dom__download/document-utils/read-excel.js diff --git a/examples/testing-dom__download/cypress/plugins/read-pdf.js b/examples/testing-dom__download/document-utils/read-pdf.js similarity index 83% rename from examples/testing-dom__download/cypress/plugins/read-pdf.js rename to examples/testing-dom__download/document-utils/read-pdf.js index 78f2315b1..300fc21be 100644 --- a/examples/testing-dom__download/cypress/plugins/read-pdf.js +++ b/examples/testing-dom__download/document-utils/read-pdf.js @@ -1,12 +1,12 @@ /* eslint-disable no-console */ -const fs = require('fs') +const { readFileSync } = require('fs') const pdf = require('pdf-parse') const readPdf = (filename) => { console.log('reading PDF file %s', filename) - const dataBuffer = fs.readFileSync(filename) + const dataBuffer = readFileSync(filename) return pdf(dataBuffer).then(function (data) { return { diff --git a/examples/testing-dom__download/package.json b/examples/testing-dom__download/package.json index 92e5e87f5..f6e408d8c 100644 --- a/examples/testing-dom__download/package.json +++ b/examples/testing-dom__download/package.json @@ -14,8 +14,6 @@ "cypress:run:win": "bin-up cypress run", "cypress:run:win:record": "bin-up cypress run --record --browser chrome", "dev": "../../node_modules/.bin/start-test start 8070 start:second 9000 cypress:open", - "no:test:ci:windows": "bin-up start-test start:win http://localhost:8070 cypress:run:win", - "no:test:ci:windows:record": "bin-up start-test start:win http://localhost:8070 cypress:run:win:record", "start": "../../node_modules/.bin/serve -l 8070 public", "start:second": "../../node_modules/.bin/serve -l 9000 public", "start:win": "bin-up serve -l 8070 --no-clipboard public", diff --git a/examples/testing-dom__drag-drop/README.md b/examples/testing-dom__drag-drop/README.md index ea23e1e05..02e3ab59b 100644 --- a/examples/testing-dom__drag-drop/README.md +++ b/examples/testing-dom__drag-drop/README.md @@ -2,7 +2,7 @@ > Performing Drag & Drop by triggering mouse and drag events -See test file [cypress/integration/drag_n_drop_spec.js](cypress/integration/drag_n_drop_spec.js) that shows how to simulate drag & drop behavior using +See test file [cypress/e2e/drag_n_drop_spec.cy.js](cypress/e2e/drag_n_drop_spec.cy.js) that shows how to simulate drag & drop behavior using - mouse events - drag events diff --git a/examples/testing-dom__drag-drop/cypress.config.js b/examples/testing-dom__drag-drop/cypress.config.js new file mode 100644 index 000000000..a2df52294 --- /dev/null +++ b/examples/testing-dom__drag-drop/cypress.config.js @@ -0,0 +1,9 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + fixturesFolder: false, + e2e: { + baseUrl: 'http://localhost:7071', + supportFile: false, + }, +}) diff --git a/examples/testing-dom__drag-drop/cypress.json b/examples/testing-dom__drag-drop/cypress.json deleted file mode 100644 index d8da1e79e..000000000 --- a/examples/testing-dom__drag-drop/cypress.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "baseUrl": "http://localhost:7071", - "fixturesFolder": false, - "pluginsFile": false, - "supportFile": false -} \ No newline at end of file diff --git a/examples/testing-dom__drag-drop/cypress/integration/drag_n_drop_spec.js b/examples/testing-dom__drag-drop/cypress/e2e/drag_n_drop_spec.cy.js similarity index 100% rename from examples/testing-dom__drag-drop/cypress/integration/drag_n_drop_spec.js rename to examples/testing-dom__drag-drop/cypress/e2e/drag_n_drop_spec.cy.js diff --git a/examples/testing-dom__form-interactions/README.md b/examples/testing-dom__form-interactions/README.md index 51967f88f..283d5187c 100644 --- a/examples/testing-dom__form-interactions/README.md +++ b/examples/testing-dom__form-interactions/README.md @@ -10,5 +10,5 @@ The test triggers `change` event on an ` Interact with elements that are hidden by CSS -See [cypress/integration/hover-hidden-elements-spec.js](cypress/integration/hover-hidden-elements-spec.js) to find how to get around Cypress' lack of `.hover()` command. +See [cypress/e2e/hover-hidden-elements-spec.cy.js](cypress/e2e/hover-hidden-elements-spec.cy.js) to find how to get around Cypress' lack of `.hover()` command. - Interact with elements that are hidden by CSS. - Use [`.invoke()`](https://on.cypress.io/invoke) and [`.trigger()`](https://on.cypress.io/trigger) to simulate hovering. diff --git a/examples/testing-dom__hover-hidden-elements/cypress.config.js b/examples/testing-dom__hover-hidden-elements/cypress.config.js new file mode 100644 index 000000000..959b1f666 --- /dev/null +++ b/examples/testing-dom__hover-hidden-elements/cypress.config.js @@ -0,0 +1,9 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + fixturesFolder: false, + e2e: { + baseUrl: 'http://localhost:7073', + supportFile: false, + }, +}) diff --git a/examples/testing-dom__hover-hidden-elements/cypress.json b/examples/testing-dom__hover-hidden-elements/cypress.json deleted file mode 100644 index fd4ad0473..000000000 --- a/examples/testing-dom__hover-hidden-elements/cypress.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "baseUrl": "http://localhost:7073", - "fixturesFolder": false, - "pluginsFile": false, - "supportFile": false -} \ No newline at end of file diff --git a/examples/testing-dom__hover-hidden-elements/cypress/integration/hover-hidden-elements-spec.js b/examples/testing-dom__hover-hidden-elements/cypress/e2e/hover-hidden-elements-spec.cy.js similarity index 100% rename from examples/testing-dom__hover-hidden-elements/cypress/integration/hover-hidden-elements-spec.js rename to examples/testing-dom__hover-hidden-elements/cypress/e2e/hover-hidden-elements-spec.cy.js diff --git a/examples/testing-dom__lit-element/cypress.config.js b/examples/testing-dom__lit-element/cypress.config.js new file mode 100644 index 000000000..7a67a9ce7 --- /dev/null +++ b/examples/testing-dom__lit-element/cypress.config.js @@ -0,0 +1,9 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + fixturesFolder: false, + experimentalShadowDomSupport: true, + e2e: { + supportFile: false, + }, +}) diff --git a/examples/testing-dom__lit-element/cypress.json b/examples/testing-dom__lit-element/cypress.json deleted file mode 100644 index ee5f8d499..000000000 --- a/examples/testing-dom__lit-element/cypress.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "pluginsFile": false, - "supportFile": false, - "fixturesFolder": false, - "experimentalShadowDomSupport": true -} diff --git a/examples/testing-dom__lit-element/cypress/integration/shadow-tests.ts b/examples/testing-dom__lit-element/cypress/e2e/shadow-tests.cy.ts similarity index 100% rename from examples/testing-dom__lit-element/cypress/integration/shadow-tests.ts rename to examples/testing-dom__lit-element/cypress/e2e/shadow-tests.cy.ts diff --git a/examples/testing-dom__lit-element/package.json b/examples/testing-dom__lit-element/package.json index 82b74372e..d8616fd5c 100644 --- a/examples/testing-dom__lit-element/package.json +++ b/examples/testing-dom__lit-element/package.json @@ -8,8 +8,6 @@ "start": "echo there is no web server to start in this project", "test:ci": "npm run cypress:run", "test:ci:firefox": "npm run cypress:run -- --browser firefox", - "test:ci:record": "npm run cypress:run -- --record", - "test:ci:windows": "bin-up cypress run", - "test:ci:windows:record": "bin-up cypress run --record --group unit-test-lit-element" + "test:ci:record": "npm run cypress:run -- --record" } } diff --git a/examples/testing-dom__page-reloads/README.md b/examples/testing-dom__page-reloads/README.md index 7b8fb305b..4a23c35ba 100644 --- a/examples/testing-dom__page-reloads/README.md +++ b/examples/testing-dom__page-reloads/README.md @@ -7,7 +7,7 @@ For example, this recipe shows how to reload the page until the target element r ![Test runs until the page shows 7](./images/lucky-7.gif) -See [cypress/integration/spec.js](cypress/integration/spec.js) file, in general it does the following: +See [cypress/e2e/spec.cy.js](cypress/e2e/spec.cy.js) file, in general it does the following: ```js it('until the number 7 appears', () => { diff --git a/examples/testing-dom__page-reloads/cypress.config.js b/examples/testing-dom__page-reloads/cypress.config.js new file mode 100644 index 000000000..9a8a5729f --- /dev/null +++ b/examples/testing-dom__page-reloads/cypress.config.js @@ -0,0 +1,10 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + fixturesFolder: false, + viewportHeight: 100, + viewportWidth: 100, + e2e: { + supportFile: false, + }, +}) diff --git a/examples/testing-dom__page-reloads/cypress.json b/examples/testing-dom__page-reloads/cypress.json deleted file mode 100644 index 37cbe808f..000000000 --- a/examples/testing-dom__page-reloads/cypress.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "viewportHeight": 100, - "viewportWidth": 100, - "pluginsFile": false, - "supportFile": false, - "fixturesFolder": false -} diff --git a/examples/testing-dom__page-reloads/cypress/integration/spec.js b/examples/testing-dom__page-reloads/cypress/e2e/spec.cy.js similarity index 100% rename from examples/testing-dom__page-reloads/cypress/integration/spec.js rename to examples/testing-dom__page-reloads/cypress/e2e/spec.cy.js diff --git a/examples/testing-dom__page-source/README.md b/examples/testing-dom__page-source/README.md index 413770070..845271b6b 100644 --- a/examples/testing-dom__page-source/README.md +++ b/examples/testing-dom__page-source/README.md @@ -3,4 +3,4 @@ ![Current HTML as text](./images/html-text.gif) -You can get the current document's HTML using `document.documentElement.outerHTML` property. Then you can validate / sanitize the HTML. You can even write it back as text into the current browser to see it, as [spec.js](./cypress/integration/spec.js) shows. +You can get the current document's HTML using `document.documentElement.outerHTML` property. Then you can validate / sanitize the HTML. You can even write it back as text into the current browser to see it, as [spec.cy.js](./cypress/e2e/spec.cy.js) shows. diff --git a/examples/testing-dom__page-source/cypress.config.js b/examples/testing-dom__page-source/cypress.config.js new file mode 100644 index 000000000..7715c27d6 --- /dev/null +++ b/examples/testing-dom__page-source/cypress.config.js @@ -0,0 +1,9 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + fixturesFolder: false, + e2e: { + baseUrl: 'https://www.cypress.io/', + supportFile: false, + }, +}) diff --git a/examples/testing-dom__page-source/cypress.json b/examples/testing-dom__page-source/cypress.json deleted file mode 100644 index 2282ed57a..000000000 --- a/examples/testing-dom__page-source/cypress.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "fixturesFolder": false, - "supportFile": false, - "pluginsFile": false, - "baseUrl": "https://www.cypress.io/" -} diff --git a/examples/testing-dom__page-source/cypress/integration/spec.js b/examples/testing-dom__page-source/cypress/e2e/spec.cy.js similarity index 100% rename from examples/testing-dom__page-source/cypress/integration/spec.js rename to examples/testing-dom__page-source/cypress/e2e/spec.cy.js diff --git a/examples/testing-dom__pagination/README.md b/examples/testing-dom__pagination/README.md index d10b8ad72..88623e9ae 100644 --- a/examples/testing-dom__pagination/README.md +++ b/examples/testing-dom__pagination/README.md @@ -3,4 +3,4 @@ ![The last page](./images/last-page.png) -See the [cypress/integration/spec.js](./cypress/integration/spec.js) file. +See the [cypress/e2e/spec.cy.js](./cypress/e2e/spec.cy.js) file. diff --git a/examples/testing-dom__pagination/cypress.config.js b/examples/testing-dom__pagination/cypress.config.js new file mode 100644 index 000000000..bdc66aa05 --- /dev/null +++ b/examples/testing-dom__pagination/cypress.config.js @@ -0,0 +1,10 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + fixturesFolder: false, + viewportHeight: 500, + viewportWidth: 500, + e2e: { + supportFile: false, + }, +}) diff --git a/examples/testing-dom__pagination/cypress.json b/examples/testing-dom__pagination/cypress.json deleted file mode 100644 index 757e57103..000000000 --- a/examples/testing-dom__pagination/cypress.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "viewportHeight": 500, - "viewportWidth": 500, - "pluginsFile": false, - "supportFile": false, - "fixturesFolder": false -} diff --git a/examples/testing-dom__pagination/cypress/integration/spec.js b/examples/testing-dom__pagination/cypress/e2e/spec.cy.js similarity index 100% rename from examples/testing-dom__pagination/cypress/integration/spec.js rename to examples/testing-dom__pagination/cypress/e2e/spec.cy.js diff --git a/examples/testing-dom__performance-metrics/README.md b/examples/testing-dom__performance-metrics/README.md index 825133900..012afae7f 100644 --- a/examples/testing-dom__performance-metrics/README.md +++ b/examples/testing-dom__performance-metrics/README.md @@ -1,6 +1,6 @@ # Utilize window.performance -The spec file [cypress/integration/spec.js](cypress/integration/spec.js) shows how you can utilize [cypress](https://cypress.io) to monitor your website. +The spec file [cypress/e2e/spec.cy.js](cypress/e2e/spec.cy.js) shows how you can utilize [cypress](https://cypress.io) to monitor your website. ![Test example](images/performance-example.png) diff --git a/examples/testing-dom__performance-metrics/cypress.config.js b/examples/testing-dom__performance-metrics/cypress.config.js new file mode 100644 index 000000000..4415f5033 --- /dev/null +++ b/examples/testing-dom__performance-metrics/cypress.config.js @@ -0,0 +1,8 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + fixturesFolder: false, + e2e: { + supportFile: false, + }, +}) diff --git a/examples/testing-dom__performance-metrics/cypress.json b/examples/testing-dom__performance-metrics/cypress.json deleted file mode 100644 index e36f98472..000000000 --- a/examples/testing-dom__performance-metrics/cypress.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "pluginsFile": false, - "supportFile": false, - "fixturesFolder": false -} diff --git a/examples/testing-dom__performance-metrics/cypress/integration/spec.js b/examples/testing-dom__performance-metrics/cypress/e2e/spec.cy.js similarity index 100% rename from examples/testing-dom__performance-metrics/cypress/integration/spec.js rename to examples/testing-dom__performance-metrics/cypress/e2e/spec.cy.js diff --git a/examples/testing-dom__responsive-image/README.md b/examples/testing-dom__responsive-image/README.md index f1d1c022a..a079ff37b 100644 --- a/examples/testing-dom__responsive-image/README.md +++ b/examples/testing-dom__responsive-image/README.md @@ -1,7 +1,7 @@ # Responsive image > Testing how the browser loads images depending on viewport -The test in [cypress/integration/spec.js](./cypress/integration/spec.js) observes the images loaded by the `` element to confirm that the mobile version is requested for mobile viewport. The desktop viewport causes the page to request the desktop image version. +The test in [cypress/e2e/spec.cy.js](./cypress/e2e/spec.cy.js) observes the images loaded by the `` element to confirm that the mobile version is requested for mobile viewport. The desktop viewport causes the page to request the desktop image version. ![The test](./images/picture.gif) diff --git a/examples/testing-dom__responsive-image/cypress.config.js b/examples/testing-dom__responsive-image/cypress.config.js new file mode 100644 index 000000000..4415f5033 --- /dev/null +++ b/examples/testing-dom__responsive-image/cypress.config.js @@ -0,0 +1,8 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + fixturesFolder: false, + e2e: { + supportFile: false, + }, +}) diff --git a/examples/testing-dom__responsive-image/cypress.json b/examples/testing-dom__responsive-image/cypress.json deleted file mode 100644 index 95670cdde..000000000 --- a/examples/testing-dom__responsive-image/cypress.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "fixturesFolder": false, - "supportFile": false, - "pluginsFile": false -} diff --git a/examples/testing-dom__responsive-image/cypress/integration/spec.js b/examples/testing-dom__responsive-image/cypress/e2e/spec.cy.js similarity index 100% rename from examples/testing-dom__responsive-image/cypress/integration/spec.js rename to examples/testing-dom__responsive-image/cypress/e2e/spec.cy.js diff --git a/examples/testing-dom__root-style/README.md b/examples/testing-dom__root-style/README.md index 9e649e52a..3c4771751 100644 --- a/examples/testing-dom__root-style/README.md +++ b/examples/testing-dom__root-style/README.md @@ -4,4 +4,4 @@ The application in [index.html](index.html) uses `` to set t ![triggered color change](images/red.gif) -Find tests in [cypress/integration/spec.js](cypress/integration/spec.js) file. +Find tests in [cypress/e2e/spec.cy.js](cypress/e2e/spec.cy.js) file. diff --git a/examples/testing-dom__root-style/cypress.config.js b/examples/testing-dom__root-style/cypress.config.js new file mode 100644 index 000000000..87a3debb6 --- /dev/null +++ b/examples/testing-dom__root-style/cypress.config.js @@ -0,0 +1,10 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + fixturesFolder: false, + viewportWidth: 300, + viewportHeight: 300, + e2e: { + supportFile: false, + }, +}) diff --git a/examples/testing-dom__root-style/cypress.json b/examples/testing-dom__root-style/cypress.json deleted file mode 100644 index 995bdf3c6..000000000 --- a/examples/testing-dom__root-style/cypress.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "fixturesFolder": false, - "supportFile": false, - "pluginsFile": false, - "viewportWidth": 300, - "viewportHeight": 300 -} diff --git a/examples/testing-dom__root-style/cypress/integration/spec.js b/examples/testing-dom__root-style/cypress/e2e/spec.cy.js similarity index 100% rename from examples/testing-dom__root-style/cypress/integration/spec.js rename to examples/testing-dom__root-style/cypress/e2e/spec.cy.js diff --git a/examples/testing-dom__select2/README.md b/examples/testing-dom__select2/README.md index a086b837c..a4fa1a738 100644 --- a/examples/testing-dom__select2/README.md +++ b/examples/testing-dom__select2/README.md @@ -3,7 +3,7 @@ This example shows how end-to-end tests work with plain `` - selecting multiple values using `