11import CommandLineArgs from "command-line-args" ;
22import MakeTaskRequest from "./helpers/MakeTaskRequest" ;
3+ import { ISODate } from "./helpers/ISODate" ;
34import Config from "./types/Config" ;
45import { readFileSync } from "fs" ;
56import fs from "fs" ;
@@ -10,6 +11,7 @@ const optionDefinitions = [
1011 { name : 'exact' , alias : 'e' , type : String , multiple : true } ,
1112 { name : 'remote' , alias : 'r' } ,
1213 { name : 'key' , alias : 'k' } ,
14+ { name : 'count' , alias : 'c' , default : 1 , type : Number } ,
1315] ;
1416
1517const args = CommandLineArgs ( optionDefinitions ) ;
@@ -28,8 +30,10 @@ Arguments:
2830 -e, --exact Run exact test by name
2931 -r, --remote Set target server (default: http://127.0.0.1:8080)
3032 -k, --key Override AUTH_KEY in requests
33+ -c, --count How much times to run each test (default: 1)
3134
3235Examples:
36+ npm run test -- -e "example" -c 5
3337 npm run test -- -e "example" -e "another"
3438 npm run test -- --all
3539` ) ;
@@ -44,15 +48,25 @@ Examples:
4448 if ( args . exact !== undefined && args . exact . length ) {
4549 console . log ( 'Running exact tests' ) ;
4650 args . exact . forEach ( ( testName : string ) => {
47- MakeTaskRequest ( testName , address , authkey ) ;
51+ for ( let i = 0 ; i < args . count ; i ++ ) {
52+ console . log ( `Running: ${ testName } #${ i + 1 } At: ${ new ISODate ( ) } ` ) ;
53+ ( async ( ) => {
54+ MakeTaskRequest ( testName , address , authkey , i + 1 ) ;
55+ } ) ( ) ;
56+ }
4857 } ) ;
4958 } else if ( args . all !== undefined ) {
5059 console . log ( 'Running all tests' ) ;
5160 const dir = __dirname + '/../test/' ;
5261 fs . readdir ( dir , ( err , files ) => {
5362 files . forEach ( fileName => {
54- console . log ( 'Running:' + fileName ) ;
55- MakeTaskRequest ( fileName , address , authkey ) ;
63+ console . log ( 'Current tests:' + fileName ) ;
64+ for ( let i = 0 ; i < args . count ; i ++ ) {
65+ console . log ( `Running: ${ fileName } #${ i + 1 } At: ${ new ISODate ( ) } ` ) ;
66+ ( async ( ) => {
67+ MakeTaskRequest ( fileName , address , authkey , i + 1 ) ;
68+ } ) ( ) ;
69+ }
5670 } ) ;
5771 } ) ;
5872 }
0 commit comments