File tree Expand file tree Collapse file tree 5 files changed +59
-1
lines changed Expand file tree Collapse file tree 5 files changed +59
-1
lines changed Original file line number Diff line number Diff line change 33node_modules
44npm-debug.log
55coverage
6+ test /e2e /results
Original file line number Diff line number Diff line change 55 "readmeFilename" : " README.md" ,
66 "main" : " index.js" ,
77 "scripts" : {
8- "test" : " istanbul cover node_modules/mocha/bin/_mocha --dir ./coverage --report lcov -- -R spec --recursive --timeout 7000 ./test && npm run eslint" ,
8+ "test" : " istanbul cover node_modules/mocha/bin/_mocha --dir ./coverage --report lcov -- -R spec --recursive --timeout 7000 ./test/unit/ ./test/functional && npm run eslint" ,
9+ "test-e2e" : " node_modules/mocha/bin/_mocha --timeout 60000 ./test/e2e/*-test.js" ,
910 "eslint" : " eslint lib/** index.js"
1011 },
1112 "repository" : {
Original file line number Diff line number Diff line change 1+ var should = require ( 'should' ) ;
2+ var scraper = require ( '../../index' ) ;
3+ var URL = require ( 'url' ) ;
4+ var fs = require ( 'fs-extra' ) ;
5+ var _ = require ( 'lodash' ) ;
6+
7+ var urls = require ( './urls.json' ) ;
8+ var options = require ( './options.json' ) ;
9+
10+ var resultDirname = __dirname + '/results' ;
11+
12+ describe ( 'E2E' , function ( ) {
13+ before ( function ( ) {
14+ fs . emptyDirSync ( resultDirname ) ;
15+ } ) ;
16+
17+ after ( function ( ) {
18+ console . log ( 'Scraping completed. Go to ' + resultDirname + ' to check results' ) ;
19+ } ) ;
20+
21+ urls . forEach ( function ( url ) {
22+ describe ( url , function ( ) {
23+ it ( 'should be successfully scraped' , function ( ) {
24+ var scraperOptions = _ . clone ( options ) ;
25+ var hostname = URL . parse ( url ) . hostname ;
26+ scraperOptions . directory = resultDirname + '/' + hostname ;
27+ scraperOptions . urls = [ { url : url , filename : 'index.html' } ] ;
28+ return scraper . scrape ( scraperOptions ) . then ( function ( result ) {
29+ result . should . be . ok ( ) ;
30+ } ) ;
31+ } ) ;
32+ } ) ;
33+ } ) ;
34+ } ) ;
Original file line number Diff line number Diff line change 1+ {
2+ "request" : {
3+ "headers" : {
4+ "User-Agent" : " Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36"
5+ }
6+ }
7+ }
Original file line number Diff line number Diff line change 1+ [
2+ " https://nodejs.org/docs/latest/api/documentation.html" ,
3+ " https://www.npmjs.com/" ,
4+ " https://www.airbnb.com/" ,
5+ " http://www.ebay.com/" ,
6+ " http://www.booking.com/" ,
7+ " https://www.kinopoisk.ru/" ,
8+ " https://www.linkedin.com/" ,
9+ " http://www.apple.com/" ,
10+ " https://habrahabr.ru/post/310794/" ,
11+ " http://www.caminitodelrey.info/" ,
12+ " http://eslint.org/docs/rules/" ,
13+ " http://www.lostfilm.tv/" ,
14+ " https://www.antipenko.pp.ua/"
15+ ]
You can’t perform that action at this time.
0 commit comments