Tn/add cypress (#47)

* added cypress, updated toml with cypress plugin, and created testing for the form

* Update cypress/e2e/form.cy.js

Co-authored-by: Prince Wilson <maxcell.wilson@gmail.com>

Co-authored-by: Prince Wilson <maxcell.wilson@gmail.com>
This commit is contained in:
Tatyana 2022-06-10 15:40:07 -05:00 committed by GitHub
parent 9ed752f292
commit 6374ff66aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 2068 additions and 0 deletions

9
cypress.config.js Normal file
View File

@ -0,0 +1,9 @@
const { defineConfig } = require('cypress')
module.exports = defineConfig({
e2e: {
baseUrl: "http://localhost:8888/",
supportFile: false,
chromeWebSecurity: false,
},
});

43
cypress/e2e/form.cy.js Normal file
View File

@ -0,0 +1,43 @@
describe('Testing form', () => {
const name = 'Testing'
const email = 'testing@testing.com'
const feedback = 'Testing form using Cypress'
beforeEach(() => {
cy.visit('/')
})
it('check for validation message for invalid email input', () => {
cy.get('[type="email"]').type('not_an_email')
cy.get('[type="submit"]').click()
cy.get('[type="email"]').then(($input) => {
expect($input[0].validationMessage).to.eq('Please include an \'@\' in the email address. \'not_an_email\' is missing an \'@\'.')
})
})
it('check for validation message for no email input', () => {
cy.get('[type="submit"]').click()
cy.get('[type="email"]').then(($input) => {
expect($input[0].validationMessage).to.eq('Please fill out this field.')
})
})
it('check for validation message with email and no feedback', () => {
cy.get('[type="email"]').type(email)
cy.get('[type="submit"]').click()
cy.get('#feedback').then(($input) => {
expect($input[0].validationMessage).to.eq('Please fill out this field.')
})
})
it('submitting feedback should redirect to /success', () => {
cy.get('#name').type(name)
cy.get('[type="email"]').type(email)
cy.get('#feedback').type(feedback)
cy.get('[type="submit"]').click()
cy.url().should('include', '/success')
})
})

View File

@ -18,3 +18,11 @@
[functions]
node_bundler = "esbuild"
[[plugins]]
package = "netlify-plugin-cypress"
[plugins.inputs.postBuild]
enable = true
[plugins.inputs]
enable = false

2007
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -25,6 +25,7 @@
},
"dependencies": {
"core-js": "^3.19.3",
"cypress": "^10.0.3",
"nuxt": "^2.15.8",
"vue": "^2.6.14",
"vue-server-renderer": "^2.6.14",