Created
June 17, 2019 10:39
-
-
Save IhostVlad/7aaf5268712d49407ebea0a056ab6cd6 to your computer and use it in GitHub Desktop.
hackernews-stress
This file contains hidden or 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 { Selector } from 'testcafe' | |
const ROOT_URL = `https://jd05ienjxfkjegg8mim64t8z1e.resolve.sh` | |
const roundSeed = `${Date.now()}-${Math.floor(Math.random()*100000000000)}` | |
fixture`Testcafe stress` | |
test('Testcafe stress test', async (t) => { | |
await t.setNativeDialogHandler(() => true) | |
{ | |
await t.navigateTo(`${ROOT_URL}/login`) | |
await t.typeText(await Selector('input[type=text]').nth(2), `User-${roundSeed}`) | |
await t.click(await Selector('input[type=submit]').nth(1)) | |
} | |
{ | |
await t.navigateTo(`${ROOT_URL}/submit`) | |
await t.typeText(Selector('input[type=text]').nth(1), `Ask-${roundSeed}`) | |
await t.typeText('textarea', Array.from({ length: 50 }).map(_ => roundSeed).join(',')) | |
await t.click('button') | |
} | |
{ | |
await t.navigateTo(`${ROOT_URL}/newest`) | |
const titleLink = await Selector('a').withText(`Ask HN: Ask-${roundSeed}`) | |
await t.click(titleLink) | |
await t.wait(5000) | |
} | |
{ | |
const textarea = await Selector('textarea').nth(-1) | |
await t.typeText(textarea, 'first comment') | |
const button = await Selector('button').nth(-1) | |
await t.click(button) | |
await t.wait(5000) | |
} | |
{ | |
await t.navigateTo(`${ROOT_URL}/newest`) | |
await t.click(await Selector('a').withText(`Ask HN: Ask-${roundSeed}`).nth(-1)) | |
await t.wait(5000) | |
await t.click(await Selector('a').withText('reply').nth(-1)) | |
await t.wait(5000) | |
} | |
{ | |
const textarea = await Selector('textarea').nth(-1) | |
await t.typeText(textarea, Array.from({ length: 50 }).map(_ => roundSeed).join(',')) | |
const button = await Selector('button').nth(-1) | |
await t.click(button) | |
await t.wait(5000) | |
} | |
}) |
This file contains hidden or 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
{ | |
"name": "example", | |
"version": "0.0.2", | |
"license": "MIT", | |
"dependencies": { | |
"testcafe": "*" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment