diff --git a/package.json b/package.json index 0450f82..8bf631f 100644 --- a/package.json +++ b/package.json @@ -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", @@ -63,7 +63,6 @@ "pretty": "latest", "puppeteer": "latest", "regex-iso-date": "latest", - "signal-exit": "latest", "simple-git-hooks": "latest", "standard": "latest", "standard-markdown": "latest", diff --git a/test/index.js b/test/index.js index d6fb04e..28df465 100644 --- a/test/index.js +++ b/test/index.js @@ -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 diff --git a/test/prerender.js b/test/prerender.js index 8ef00c8..e3000c3 100644 --- a/test/prerender.js +++ b/test/prerender.js @@ -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' diff --git a/test/util.js b/test/util.js index 3dbbada..72c18b6 100644 --- a/test/util.js +++ b/test/util.js @@ -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 }