Skip to content

Instantly share code, notes, and snippets.

@slawekradzyminski
Created July 1, 2021 08:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slawekradzyminski/0d5e86f1fa84abeb26c9569868ccc390 to your computer and use it in GitHub Desktop.
Save slawekradzyminski/0d5e86f1fa84abeb26c9569868ccc390 to your computer and use it in GitHub Desktop.
/// <reference types="cypress" />
import { getRandomString } from "../util/random"
describe('home page', () => {
const firstName = getRandomString()
const lastName = getRandomString()
const username = getRandomString()
const password = getRandomString()
let id
let token
before(() => {
cy.request({
method: 'POST',
url: 'http://localhost:4000/users/register',
body: {
firstName: firstName,
lastName: lastName,
username: username,
password: password
}
}).then((response) => {
expect(response.status).to.eq(201)
id = response.body.id
})
cy.request({
method: 'POST',
url: 'http://localhost:4000/users/authenticate',
body: {
username: username,
password: password
}
}).then((response) => {
expect(response.status).to.eq(200)
token = response.body.token
})
})
beforeEach(() => {
const user = { token: token }
window.localStorage.setItem('user', JSON.stringify(user))
cy.visit('/')
})
it('should delete user', () => {
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment