diff --git a/cypress.config.js b/cypress.config.js index d811e2a..47386ff 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -1,9 +1,8 @@ -const { defineConfig } = require('cypress'); - -module.exports = defineConfig({ +module.exports = { e2e: { - setupNodeEvents(on, config) { - // implement node event listeners here - } - } -}); + baseUrl: 'https://react-redux.realworld.io', + viewportWidth: 650, + viewportHeight: 850, + defaultCommandTimeout: 10000, + }, +}; diff --git a/cypress/e2e/signUp.cy.js b/cypress/e2e/signUp.cy.js index 87cc96d..226ac4c 100644 --- a/cypress/e2e/signUp.cy.js +++ b/cypress/e2e/signUp.cy.js @@ -1,5 +1,20 @@ +/// + +import { generateUser } from '../support/generate'; + describe('Sign Up page', () => { it('should provide an ability to register new account', () => { + const user = generateUser(); + + cy.visit('/#/register'); + + + cy.get('input[placeholder="Username"]').type(user.username); + cy.get('input[placeholder="Email"]').type(user.email); + cy.get('input[placeholder="Password"]').type(user.password); + cy.get('button[type="submit"]').click(); + + cy.get('.navbar').should('contain', user.username); }); }); diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 119ab03..0cfda60 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -23,3 +23,13 @@ // // -- This will overwrite an existing command -- // Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) +import { faker } from '@faker-js/faker'; + +Cypress.Commands.add('generateUser', () => { + const randomNumber = Math.random().toString().slice(2, 6); + const username = faker.internet.userName() + '_' + randomNumber; + const email = `${username}@mail.com`; + const password = '12345Qwert!'; + + return { email, password, username }; +}); diff --git a/cypress/support/generate.js b/cypress/support/generate.js new file mode 100644 index 0000000..c63ecc0 --- /dev/null +++ b/cypress/support/generate.js @@ -0,0 +1,10 @@ +import { faker } from '@faker-js/faker'; + +export function generateUser() { + const randomNumber = Math.random().toString().slice(2, 6); + const username = faker.internet.userName() + '_' + randomNumber; + const email = `${username}@mail.com`; + const password = '12345Qwert!'; + + return { email, password, username }; +}