cypress-on-rails 1.12.1 → 1.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (200) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +3 -3
  3. data/.gitignore +4 -1
  4. data/CHANGELOG.md +7 -0
  5. data/README.md +91 -5
  6. data/cypress-on-rails.gemspec +1 -0
  7. data/lib/cypress-on-rails.rb +2 -2
  8. data/lib/cypress_on_rails/configuration.rb +3 -0
  9. data/lib/cypress_on_rails/middleware.rb +6 -10
  10. data/lib/cypress_on_rails/middleware_config.rb +17 -0
  11. data/lib/cypress_on_rails/railtie.rb +5 -1
  12. data/lib/cypress_on_rails/vcr_middleware.rb +73 -0
  13. data/lib/cypress_on_rails/version.rb +1 -1
  14. data/lib/generators/cypress_on_rails/install_generator.rb +18 -24
  15. data/lib/generators/cypress_on_rails/templates/config/initializers/cypress_on_rails.rb.erb +1 -0
  16. data/lib/generators/cypress_on_rails/templates/spec/cypress/app_commands/clean.rb +6 -0
  17. data/lib/generators/cypress_on_rails/templates/spec/cypress/{cypress_helper.rb → cypress_helper.rb.erb} +5 -0
  18. data/lib/generators/cypress_on_rails/templates/spec/cypress/{integration/rails_examples/advance_factory_bot_spec.js → e2e/rails_examples/advance_factory_bot.cy.js} +0 -0
  19. data/lib/generators/cypress_on_rails/templates/spec/cypress/{integration/rails_examples/other_spec.js → e2e/rails_examples/other.cy.js} +0 -0
  20. data/lib/generators/cypress_on_rails/templates/spec/cypress/{integration/rails_examples/using_factory_bot_spec.js → e2e/rails_examples/using_factory_bot.cy.js} +0 -0
  21. data/lib/generators/cypress_on_rails/templates/spec/cypress/{integration/rails_examples/using_fixtures_spec.js → e2e/rails_examples/using_fixtures.cy.js} +0 -0
  22. data/lib/generators/cypress_on_rails/templates/spec/cypress/{integration/rails_examples/using_scenarios_spec.js → e2e/rails_examples/using_scenarios.cy.js} +0 -0
  23. data/lib/generators/cypress_on_rails/templates/spec/cypress/e2e/rails_examples/using_vcr.cy.js +24 -0
  24. data/lib/generators/cypress_on_rails/templates/spec/cypress/support/{index.js → index.js.erb} +1 -0
  25. data/lib/generators/cypress_on_rails/templates/spec/cypress/support/on-rails.js +1 -1
  26. data/lib/generators/cypress_on_rails/templates/spec/cypress.config.js +9 -0
  27. data/plugin/.gitignore +1 -0
  28. data/plugin/cypress/plugins/index.js +4 -0
  29. data/plugin/package.json +31 -0
  30. data/plugin/support/index.js +37 -0
  31. data/spec/cypress_on_rails/middleware_spec.rb +3 -1
  32. data/spec/cypress_on_rails/vcr_middleware_spec.rb +119 -0
  33. data/specs_e2e/cypress.config.js +10 -0
  34. data/{spec/integrations → specs_e2e}/rails_3_2/.gitignore +1 -1
  35. data/specs_e2e/rails_3_2/.ruby_version +1 -0
  36. data/{spec/integrations → specs_e2e}/rails_3_2/Gemfile +1 -1
  37. data/{spec/integrations → specs_e2e}/rails_3_2/README.rdoc +0 -0
  38. data/{spec/integrations → specs_e2e}/rails_3_2/Rakefile +0 -0
  39. data/{spec/integrations → specs_e2e}/rails_3_2/app/assets/stylesheets/application.css +0 -0
  40. data/{spec/integrations → specs_e2e}/rails_3_2/app/controllers/application_controller.rb +0 -0
  41. data/{spec/integrations → specs_e2e}/rails_3_2/app/controllers/welcome_controller.rb +0 -0
  42. data/{spec/integrations → specs_e2e}/rails_3_2/app/helpers/application_helper.rb +0 -0
  43. data/{spec/integrations → specs_e2e}/rails_3_2/app/models/post.rb +0 -0
  44. data/{spec/integrations → specs_e2e}/rails_3_2/app/views/layouts/application.html.erb +0 -0
  45. data/{spec/integrations → specs_e2e}/rails_3_2/app/views/welcome/index.html.erb +0 -0
  46. data/{spec/integrations → specs_e2e}/rails_3_2/bin/rails +0 -0
  47. data/{spec/integrations → specs_e2e}/rails_3_2/config/application.rb +0 -0
  48. data/{spec/integrations → specs_e2e}/rails_3_2/config/boot.rb +0 -0
  49. data/{spec/integrations → specs_e2e}/rails_3_2/config/environment.rb +0 -0
  50. data/{spec/integrations → specs_e2e}/rails_3_2/config/environments/development.rb +0 -0
  51. data/{spec/integrations → specs_e2e}/rails_3_2/config/environments/production.rb +0 -0
  52. data/{spec/integrations → specs_e2e}/rails_3_2/config/environments/test.rb +0 -0
  53. data/{spec/integrations → specs_e2e}/rails_3_2/config/initializers/backtrace_silencers.rb +0 -0
  54. data/{spec/integrations → specs_e2e}/rails_3_2/config/initializers/inflections.rb +0 -0
  55. data/{spec/integrations → specs_e2e}/rails_3_2/config/initializers/mime_types.rb +0 -0
  56. data/{spec/integrations → specs_e2e}/rails_3_2/config/initializers/secret_token.rb +0 -0
  57. data/{spec/integrations → specs_e2e}/rails_3_2/config/initializers/session_store.rb +0 -0
  58. data/{spec/integrations → specs_e2e}/rails_3_2/config/initializers/wrap_parameters.rb +0 -0
  59. data/{spec/integrations → specs_e2e}/rails_3_2/config/locales/en.yml +0 -0
  60. data/{spec/integrations → specs_e2e}/rails_3_2/config/routes.rb +0 -0
  61. data/{spec/integrations → specs_e2e}/rails_3_2/config.ru +0 -0
  62. data/{spec/integrations → specs_e2e}/rails_3_2/log/.keep +0 -0
  63. data/{spec/integrations → specs_e2e}/rails_3_2/public/404.html +0 -0
  64. data/{spec/integrations → specs_e2e}/rails_3_2/public/422.html +0 -0
  65. data/{spec/integrations → specs_e2e}/rails_3_2/public/500.html +0 -0
  66. data/{spec/integrations → specs_e2e}/rails_3_2/public/favicon.ico +0 -0
  67. data/{spec/integrations → specs_e2e}/rails_3_2/public/robots.txt +0 -0
  68. data/{spec/integrations → specs_e2e}/rails_3_2/test.sh +8 -7
  69. data/{spec/integrations → specs_e2e}/rails_3_2/tmp/.keep +0 -0
  70. data/{spec/integrations → specs_e2e}/rails_3_2/vendor/.gitkeep +0 -0
  71. data/{spec/integrations → specs_e2e}/rails_4_2/.gitignore +3 -2
  72. data/{spec/integrations → specs_e2e}/rails_4_2/Gemfile +3 -1
  73. data/{spec/integrations → specs_e2e}/rails_4_2/README.rdoc +0 -0
  74. data/{spec/integrations → specs_e2e}/rails_4_2/Rakefile +0 -0
  75. data/{spec/integrations/rails_5_2/app/assets/javascripts/posts.js → specs_e2e/rails_4_2/app/assets/javascripts/using_vcr.js} +0 -0
  76. data/{spec/integrations/rails_5_2/app/assets/stylesheets/posts.css → specs_e2e/rails_4_2/app/assets/stylesheets/using_vcr.css} +0 -0
  77. data/{spec/integrations → specs_e2e}/rails_4_2/app/controllers/application_controller.rb +0 -0
  78. data/specs_e2e/rails_4_2/app/controllers/using_vcr_controller.rb +10 -0
  79. data/{spec/integrations → specs_e2e}/rails_4_2/app/controllers/welcome_controller.rb +0 -0
  80. data/{spec/integrations → specs_e2e}/rails_4_2/app/models/post.rb +3 -1
  81. data/{spec/integrations → specs_e2e}/rails_4_2/app/views/layouts/application.html.erb +0 -0
  82. data/specs_e2e/rails_4_2/app/views/using_vcr/index.html.erb +6 -0
  83. data/specs_e2e/rails_4_2/app/views/using_vcr/record_cats.html.erb +7 -0
  84. data/{spec/integrations → specs_e2e}/rails_4_2/app/views/welcome/index.html.erb +0 -0
  85. data/{spec/integrations → specs_e2e}/rails_4_2/bin/bundle +0 -0
  86. data/{spec/integrations → specs_e2e}/rails_4_2/bin/rails +0 -0
  87. data/{spec/integrations → specs_e2e}/rails_4_2/bin/rake +0 -0
  88. data/{spec/integrations → specs_e2e}/rails_4_2/bin/setup +0 -0
  89. data/{spec/integrations → specs_e2e}/rails_4_2/config/application.rb +0 -0
  90. data/{spec/integrations → specs_e2e}/rails_4_2/config/boot.rb +0 -0
  91. data/{spec/integrations → specs_e2e}/rails_4_2/config/environment.rb +0 -0
  92. data/{spec/integrations → specs_e2e}/rails_4_2/config/environments/development.rb +0 -0
  93. data/{spec/integrations → specs_e2e}/rails_4_2/config/environments/production.rb +0 -0
  94. data/{spec/integrations → specs_e2e}/rails_4_2/config/environments/test.rb +0 -0
  95. data/{spec/integrations → specs_e2e}/rails_4_2/config/initializers/backtrace_silencers.rb +0 -0
  96. data/{spec/integrations → specs_e2e}/rails_4_2/config/initializers/cookies_serializer.rb +0 -0
  97. data/{spec/integrations → specs_e2e}/rails_4_2/config/initializers/filter_parameter_logging.rb +0 -0
  98. data/{spec/integrations → specs_e2e}/rails_4_2/config/initializers/inflections.rb +0 -0
  99. data/{spec/integrations → specs_e2e}/rails_4_2/config/initializers/mime_types.rb +0 -0
  100. data/{spec/integrations → specs_e2e}/rails_4_2/config/initializers/session_store.rb +0 -0
  101. data/{spec/integrations → specs_e2e}/rails_4_2/config/initializers/to_time_preserves_timezone.rb +0 -0
  102. data/{spec/integrations → specs_e2e}/rails_4_2/config/initializers/wrap_parameters.rb +0 -0
  103. data/{spec/integrations → specs_e2e}/rails_4_2/config/locales/en.yml +0 -0
  104. data/{spec/integrations → specs_e2e}/rails_4_2/config/routes.rb +5 -0
  105. data/{spec/integrations → specs_e2e}/rails_4_2/config/secrets.yml +0 -0
  106. data/{spec/integrations → specs_e2e}/rails_4_2/config.ru +0 -0
  107. data/specs_e2e/rails_4_2/package.json +10 -0
  108. data/{spec/integrations → specs_e2e}/rails_4_2/public/404.html +0 -0
  109. data/{spec/integrations → specs_e2e}/rails_4_2/public/422.html +0 -0
  110. data/{spec/integrations → specs_e2e}/rails_4_2/public/500.html +0 -0
  111. data/{spec/integrations → specs_e2e}/rails_4_2/public/favicon.ico +0 -0
  112. data/{spec/integrations → specs_e2e}/rails_4_2/public/robots.txt +0 -0
  113. data/{spec/integrations/rails_4_2/log → specs_e2e/rails_4_2/spec}/.keep +0 -0
  114. data/{spec/integrations → specs_e2e}/rails_4_2/test.sh +13 -12
  115. data/{spec/integrations/rails_4_2/spec → specs_e2e/rails_4_2/vendor}/.keep +0 -0
  116. data/{spec/integrations → specs_e2e}/rails_5_2/.gitignore +1 -1
  117. data/{spec/integrations → specs_e2e}/rails_5_2/Gemfile +1 -1
  118. data/{spec/integrations → specs_e2e}/rails_5_2/README.md +0 -0
  119. data/{spec/integrations → specs_e2e}/rails_5_2/Rakefile +0 -0
  120. data/specs_e2e/rails_5_2/app/assets/javascripts/posts.js +2 -0
  121. data/specs_e2e/rails_5_2/app/assets/stylesheets/posts.css +4 -0
  122. data/{spec/integrations → specs_e2e}/rails_5_2/app/assets/stylesheets/scaffold.css +0 -0
  123. data/{spec/integrations → specs_e2e}/rails_5_2/app/controllers/application_controller.rb +0 -0
  124. data/{spec/integrations → specs_e2e}/rails_5_2/app/controllers/posts_controller.rb +0 -0
  125. data/{spec/integrations → specs_e2e}/rails_5_2/app/helpers/posts_helper.rb +0 -0
  126. data/{spec/integrations → specs_e2e}/rails_5_2/app/jobs/application_job.rb +0 -0
  127. data/{spec/integrations → specs_e2e}/rails_5_2/app/models/application_record.rb +0 -0
  128. data/{spec/integrations → specs_e2e}/rails_5_2/app/models/post.rb +0 -0
  129. data/{spec/integrations → specs_e2e}/rails_5_2/app/views/layouts/application.html.erb +0 -0
  130. data/{spec/integrations → specs_e2e}/rails_5_2/app/views/posts/_form.html.erb +0 -0
  131. data/{spec/integrations → specs_e2e}/rails_5_2/app/views/posts/edit.html.erb +0 -0
  132. data/{spec/integrations → specs_e2e}/rails_5_2/app/views/posts/index.html.erb +0 -0
  133. data/{spec/integrations → specs_e2e}/rails_5_2/app/views/posts/new.html.erb +0 -0
  134. data/{spec/integrations → specs_e2e}/rails_5_2/app/views/posts/show.html.erb +0 -0
  135. data/{spec/integrations → specs_e2e}/rails_5_2/app/views/welcome/index.html.erb +0 -0
  136. data/{spec/integrations → specs_e2e}/rails_5_2/bin/bundle +0 -0
  137. data/{spec/integrations → specs_e2e}/rails_5_2/bin/rails +0 -0
  138. data/{spec/integrations → specs_e2e}/rails_5_2/bin/rake +0 -0
  139. data/{spec/integrations → specs_e2e}/rails_5_2/bin/setup +0 -0
  140. data/{spec/integrations → specs_e2e}/rails_5_2/bin/update +0 -0
  141. data/{spec/integrations → specs_e2e}/rails_5_2/config/application.rb +0 -0
  142. data/{spec/integrations → specs_e2e}/rails_5_2/config/boot.rb +0 -0
  143. data/{spec/integrations → specs_e2e}/rails_5_2/config/credentials.yml.enc +0 -0
  144. data/{spec/integrations → specs_e2e}/rails_5_2/config/database.yml +0 -0
  145. data/{spec/integrations → specs_e2e}/rails_5_2/config/environment.rb +0 -0
  146. data/{spec/integrations → specs_e2e}/rails_5_2/config/environments/development.rb +0 -0
  147. data/{spec/integrations → specs_e2e}/rails_5_2/config/environments/production.rb +0 -0
  148. data/{spec/integrations → specs_e2e}/rails_5_2/config/environments/test.rb +0 -0
  149. data/{spec/integrations → specs_e2e}/rails_5_2/config/initializers/application_controller_renderer.rb +0 -0
  150. data/{spec/integrations → specs_e2e}/rails_5_2/config/initializers/backtrace_silencers.rb +0 -0
  151. data/{spec/integrations → specs_e2e}/rails_5_2/config/initializers/content_security_policy.rb +0 -0
  152. data/{spec/integrations → specs_e2e}/rails_5_2/config/initializers/cookies_serializer.rb +0 -0
  153. data/{spec/integrations → specs_e2e}/rails_5_2/config/initializers/filter_parameter_logging.rb +0 -0
  154. data/{spec/integrations → specs_e2e}/rails_5_2/config/initializers/inflections.rb +0 -0
  155. data/{spec/integrations → specs_e2e}/rails_5_2/config/initializers/mime_types.rb +0 -0
  156. data/{spec/integrations → specs_e2e}/rails_5_2/config/initializers/wrap_parameters.rb +0 -0
  157. data/{spec/integrations → specs_e2e}/rails_5_2/config/locales/en.yml +0 -0
  158. data/{spec/integrations → specs_e2e}/rails_5_2/config/master.key +0 -0
  159. data/{spec/integrations → specs_e2e}/rails_5_2/config/routes.rb +0 -0
  160. data/{spec/integrations → specs_e2e}/rails_5_2/config.ru +0 -0
  161. data/{spec/integrations → specs_e2e}/rails_5_2/db/migrate/20180621085832_create_posts.rb +0 -0
  162. data/{spec/integrations → specs_e2e}/rails_5_2/public/404.html +0 -0
  163. data/{spec/integrations → specs_e2e}/rails_5_2/public/422.html +0 -0
  164. data/{spec/integrations → specs_e2e}/rails_5_2/public/500.html +0 -0
  165. data/{spec/integrations → specs_e2e}/rails_5_2/public/apple-touch-icon-precomposed.png +0 -0
  166. data/{spec/integrations → specs_e2e}/rails_5_2/public/apple-touch-icon.png +0 -0
  167. data/{spec/integrations → specs_e2e}/rails_5_2/public/favicon.ico +0 -0
  168. data/{spec/integrations → specs_e2e}/rails_5_2/public/robots.txt +0 -0
  169. data/{spec/integrations → specs_e2e}/rails_5_2/test/controllers/posts_controller_test.rb +0 -0
  170. data/{spec/integrations → specs_e2e}/rails_5_2/test/cypress_fixtures/posts.yml +0 -0
  171. data/{spec/integrations → specs_e2e}/rails_5_2/test/fixtures/posts.yml +0 -0
  172. data/{spec/integrations → specs_e2e}/rails_5_2/test/models/post_test.rb +0 -0
  173. data/{spec/integrations → specs_e2e}/rails_5_2/test.sh +8 -7
  174. data/{spec/integrations/rails_4_2 → specs_e2e/rails_5_2}/vendor/.keep +0 -0
  175. metadata +177 -171
  176. data/lib/generators/cypress_on_rails/templates/spec/cypress/fixtures/example.json +0 -5
  177. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/actions.spec.js +0 -272
  178. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/aliasing.spec.js +0 -42
  179. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/assertions.spec.js +0 -63
  180. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/connectors.spec.js +0 -55
  181. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/cookies.spec.js +0 -78
  182. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/cypress_api.spec.js +0 -211
  183. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/files.spec.js +0 -86
  184. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/local_storage.spec.js +0 -52
  185. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/location.spec.js +0 -32
  186. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/misc.spec.js +0 -68
  187. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/navigation.spec.js +0 -54
  188. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/network_requests.spec.js +0 -108
  189. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/querying.spec.js +0 -65
  190. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/spies_stubs_clocks.spec.js +0 -62
  191. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/traversal.spec.js +0 -121
  192. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/utilities.spec.js +0 -89
  193. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/viewport.spec.js +0 -59
  194. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/waiting.spec.js +0 -34
  195. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/window.spec.js +0 -22
  196. data/lib/generators/cypress_on_rails/templates/spec/cypress.json +0 -4
  197. data/spec/integrations/cypress.json +0 -5
  198. data/spec/integrations/rails_5_2/log/.keep +0 -0
  199. data/spec/integrations/rails_5_2/tmp/.keep +0 -0
  200. data/spec/integrations/rails_5_2/vendor/.keep +0 -0
