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:
parent
9ed752f292
commit
6374ff66aa
9
cypress.config.js
Normal file
9
cypress.config.js
Normal 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
43
cypress/e2e/form.cy.js
Normal 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')
|
||||||
|
|
||||||
|
})
|
||||||
|
})
|
@ -18,3 +18,11 @@
|
|||||||
|
|
||||||
[functions]
|
[functions]
|
||||||
node_bundler = "esbuild"
|
node_bundler = "esbuild"
|
||||||
|
|
||||||
|
[[plugins]]
|
||||||
|
package = "netlify-plugin-cypress"
|
||||||
|
[plugins.inputs.postBuild]
|
||||||
|
enable = true
|
||||||
|
|
||||||
|
[plugins.inputs]
|
||||||
|
enable = false
|
2007
package-lock.json
generated
2007
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -25,6 +25,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"core-js": "^3.19.3",
|
"core-js": "^3.19.3",
|
||||||
|
"cypress": "^10.0.3",
|
||||||
"nuxt": "^2.15.8",
|
"nuxt": "^2.15.8",
|
||||||
"vue": "^2.6.14",
|
"vue": "^2.6.14",
|
||||||
"vue-server-renderer": "^2.6.14",
|
"vue-server-renderer": "^2.6.14",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user