File size: 1,781 Bytes
e60e8d0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | process.env.NODE_ENV = 'development'
const server = require('../src/index')
const request = require("supertest")
beforeAll(async () => {
while (!global.browser) {
await new Promise(resolve => setTimeout(resolve, 1000));
}
}, 30000);
afterAll(async () => {
global.finished = true
await global.browser.close()
})
test('Scraping Page Source from Cloudflare Protection', async () => {
return request(server)
.post("/cf-clearance-scraper")
.send({
url: 'https://nopecha.com/demo/cloudflare',
mode: "source"
})
.expect(200)
.then(response => { expect(response.body.code).toEqual(200); })
}, 60000)
test('Creating a Turnstile Token With Site Key [min]', async () => {
return request(server)
.post("/cf-clearance-scraper")
.send({
url: 'https://turnstile.zeroclover.io/',
siteKey: "0x4AAAAAAAEwzhD6pyKkgXC0",
mode: "turnstile-min"
})
.expect(200)
.then(response => { expect(response.body.code).toEqual(200); })
}, 60000)
test('Creating a Turnstile Token With Site Key [max]', async () => {
return request(server)
.post("/cf-clearance-scraper")
.send({
url: 'https://turnstile.zeroclover.io/',
mode: "turnstile-max"
})
.expect(200)
.then(response => { expect(response.body.code).toEqual(200); })
}, 60000)
test('Create Cloudflare WAF Session', async () => {
return request(server)
.post("/cf-clearance-scraper")
.send({
url: 'https://nopecha.com/demo/cloudflare',
mode: "waf-session"
})
.expect(200)
.then(response => { expect(response.body.code).toEqual(200); })
}, 60000) |