Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
f2430d095f | |||
d79a5af51a |
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartbrowser",
|
"name": "@pushrocks/smartbrowser",
|
||||||
"version": "1.0.12",
|
"version": "1.0.13",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartbrowser",
|
"name": "@pushrocks/smartbrowser",
|
||||||
"version": "1.0.12",
|
"version": "1.0.13",
|
||||||
"description": "simplified puppeteer",
|
"description": "simplified puppeteer",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist/index.d.ts",
|
||||||
|
13
test/test.ts
13
test/test.ts
@ -3,22 +3,21 @@ import { tap, expect } from '@pushrocks/tapbundle';
|
|||||||
import * as smartbrowser from '../ts/index';
|
import * as smartbrowser from '../ts/index';
|
||||||
let testSmartBrowser: smartbrowser.SmartBrowser;
|
let testSmartBrowser: smartbrowser.SmartBrowser;
|
||||||
|
|
||||||
tap
|
tap.test('should instanstiate a new browser ', async () => {
|
||||||
.test('should instanstiate a new browser ', async () => {
|
testSmartBrowser = new smartbrowser.SmartBrowser();
|
||||||
testSmartBrowser = new smartbrowser.SmartBrowser();
|
return expect(testSmartBrowser).to.be.instanceof(smartbrowser.SmartBrowser);
|
||||||
return expect(testSmartBrowser).to.be.instanceof(smartbrowser.SmartBrowser);
|
});
|
||||||
})
|
|
||||||
|
|
||||||
tap.test('should start the browser ', async () => {
|
tap.test('should start the browser ', async () => {
|
||||||
await expect(testSmartBrowser.start()).to.eventually.be.fulfilled;
|
await expect(testSmartBrowser.start()).to.eventually.be.fulfilled;
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should create a PDF from a page', async (tools) => {
|
tap.test('should create a PDF from a page', async tools => {
|
||||||
const result = await testSmartBrowser.pdfFromPage('https://lossless.com');
|
const result = await testSmartBrowser.pdfFromPage('https://lossless.com');
|
||||||
expect(result.buffer).to.be.instanceOf(Buffer);
|
expect(result.buffer).to.be.instanceOf(Buffer);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should produce a valid screenshot', async (tools) => {
|
tap.test('should produce a valid screenshot', async tools => {
|
||||||
const result = await testSmartBrowser.screenshotFromPage('https://lossless.com');
|
const result = await testSmartBrowser.screenshotFromPage('https://lossless.com');
|
||||||
expect(result.buffer).to.be.instanceOf(Buffer);
|
expect(result.buffer).to.be.instanceOf(Buffer);
|
||||||
});
|
});
|
||||||
|
@ -44,7 +44,7 @@ export class SmartBrowser {
|
|||||||
* @param urlArg
|
* @param urlArg
|
||||||
* @param funcArg
|
* @param funcArg
|
||||||
*/
|
*/
|
||||||
public async evaluateOnPage (urlArg: string, funcArg: () => Promise<any>) {
|
public async evaluateOnPage(urlArg: string, funcArg: () => Promise<any>) {
|
||||||
const page = await this.headlessBrowser.newPage();
|
const page = await this.headlessBrowser.newPage();
|
||||||
await page.goto(urlArg, {
|
await page.goto(urlArg, {
|
||||||
waitUntil: 'networkidle2'
|
waitUntil: 'networkidle2'
|
||||||
@ -63,7 +63,6 @@ export class SmartBrowser {
|
|||||||
});
|
});
|
||||||
this.smartpdf = new plugins.smartpdf.SmartPdf();
|
this.smartpdf = new plugins.smartpdf.SmartPdf();
|
||||||
await this.smartpdf.start(this.headlessBrowser);
|
await this.smartpdf.start(this.headlessBrowser);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,2 +1 @@
|
|||||||
export * from './interfaces.screenshotresult';
|
export * from './interfaces.screenshotresult';
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user