@@ -1,211 +0,0 @@
1
- /// <reference types="Cypress" />
2
-
3
- context('Cypress.Commands', () => {
4
- beforeEach(() => {
5
- cy.visit('https://example.cypress.io/cypress-api')
6
- })
7
-
8
- // https://on.cypress.io/custom-commands
9
-
10
- it('.add() - create a custom command', () => {
11
- Cypress.Commands.add('console', {
12
- prevSubject: true,
13
- }, (subject, method) => {
14
- // the previous subject is automatically received
15
- // and the commands arguments are shifted
16
-
17
- // allow us to change the console method used
18
- method = method || 'log'
19
-
20
- // log the subject to the console
21
- console[method]('The subject is', subject)
22
-
23
- // whatever we return becomes the new subject
24
- // we don't want to change the subject so
25
- // we return whatever was passed in
26
- return subject
27
- })
28
-
29
- cy.get('button').console('info').then(($button) => {
30
- // subject is still $button
31
- })
32
- })
33
- })
34
-
35
-
36
- context('Cypress.Cookies', () => {
37
- beforeEach(() => {
38
- cy.visit('https://example.cypress.io/cypress-api')
39
- })
40
-
41
- // https://on.cypress.io/cookies
42
- it('.debug() - enable or disable debugging', () => {
43
- Cypress.Cookies.debug(true)
44
-
45
- // Cypress will now log in the console when
46
- // cookies are set or cleared
47
- cy.setCookie('fakeCookie', '123ABC')
48
- cy.clearCookie('fakeCookie')
49
- cy.setCookie('fakeCookie', '123ABC')
50
- cy.clearCookie('fakeCookie')
51
- cy.setCookie('fakeCookie', '123ABC')
52
- })
53
-
54
- it('.preserveOnce() - preserve cookies by key', () => {
55
- // normally cookies are reset after each test
56
- cy.getCookie('fakeCookie').should('not.be.ok')
57
-
58
- // preserving a cookie will not clear it when
59
- // the next test starts
60
- cy.setCookie('lastCookie', '789XYZ')
61
- Cypress.Cookies.preserveOnce('lastCookie')
62
- })
63
-
64
- it('.defaults() - set defaults for all cookies', () => {
65
- // now any cookie with the name 'session_id' will
66
- // not be cleared before each new test runs
67
- Cypress.Cookies.defaults({
68
- preserve: 'session_id',
69
- })
70
- })
71
- })
72
-
73
-
74
- context('Cypress.Server', () => {
75
- beforeEach(() => {
76
- cy.visit('https://example.cypress.io/cypress-api')
77
- })
78
-
79
- // Permanently override server options for
80
- // all instances of cy.server()
81
-
82
- // https://on.cypress.io/cypress-server
83
- it('.defaults() - change default config of server', () => {
84
- Cypress.Server.defaults({
85
- delay: 0,
86
- force404: false,
87
- preserve (xhr) {
88
- // handle custom logic for preserving
89
- },
90
- })
91
- })
92
- })
93
-
94
- context('Cypress.arch', () => {
95
- beforeEach(() => {
96
- cy.visit('https://example.cypress.io/cypress-api')
97
- })
98
-
99
- it('Get CPU architecture name of underlying OS', () => {
100
- // https://on.cypress.io/arch
101
- expect(Cypress.arch).to.exist
102
- })
103
- })
104
-
105
- context('Cypress.config()', () => {
106
- beforeEach(() => {
107
- cy.visit('https://example.cypress.io/cypress-api')
108
- })
109
-
110
- it('Get and set configuration options', () => {
111
- // https://on.cypress.io/config
112
- let myConfig = Cypress.config()
113
-
114
- expect(myConfig).to.have.property('animationDistanceThreshold', 5)
115
- expect(myConfig).to.have.property('baseUrl', 'http://localhost:5017')
116
- expect(myConfig).to.have.property('defaultCommandTimeout', 10000)
117
- expect(myConfig).to.have.property('requestTimeout', 5000)
118
- expect(myConfig).to.have.property('responseTimeout', 30000)
119
- expect(myConfig).to.have.property('viewportHeight', 660)
120
- expect(myConfig).to.have.property('viewportWidth', 1000)
121
- expect(myConfig).to.have.property('pageLoadTimeout', 60000)
122
- expect(myConfig).to.have.property('waitForAnimations', true)
123
-
124
- expect(Cypress.config('pageLoadTimeout')).to.eq(60000)
125
-
126
- // this will change the config for the rest of your tests!
127
- Cypress.config('pageLoadTimeout', 20000)
128
-
129
- expect(Cypress.config('pageLoadTimeout')).to.eq(20000)
130
-
131
- Cypress.config('pageLoadTimeout', 60000)
132
- })
133
- })
134
-
135
- context('Cypress.dom', () => {
136
- beforeEach(() => {
137
- cy.visit('https://example.cypress.io/cypress-api')
138
- })
139
-
140
- // https://on.cypress.io/dom
141
- it('.isHidden() - determine if a DOM element is hidden', () => {
142
- let hiddenP = Cypress.$('.dom-p p.hidden').get(0)
143
- let visibleP = Cypress.$('.dom-p p.visible').get(0)
144
-
145
- // our first paragraph has css class 'hidden'
146
- expect(Cypress.dom.isHidden(hiddenP)).to.be.true
147
- expect(Cypress.dom.isHidden(visibleP)).to.be.false
148
- })
149
- })
150
-
151
- context('Cypress.env()', () => {
152
- beforeEach(() => {
153
- cy.visit('https://example.cypress.io/cypress-api')
154
- })
155
-
156
- // We can set environment variables for highly dynamic values
157
-
158
- // https://on.cypress.io/environment-variables
159
- it('Get environment variables', () => {
160
- // https://on.cypress.io/env
161
- // set multiple environment variables
162
- Cypress.env({
163
- host: 'veronica.dev.local',
164
- api_server: 'http://localhost:8888/v1/',
165
- })
166
-
167
- // get environment variable
168
- expect(Cypress.env('host')).to.eq('veronica.dev.local')
169
-
170
- // set environment variable
171
- Cypress.env('api_server', 'http://localhost:8888/v2/')
172
- expect(Cypress.env('api_server')).to.eq('http://localhost:8888/v2/')
173
-
174
- // get all environment variable
175
- expect(Cypress.env()).to.have.property('host', 'veronica.dev.local')
176
- expect(Cypress.env()).to.have.property('api_server', 'http://localhost:8888/v2/')
177
- })
178
- })
179
-
180
- context('Cypress.log', () => {
181
- beforeEach(() => {
182
- cy.visit('https://example.cypress.io/cypress-api')
183
- })
184
-
185
- it('Control what is printed to the Command Log', () => {
186
- // https://on.cypress.io/cypress-log
187
- })
188
- })
189
-
190
-
191
- context('Cypress.platform', () => {
192
- beforeEach(() => {
193
- cy.visit('https://example.cypress.io/cypress-api')
194
- })
195
-
196
- it('Get underlying OS name', () => {
197
- // https://on.cypress.io/platform
198
- expect(Cypress.platform).to.be.exist
199
- })
200
- })
201
-
202
- context('Cypress.version', () => {
203
- beforeEach(() => {
204
- cy.visit('https://example.cypress.io/cypress-api')
205
- })
206
-
207
- it('Get current version of Cypress being run', () => {
208
- // https://on.cypress.io/version
209
- expect(Cypress.version).to.be.exist
210
- })
211
- })
@@ -1,86 +0,0 @@
1
- /// <reference types="Cypress" />
2
-
3
- context('Files', () => {
4
- beforeEach(() => {
5
- cy.visit('https://example.cypress.io/commands/files')
6
- })
7
- it('cy.fixture() - load a fixture', () => {
8
- // https://on.cypress.io/fixture
9
-
10
- // Instead of writing a response inline you can
11
- // use a fixture file's content.
12
-
13
- cy.server()
14
- cy.fixture('example.json').as('comment')
15
- cy.route('GET', 'comments/*', '@comment').as('getComment')
16
-
17
- // we have code that gets a comment when
18
- // the button is clicked in scripts.js
19
- cy.get('.fixture-btn').click()
20
-
21
- cy.wait('@getComment').its('responseBody')
22
- .should('have.property', 'name')
23
- .and('include', 'Using fixtures to represent data')
24
-
25
- // you can also just write the fixture in the route
26
- cy.route('GET', 'comments/*', 'fixture:example.json').as('getComment')
27
-
28
- // we have code that gets a comment when
29
- // the button is clicked in scripts.js
30
- cy.get('.fixture-btn').click()
31
-
32
- cy.wait('@getComment').its('responseBody')
33
- .should('have.property', 'name')
34
- .and('include', 'Using fixtures to represent data')
35
-
36
- // or write fx to represent fixture
37
- // by default it assumes it's .json
38
- cy.route('GET', 'comments/*', 'fx:example').as('getComment')
39
-
40
- // we have code that gets a comment when
41
- // the button is clicked in scripts.js
42
- cy.get('.fixture-btn').click()
43
-
44
- cy.wait('@getComment').its('responseBody')
45
- .should('have.property', 'name')
46
- .and('include', 'Using fixtures to represent data')
47
- })
48
-
49
- it('cy.readFile() - read a files contents', () => {
50
- // https://on.cypress.io/readfile
51
-
52
- // You can read a file and yield its contents
53
- // The filePath is relative to your project's root.
54
- cy.readFile('cypress.json').then((json) => {
55
- expect(json).to.be.an('object')
56
- })
57
- })
58
-
59
- it('cy.writeFile() - write to a file', () => {
60
- // https://on.cypress.io/writefile
61
-
62
- // You can write to a file
63
-
64
- // Use a response from a request to automatically
65
- // generate a fixture file for use later
66
- cy.request('https://jsonplaceholder.typicode.com/users')
67
- .then((response) => {
68
- cy.writeFile('cypress/fixtures/users.json', response.body)
69
- })
70
- cy.fixture('users').should((users) => {
71
- expect(users[0].name).to.exist
72
- })
73
-
74
- // JavaScript arrays and objects are stringified
75
- // and formatted into text.
76
- cy.writeFile('cypress/fixtures/profile.json', {
77
- id: 8739,
78
- name: 'Jane',
79
- email: 'jane@example.com',
80
- })
81
-
82
- cy.fixture('profile').should((profile) => {
83
- expect(profile.name).to.eq('Jane')
84
- })
85
- })
86
- })
@@ -1,52 +0,0 @@
1
- /// <reference types="Cypress" />
2
-
3
- context('Local Storage', () => {
4
- beforeEach(() => {
5
- cy.visit('https://example.cypress.io/commands/local-storage')
6
- })
7
- // Although local storage is automatically cleared
8
- // in between tests to maintain a clean state
9
- // sometimes we need to clear the local storage manually
10
-
11
- it('cy.clearLocalStorage() - clear all data in local storage', () => {
12
- // https://on.cypress.io/clearlocalstorage
13
- cy.get('.ls-btn').click().should(() => {
14
- expect(localStorage.getItem('prop1')).to.eq('red')
15
- expect(localStorage.getItem('prop2')).to.eq('blue')
16
- expect(localStorage.getItem('prop3')).to.eq('magenta')
17
- })
18
-
19
- // clearLocalStorage() yields the localStorage object
20
- cy.clearLocalStorage().should((ls) => {
21
- expect(ls.getItem('prop1')).to.be.null
22
- expect(ls.getItem('prop2')).to.be.null
23
- expect(ls.getItem('prop3')).to.be.null
24
- })
25
-
26
- // Clear key matching string in Local Storage
27
- cy.get('.ls-btn').click().should(() => {
28
- expect(localStorage.getItem('prop1')).to.eq('red')
29
- expect(localStorage.getItem('prop2')).to.eq('blue')
30
- expect(localStorage.getItem('prop3')).to.eq('magenta')
31
- })
32
-
33
- cy.clearLocalStorage('prop1').should((ls) => {
34
- expect(ls.getItem('prop1')).to.be.null
35
- expect(ls.getItem('prop2')).to.eq('blue')
36
- expect(ls.getItem('prop3')).to.eq('magenta')
37
- })
38
-
39
- // Clear keys matching regex in Local Storage
40
- cy.get('.ls-btn').click().should(() => {
41
- expect(localStorage.getItem('prop1')).to.eq('red')
42
- expect(localStorage.getItem('prop2')).to.eq('blue')
43
- expect(localStorage.getItem('prop3')).to.eq('magenta')
44
- })
45
-
46
- cy.clearLocalStorage(/prop1|2/).should((ls) => {
47
- expect(ls.getItem('prop1')).to.be.null
48
- expect(ls.getItem('prop2')).to.be.null
49
- expect(ls.getItem('prop3')).to.eq('magenta')
50
- })
51
- })
52
- })
@@ -1,32 +0,0 @@
1
- /// <reference types="Cypress" />
2
-
3
- context('Location', () => {
4
- beforeEach(() => {
5
- cy.visit('https://example.cypress.io/commands/location')
6
- })
7
-
8
- it('cy.hash() - get the current URL hash', () => {
9
- // https://on.cypress.io/hash
10
- cy.hash().should('be.empty')
11
- })
12
-
13
- it('cy.location() - get window.location', () => {
14
- // https://on.cypress.io/location
15
- cy.location().should((location) => {
16
- expect(location.hash).to.be.empty
17
- expect(location.href).to.eq('https://example.cypress.io/commands/location')
18
- expect(location.host).to.eq('example.cypress.io')
19
- expect(location.hostname).to.eq('example.cypress.io')
20
- expect(location.origin).to.eq('https://example.cypress.io')
21
- expect(location.pathname).to.eq('/commands/location')
22
- expect(location.port).to.eq('')
23
- expect(location.protocol).to.eq('https:')
24
- expect(location.search).to.be.empty
25
- })
26
- })
27
-
28
- it('cy.url() - get the current URL', () => {
29
- // https://on.cypress.io/url
30
- cy.url().should('eq', 'https://example.cypress.io/commands/location')
31
- })
32
- })
@@ -1,68 +0,0 @@
1
- /// <reference types="Cypress" />
2
-
3
- context('Misc', () => {
4
- beforeEach(() => {
5
- cy.visit('https://example.cypress.io/commands/misc')
6
- })
7
-
8
- it('.end() - end the command chain', () => {
9
- // https://on.cypress.io/end
10
-
11
- // cy.end is useful when you want to end a chain of commands
12
- // and force Cypress to re-query from the root element
13
- cy.get('.misc-table').within(() => {
14
- // ends the current chain and yields null
15
- cy.contains('Cheryl').click().end()
16
-
17
- // queries the entire table again
18
- cy.contains('Charles').click()
19
- })
20
- })
21
-
22
- it('cy.exec() - execute a system command', () => {
23
- // https://on.cypress.io/exec
24
-
25
- // execute a system command.
26
- // so you can take actions necessary for
27
- // your test outside the scope of Cypress.
28
- cy.exec('echo Jane Lane')
29
- .its('stdout').should('contain', 'Jane Lane')
30
-
31
- // we can use Cypress.platform string to
32
- // select appropriate command
33
- // https://on.cypress/io/platform
34
- cy.log(`Platform ${Cypress.platform} architecture ${Cypress.arch}`)
35
-
36
- if (Cypress.platform === 'win32') {
37
- cy.exec('print cypress.json')
38
- .its('stderr').should('be.empty')
39
- } else {
40
- cy.exec('cat cypress.json')
41
- .its('stderr').should('be.empty')
42
-
43
- cy.exec('pwd')
44
- .its('code').should('eq', 0)
45
- }
46
- })
47
-
48
- it('cy.focused() - get the DOM element that has focus', () => {
49
- // https://on.cypress.io/focused
50
- cy.get('.misc-form').find('#name').click()
51
- cy.focused().should('have.id', 'name')
52
-
53
- cy.get('.misc-form').find('#description').click()
54
- cy.focused().should('have.id', 'description')
55
- })
56
-
57
- it('cy.screenshot() - take a screenshot', () => {
58
- // https://on.cypress.io/screenshot
59
- cy.screenshot('my-image')
60
- })
61
-
62
- it('cy.wrap() - wrap an object', () => {
63
- // https://on.cypress.io/wrap
64
- cy.wrap({ foo: 'bar' })
65
- .should('have.property', 'foo')
66
- .and('include', 'bar')
67
- })
68
- })
@@ -1,54 +0,0 @@
1
- /// <reference types="Cypress" />
2
-
3
- context('Navigation', () => {
4
- beforeEach(() => {
5
- cy.visit('https://example.cypress.io')
6
- cy.get('.navbar-nav').contains('Commands').click()
7
- cy.get('.dropdown-menu').contains('Navigation').click()
8
- })
9
-
10
- it('cy.go() - go back or forward in the browser\'s history', () => {
11
- // https://on.cypress.io/go
12
-
13
- cy.location('pathname').should('include', 'navigation')
14
-
15
- cy.go('back')
16
- cy.location('pathname').should('not.include', 'navigation')
17
-
18
- cy.go('forward')
19
- cy.location('pathname').should('include', 'navigation')
20
-
21
- // clicking back
22
- cy.go(-1)
23
- cy.location('pathname').should('not.include', 'navigation')
24
-
25
- // clicking forward
26
- cy.go(1)
27
- cy.location('pathname').should('include', 'navigation')
28
- })
29
-
30
- it('cy.reload() - reload the page', () => {
31
- // https://on.cypress.io/reload
32
- cy.reload()
33
-
34
- // reload the page without using the cache
35
- cy.reload(true)
36
- })
37
-
38
- it('cy.visit() - visit a remote url', () => {
39
- // https://on.cypress.io/visit
40
-
41
- // Visit any sub-domain of your current domain
42
-
43
- // Pass options to the visit
44
- cy.visit('https://example.cypress.io/commands/navigation', {
45
- timeout: 50000, // increase total time for the visit to resolve
46
- onBeforeLoad (contentWindow) {
47
- // contentWindow is the remote page's window object
48
- },
49
- onLoad (contentWindow) {
50
- // contentWindow is the remote page's window object
51
- },
52
- })
53
- })
54
- })
@@ -1,108 +0,0 @@
1
- /// <reference types="Cypress" />
2
-
3
- context('Network Requests', () => {
4
- beforeEach(() => {
5
- cy.visit('https://example.cypress.io/commands/network-requests')
6
- })
7
-
8
- // Manage AJAX / XHR requests in your app
9
-
10
- it('cy.server() - control behavior of network requests and responses', () => {
11
- // https://on.cypress.io/server
12
-
13
- cy.server().should((server) => {
14
- // the default options on server
15
- // you can override any of these options
16
- expect(server.delay).to.eq(0)
17
- expect(server.method).to.eq('GET')
18
- expect(server.status).to.eq(200)
19
- expect(server.headers).to.be.null
20
- expect(server.response).to.be.null
21
- expect(server.onRequest).to.be.undefined
22
- expect(server.onResponse).to.be.undefined
23
- expect(server.onAbort).to.be.undefined
24
-
25
- // These options control the server behavior
26
- // affecting all requests
27
-
28
- // pass false to disable existing route stubs
29
- expect(server.enable).to.be.true
30
- // forces requests that don't match your routes to 404
31
- expect(server.force404).to.be.false
32
- // whitelists requests from ever being logged or stubbed
33
- expect(server.whitelist).to.be.a('function')
34
- })
35
-
36
- cy.server({
37
- method: 'POST',
38
- delay: 1000,
39
- status: 422,
40
- response: {},
41
- })
42
-
43
- // any route commands will now inherit the above options
44
- // from the server. anything we pass specifically
45
- // to route will override the defaults though.
46
- })
47
-
48
- it('cy.request() - make an XHR request', () => {
49
- // https://on.cypress.io/request
50
- cy.request('https://jsonplaceholder.typicode.com/comments')
51
- .should((response) => {
52
- expect(response.status).to.eq(200)
53
- expect(response.body).to.have.length(500)
54
- expect(response).to.have.property('headers')
55
- expect(response).to.have.property('duration')
56
- })
57
- })
58
-
59
- it('cy.route() - route responses to matching requests', () => {
60
- // https://on.cypress.io/route
61
-
62
- let message = 'whoa, this comment does not exist'
63
- cy.server()
64
-
65
- // Listen to GET to comments/1
66
- cy.route('GET', 'comments/*').as('getComment')
67
-
68
- // we have code that gets a comment when
69
- // the button is clicked in scripts.js
70
- cy.get('.network-btn').click()
71
-
72
- // https://on.cypress.io/wait
73
- cy.wait('@getComment').its('status').should('eq', 200)
74
-
75
- // Listen to POST to comments
76
- cy.route('POST', '/comments').as('postComment')
77
-
78
- // we have code that posts a comment when
79
- // the button is clicked in scripts.js
80
- cy.get('.network-post').click()
81
- cy.wait('@postComment')
82
-
83
- // get the route
84
- cy.get('@postComment').should((xhr) => {
85
- expect(xhr.requestBody).to.include('email')
86
- expect(xhr.requestHeaders).to.have.property('Content-Type')
87
- expect(xhr.responseBody).to.have.property('name', 'Using POST in cy.route()')
88
- })
89
-
90
- // Stub a response to PUT comments/ ****
91
- cy.route({
92
- method: 'PUT',
93
- url: 'comments/*',
94
- status: 404,
95
- response: { error: message },
96
- delay: 500,
97
- }).as('putComment')
98
-
99
- // we have code that puts a comment when
100
- // the button is clicked in scripts.js
101
- cy.get('.network-put').click()
102
-
103
- cy.wait('@putComment')
104
-
105
- // our 404 statusCode logic in scripts.js executed
106
- cy.get('.network-put-comment').should('contain', message)
107
- })
108
- })
@@ -1,65 +0,0 @@
1
- /// <reference types="Cypress" />
2
-
3
- context('Querying', () => {
4
- beforeEach(() => {
5
- cy.visit('https://example.cypress.io/commands/querying')
6
- })
7
-
8
- // The most commonly used query is 'cy.get()', you can
9
- // think of this like the '$' in jQuery
10
-
11
- it('cy.get() - query DOM elements', () => {
12
- // https://on.cypress.io/get
13
-
14
- cy.get('#query-btn').should('contain', 'Button')
15
-
16
- cy.get('.query-btn').should('contain', 'Button')
17
-
18
- cy.get('#querying .well>button:first').should('contain', 'Button')
19
- // ↲
20
- // Use CSS selectors just like jQuery
21
- })
22
-
23
- it('cy.contains() - query DOM elements with matching content', () => {
24
- // https://on.cypress.io/contains
25
- cy.get('.query-list')
26
- .contains('bananas').should('have.class', 'third')
27
-
28
- // we can pass a regexp to `.contains()`
29
- cy.get('.query-list')
30
- .contains(/^b\w+/).should('have.class', 'third')
31
-
32
- cy.get('.query-list')
33
- .contains('apples').should('have.class', 'first')
34
-
35
- // passing a selector to contains will
36
- // yield the selector containing the text
37
- cy.get('#querying')
38
- .contains('ul', 'oranges')
39
- .should('have.class', 'query-list')
40
-
41
- cy.get('.query-button')
42
- .contains('Save Form')
43
- .should('have.class', 'btn')
44
- })
45
-
46
- it('.within() - query DOM elements within a specific element', () => {
47
- // https://on.cypress.io/within
48
- cy.get('.query-form').within(() => {
49
- cy.get('input:first').should('have.attr', 'placeholder', 'Email')
50
- cy.get('input:last').should('have.attr', 'placeholder', 'Password')
51
- })
52
- })
53
-
54
- it('cy.root() - query the root DOM element', () => {
55
- // https://on.cypress.io/root
56
-
57
- // By default, root is the document
58
- cy.root().should('match', 'html')
59
-
60
- cy.get('.query-ul').within(() => {
61
- // In this within, the root is now the ul DOM element
62
- cy.root().should('have.class', 'query-ul')
63
- })
64
- })
65
- })