Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Oct 19, 2019. It is now read-only.

Commit a32534d

Browse files
Update ScraperTester.ts
1 parent 73a19e5 commit a32534d

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

‎packages/source-scraper-test-utils/lib/ScraperTester.ts

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,26 @@ export class ScraperTester<T, SO extends IScraperOptions, S extends Scraper<T, S
3232
public testScraping(urls: string[], options?: SO): this {
3333
return this.addTest(
3434
'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+
}
5255
);
5356
}
5457
protected getTestTarget(): S {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /