@@ -32,23 +32,26 @@ export class ScraperTester<T, SO extends IScraperOptions, S extends Scraper<T, S
32
32
public testScraping ( urls : string [ ] , options ?: SO ) : this {
33
33
return this . addTest (
34
34
'should scrap data from a test page' ,
35
- ( ) => urls . forEach ( async url => {
36
- const scrap = await this . scraper . scrap ( url , options ) ;
37
- scrap . should . have . property ( 'success' ) . that . is . true ;
38
- scrap . should . have . property ( 'data' ) . that . is . an ( 'object' ) ;
39
- let data = scrap . data as any ;
40
- if ( 'sources' in data ) {
41
- data = data as ISourceData ;
42
- data . should . have . property ( 'sources' ) . that . is . an ( 'array' ) ;
43
- data . sources . length . should . be . greaterThan ( 0 ) ;
44
- data . sources . forEach ( s => s . should . have . property ( 'url' ) . that . is . a ( 'string' ) ) ;
45
- } else if ( 'hosters' in data ) {
46
- data = data as IHosterData ;
47
- data . should . have . property ( 'hosters' ) . that . is . an ( 'array' ) ;
48
- data . hosters . length . should . be . greaterThan ( 0 ) ;
49
- data . hosters . forEach ( s => s . should . have . property ( 'url' ) . that . is . a ( 'string' ) ) ;
50
- } else throw new Error ( 'Unexpected scraper type' ) ;
51
- } )
35
+ async ( ) => {
36
+ for ( const url of urls ) {
37
+ const scrap = await this . scraper . scrap ( url , options ) ;
38
+ console . log ( scrap ) ;
39
+ scrap . should . have . property ( 'success' ) . that . is . true ;
40
+ scrap . should . have . property ( 'data' ) . that . is . an ( 'object' ) ;
41
+ let data = scrap . data as any ;
42
+ if ( 'sources' in data ) {
43
+ data = data as ISourceData ;
44
+ data . should . have . property ( 'sources' ) . that . is . an ( 'array' ) ;
45
+ data . sources . length . should . be . greaterThan ( 0 ) ;
46
+ data . sources . forEach ( s => s . should . have . property ( 'url' ) . that . is . a ( 'string' ) ) ;
47
+ } else if ( 'hosters' in data ) {
48
+ data = data as IHosterData ;
49
+ data . should . have . property ( 'hosters' ) . that . is . an ( 'array' ) ;
50
+ data . hosters . length . should . be . greaterThan ( 0 ) ;
51
+ data . hosters . forEach ( s => s . should . have . property ( 'url' ) . that . is . a ( 'string' ) ) ;
52
+ } else throw new Error ( 'Unexpected scraper type' ) ;
53
+ }
54
+ }
52
55
) ;
53
56
}
54
57
protected getTestTarget ( ) : S {
0 commit comments