File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ const observer = `
3535 * @param {number } [opts.height] - Optional max height to clip overflow
3636 * @param {string } [opts.loadFontFamily] - Optional font family to load with fontfaceobserver
3737 * @param {boolean } [opts.loadGoogleFont=false] - Whether or not to load and wait for `opts.style.fontFamily` as one or more google fonts
38+ * @param {boolean } [opts.verbose=false] - Optional whether to log browser console messages
3839 * @param {object } [opts.style={}] - JS [CSS styles](https://www.w3schools.com/jsref/dom_obj_style.asp) to apply to the text's container div
3940 * @param {object } [opts.inject={}] - Optionally injects arbitrary string content into the head, style, or body elements.
4041 * @param {string } [opts.inject.head] - Optionally injected into the document <head>
@@ -51,6 +52,7 @@ export async function renderText(opts) {
5152 height = undefined ,
5253 loadFontFamily = undefined ,
5354 loadGoogleFont = false ,
55+ verbose = false ,
5456 style = { } ,
5557 inject = { }
5658 } = opts
@@ -152,8 +154,10 @@ ${inject.body || ''}
152154 } ) )
153155 const page = await browser . newPage ( )
154156
155- page . on ( 'console' , console . log )
156- page . on ( 'error' , console . error )
157+ if ( verbose ) {
158+ page . on ( 'console' , console . log )
159+ page . on ( 'error' , console . error )
160+ }
157161
158162 await page . setViewport ( {
159163 deviceScaleFactor : 1 ,
You can’t perform that action at this time.
0 commit comments