@error-paparazzi/jest
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -10,6 +10,4 @@ "use strict"; | ||
const puppeteer_1 = __importDefault(require("puppeteer")); | ||
const screenshot = async () => { | ||
const browser = await puppeteer_1.default.launch({ | ||
defaultViewport: { width: 375, height: 812 } | ||
}); | ||
const screenshot = async ({ launchOptions } = { launchOptions: {} }) => { | ||
const browser = await puppeteer_1.default.launch(launchOptions); | ||
const page = await browser.newPage(); | ||
@@ -21,3 +19,3 @@ await page.setContent(document.documentElement.outerHTML); | ||
}; | ||
exports.takeScreenshotOnError = () => { | ||
exports.takeScreenshotOnError = (params) => { | ||
const makeScreenshotOnFail = (fn) => async () => { | ||
@@ -29,3 +27,3 @@ try { | ||
if (!is_ci_1.default) | ||
await screenshot(); | ||
await screenshot(...params); | ||
throw e; | ||
@@ -32,0 +30,0 @@ } |
{ | ||
"name": "@error-paparazzi/jest", | ||
"version": "0.0.1", | ||
"private": false, | ||
"version": "0.0.2", | ||
"description": "Make screenshot of JSDOM when your jest test failed", | ||
@@ -6,0 +5,0 @@ "main": "lib/index.js", |
import isCi from "is-ci"; | ||
import open from "open"; | ||
import tmp from "tmp"; | ||
import pupetter from "puppeteer"; | ||
import pupetter, { LaunchOptions } from "puppeteer"; | ||
const screenshot = async () => { | ||
const browser = await pupetter.launch({ | ||
defaultViewport: { width: 375, height: 812 } | ||
}); | ||
const screenshot = async ( | ||
{ launchOptions }: { launchOptions?: LaunchOptions } = { launchOptions: {} } | ||
) => { | ||
const browser = await pupetter.launch(launchOptions); | ||
const page = await browser.newPage(); | ||
@@ -17,3 +17,5 @@ await page.setContent(document.documentElement.outerHTML); | ||
export const takeScreenshotOnError = () => { | ||
export const takeScreenshotOnError = ( | ||
params: Parameters<typeof screenshot> | ||
) => { | ||
const makeScreenshotOnFail = (fn: any) => async () => { | ||
@@ -23,3 +25,3 @@ try { | ||
} catch (e) { | ||
if (!isCi) await screenshot(); | ||
if (!isCi) await screenshot(...params); | ||
throw e; | ||
@@ -26,0 +28,0 @@ } |
@@ -11,4 +11,4 @@ { | ||
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ | ||
// "declaration": true, /* Generates corresponding '.d.ts' file. */ | ||
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ | ||
"declaration": true /* Generates corresponding '.d.ts' file. */, | ||
"declarationMap": true /* Generates a sourcemap for each corresponding '.d.ts' file. */, | ||
"sourceMap": true /* Generates corresponding '.map' file. */, | ||
@@ -15,0 +15,0 @@ // "outFile": "./", /* Concatenate and emit output to single file. */ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11339
8
138