Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution #164

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions cypress/e2e/signUp.cy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
/// <reference types="cypress" />
import { generateUser } from '../support/generateUser';

const url = 'https://react-redux.realworld.io';

describe('Sign Up page', () => {
it('should provide an ability to register new account', () => {
const user = generateUser();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally, the base url is indicated in the config, but that's ok.


cy.visit(url + '/#/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(`a[class='nav-link']`)
.contains(user.username)
.should('exist');
});
});
12 changes: 12 additions & 0 deletions cypress/support/generateUser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { faker } from '@faker-js/faker';

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 };
}

module.exports = { generateUser };