Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
],
"dependencies": {
"@kikobeats/time-span": "~1.0.2",
"@metascraper/helpers": "~5.39.0",
"@metascraper/helpers": "~5.40.0",
"cheerio": "~1.0.0-rc.12",
"css-url-regex": "~4.0.0",
"debug-logfmt": "~1.2.0",
Expand Down Expand Up @@ -63,7 +63,6 @@
"pretty": "latest",
"puppeteer": "latest",
"regex-iso-date": "latest",
"signal-exit": "latest",
"simple-git-hooks": "latest",
"standard": "latest",
"standard-markdown": "latest",
Expand Down
4 changes: 3 additions & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ const PCancelable = require('p-cancelable')
const cheerio = require('cheerio')
const test = require('ava')

const { getBrowserless, prettyHtml } = require('./util')
const { initBrowserless, prettyHtml } = require('./util')
const getHTML = require('..')

const getBrowserless = initBrowserless(test)

const wait = async (promise, prop) => {
const res = await promise
return prop ? res[prop] : res
Expand Down
4 changes: 3 additions & 1 deletion test/prerender.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
const test = require('ava')

const getHTML = require('../src')
const { getBrowserless } = require('./util')
const { initBrowserless } = require('./util')

const getBrowserless = initBrowserless(test)

test('`{ prerender: true }`', async t => {
const url = 'https://example.com'
Expand Down
14 changes: 5 additions & 9 deletions test/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,16 @@

const createBrowserless = require('browserless')
const dateRegex = require('regex-iso-date')
const { onExit } = require('signal-exit')
const pretty = require('pretty')

const browserlessFactory = createBrowserless()

onExit(browserlessFactory.close)

const getBrowserless = async () => {
const browserless = await browserlessFactory.createContext()
return browserless
const initBrowserless = test => {
const browserlessFactory = createBrowserless()
test.after.always(browserlessFactory.close)
return () => browserlessFactory.createContext()
}

module.exports = {
prettyHtml: html =>
pretty(html, { ocd: true }).replace(dateRegex(), '{DATE}'),
getBrowserless
initBrowserless
}