diff options
-rw-r--r-- | tests.js | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -56,6 +56,21 @@ function next() { | |||
56 | } | 56 | } |
57 | } | 57 | } |
58 | 58 | ||
59 | /** | ||
60 | * Randomize array element order in-place. | ||
61 | * Using Durstenfeld shuffle algorithm. | ||
62 | * See http://stackoverflow.com/a/12646864 | ||
63 | */ | ||
64 | function shuffle(array) { | ||
65 | for (var i = array.length - 1; i > 0; i--) { | ||
66 | var j = Math.floor(Math.random() * (i + 1)); | ||
67 | var temp = array[i]; | ||
68 | array[i] = array[j]; | ||
69 | array[j] = temp; | ||
70 | } | ||
71 | return array; | ||
72 | } | ||
73 | |||
59 | tests = [ | 74 | tests = [ |
60 | 75 | ||
61 | // Page loads with status of 'success' | 76 | // Page loads with status of 'success' |
@@ -602,4 +617,5 @@ page.open(url, function(status) { | |||
602 | ]; | 617 | ]; |
603 | 618 | ||
604 | console.log("Running tests..."); | 619 | console.log("Running tests..."); |
620 | tests = shuffle(tests); | ||
605 | next(); | 621 | next(); |