Skip to content

Commit 6192d8a

Browse files
committed
Closes #12. Closes #8
1 parent 2553bf6 commit 6192d8a

File tree

4 files changed

+21
-11
lines changed

4 files changed

+21
-11
lines changed

cypress/integration/monkey/monkey.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const url = Cypress.config('baseUrl') || "https://uniandes.edu.co/"
66
const appName = Cypress.env('appName')|| "your app"
77
const events = Cypress.env('events')|| 100
88
const delay = Cypress.env('delay') || 100
9-
const seed = Cypress.env('seed') || 12
9+
var seed = Cypress.env('seed')
1010

1111
const pct_clicks = Cypress.env('pctClicks') || 19
1212
const pct_scrolls = Cypress.env('pctScroll') || 17
@@ -511,10 +511,11 @@ var pending_events = [,,,,,]
511511

512512
describe( `${appName} under monkeys`, function() {
513513
it(`visits ${appName} and survives monkeys`, function() {
514-
beforeEach(()=>{
515-
cy.task('logStart')
516-
})
514+
if(!seed) seed = getRandomInt(0, Number.MAX_SAFE_INTEGER);
517515

516+
cy.task('logStart', {"type":"monkey", "url":url, "seed":seed})
517+
cy.log(`Seed: ${seed}`)
518+
cy.task('genericLog', {"message":`Seed: ${seed}`})
518519
let pcg = pct_clicks+pct_scrolls+pct_keys+pct_pgnav+pct_selectors+pct_spkeys
519520
if(pcg === 100){
520521

cypress/integration/monkey/smart-monkey.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const url = Cypress.config('baseUrl') || "https://uniandes.edu.co/";
77
const appName = Cypress.env('appName')|| "your app";
88
const events = Cypress.env('events')|| 100;
99
const delay = Cypress.env('delay') || 100;
10-
const seed = Cypress.env('seed') || 12;
10+
var seed = Cypress.env('seed');
1111

1212
const num_categories = 7;
1313

@@ -639,9 +639,11 @@ const functions = [
639639

640640
describe( `${appName} under smarter monkeys`, function() {
641641
it(`visits ${appName} and survives smarter monkeys`, function() {
642-
beforeEach(()=>{
643-
cy.task('logStart')
644-
})
642+
if(!seed) seed = getRandomInt(0, Number.MAX_SAFE_INTEGER);
643+
644+
cy.task('logStart', {"type":"monkey", "url":url, "seed":seed})
645+
cy.log(`Seed: ${seed}`)
646+
cy.task('genericLog', {"message":`Seed: ${seed}`})
645647

646648
let pcg = pct_clicks+pct_scrolls+pct_keys+pct_pgnav+pct_selectors+pct_spkeys+pct_actions+pct_browserChaos;
647649
if(pcg === 100){

cypress/plugins/index.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,12 @@ module.exports = (on, config) => {
3333
})
3434
return null
3535
},
36-
logStart(){
37-
fs.appendFile(LOG_FILENAME, "<html><body><ol type = '1'>", (err) => {
36+
logStart({type, url, seed}){
37+
//Date might be inaccurate
38+
var currentdate = new Date(Date.now());
39+
var date = currentdate.getDay() + "/" + currentdate.getMonth() + "/" + currentdate.getFullYear();
40+
var time = currentdate.getHours() + ":" + currentdate.getMinutes() + ":" + currentdate.getSeconds();
41+
fs.appendFile(LOG_FILENAME, `<html><body><h1>Execution of ${type} in <a href = ${url}>${url}</a></h1><h2>Date of execution: ${date} at ${time}</h2><h2>Seed:${seed}</h2><ol type = '1'>`, (err) => {
3842
if (err) throw err
3943
console.log(`Log started`)
4044
})
@@ -52,6 +56,9 @@ module.exports = (on, config) => {
5256
if (err) throw err
5357
console.log(`Logged error`)
5458
})
59+
},
60+
genericLog({message}){
61+
console.log(message)
5562
}
5663
})
5764

monkey-config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
{
44
"projectId":"TSDL-Monkey-with-cypress",
5-
"baseUrl":"https://uniandes.edu.co/",
5+
"baseUrl":"https://caev03.github.io",
66
"env":{
77
"appName":"App prueba",
88
"events":50,

0 commit comments

Comments
 (0)