This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const request = require('supertest'); | |
const app = require('./app'); | |
describe('GET /', () => { | |
it('should return a 200 status code and a welcome message', async () => { | |
const res = await request(app).get('/'); | |
expect(res.statusCode).toEqual(200); | |
expect(res.body).toEqual({ message: 'Welcome to my API!' }); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const registerUrl = 'http://localhost:4000/users/signup' | |
export const register = (user: User) => { | |
const registerResponse = http.post(registerUrl, registerBody(user), { | |
headers: jsonHeaders, | |
}); | |
check(registerResponse, { "is status 201": (r) => r.status === 201 }); | |
} | |
const registerBody = (user: User) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function () { | |
const user = getUser() | |
register(user) | |
sleep(3) | |
const token = login(user) | |
sleep(3) | |
getAllUsers(token) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { sleep, check } from 'k6'; | |
import { Options } from 'k6/options'; | |
import http from 'k6/http'; | |
export let options:Options = { | |
vus: 100, | |
iterations: 100 | |
}; | |
export default () => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <reference types="cypress" /> | |
describe('home page', () => { | |
const array = [ | |
{ | |
id: 1, | |
firstName: 'Joann', | |
lastName: 'Ocado', | |
username: '12345', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <reference types="cypress" /> | |
describe('login page', () => { | |
const firstName = 'Slawek' | |
beforeEach(() => { | |
cy.visit('/login') | |
}) | |
it('should login', () => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <reference types="cypress" /> | |
describe('login page', () => { | |
const firstName = 'Slawek' | |
beforeEach(() => { | |
cy.visit('/login') | |
}) | |
it('should login', () => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// *********************************************************** | |
// This example support/index.js is processed and | |
// loaded automatically before your test files. | |
// | |
// This is a great place to put global configuration and | |
// behavior that modifies Cypress. | |
// | |
// You can change the location of this file or turn off | |
// automatically serving support files with the | |
// 'supportFile' configuration option. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <reference types="cypress" /> | |
import { getRandomString } from "../util/random" | |
describe('home page', () => { | |
const firstName = getRandomString() | |
const lastName = getRandomString() | |
const username = getRandomString() | |
const password = getRandomString() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <reference types="cypress" /> | |
import { loginPage } from "../../pages/loginpage" | |
import { getRandomString } from "../../util/randomutil" | |
context('Register tests', () => { | |
const username = getRandomString() | |
const password = getRandomString() |