@@ -7,7 +7,9 @@ import type { ConsoleLog, LogLevel, NightwatchTestCase } from '../types.js'
77export function determineTestState (
88 testcase : NightwatchTestCase
99) : 'passed' | 'failed' | 'skipped' {
10- if ( testcase . passed === 0 && testcase . failed === 0 ) return 'skipped'
10+ if ( testcase . passed === 0 && testcase . failed === 0 ) {
11+ return 'skipped'
12+ }
1113 return testcase . passed > 0 && testcase . failed === 0 ? 'passed' : 'failed'
1214}
1315
@@ -20,7 +22,11 @@ const signatureCounters = new Map<string, number>()
2022 */
2123export function generateStableUid ( itemOrFile : any , name ?: string ) : string {
2224 let file : string , testName : string
23- if ( typeof itemOrFile === 'object' && itemOrFile !== null && name === undefined ) {
25+ if (
26+ typeof itemOrFile === 'object' &&
27+ itemOrFile !== null &&
28+ name === undefined
29+ ) {
2430 file = itemOrFile . file || ''
2531 testName = String ( itemOrFile . fullTitle || itemOrFile . title )
2632 } else {
@@ -235,15 +241,18 @@ export function findTestFileByName(
235241/**
236242 * Strip ANSI escape codes from a string.
237243 */
238- export const stripAnsiCodes = ( text : string ) : string => text . replace ( ANSI_REGEX , '' )
244+ export const stripAnsiCodes = ( text : string ) : string =>
245+ text . replace ( ANSI_REGEX , '' )
239246
240247/**
241248 * Infer a log level from the text content of a line.
242249 */
243250export function detectLogLevel ( text : string ) : LogLevel {
244251 const low = stripAnsiCodes ( text ) . toLowerCase ( )
245252 for ( const { level, pattern } of LOG_LEVEL_PATTERNS ) {
246- if ( pattern . test ( low ) ) return level
253+ if ( pattern . test ( low ) ) {
254+ return level
255+ }
247256 }
248257 return 'log'
249258}
@@ -267,11 +276,16 @@ export function chromeLogLevelToLogLevel(
267276) : LogLevel {
268277 const s = typeof level === 'object' ? ( level ?. name ?? '' ) : ( level ?? '' )
269278 switch ( s . toUpperCase ( ) ) {
270- case 'SEVERE' : return 'error'
271- case 'WARNING' : return 'warn'
272- case 'INFO' : return 'info'
273- case 'DEBUG' : return 'debug'
274- default : return 'log'
279+ case 'SEVERE' :
280+ return 'error'
281+ case 'WARNING' :
282+ return 'warn'
283+ case 'INFO' :
284+ return 'info'
285+ case 'DEBUG' :
286+ return 'debug'
287+ default :
288+ return 'log'
275289 }
276290}
277291
@@ -281,16 +295,38 @@ export function chromeLogLevelToLogLevel(
281295export function getRequestType ( url : string , mimeType ?: string ) : string {
282296 const ct = mimeType ?. toLowerCase ( ) ?? ''
283297 const u = url . toLowerCase ( )
284- if ( ct . includes ( 'text/html' ) ) return 'document'
285- if ( ct . includes ( 'text/css' ) ) return 'stylesheet'
286- if ( ct . includes ( 'javascript' ) || ct . includes ( 'ecmascript' ) ) return 'script'
287- if ( ct . includes ( 'image/' ) ) return 'image'
288- if ( ct . includes ( 'font/' ) || ct . includes ( 'woff' ) ) return 'font'
289- if ( ct . includes ( 'application/json' ) ) return 'fetch'
290- if ( u . endsWith ( '.html' ) || u . endsWith ( '.htm' ) ) return 'document'
291- if ( u . endsWith ( '.css' ) ) return 'stylesheet'
292- if ( u . endsWith ( '.js' ) || u . endsWith ( '.mjs' ) ) return 'script'
293- if ( u . match ( / \. ( p n g | j p g | j p e g | g i f | s v g | w e b p | i c o ) $ / ) ) return 'image'
294- if ( u . match ( / \. ( w o f f | w o f f 2 | t t f | e o t | o t f ) $ / ) ) return 'font'
298+ if ( ct . includes ( 'text/html' ) ) {
299+ return 'document'
300+ }
301+ if ( ct . includes ( 'text/css' ) ) {
302+ return 'stylesheet'
303+ }
304+ if ( ct . includes ( 'javascript' ) || ct . includes ( 'ecmascript' ) ) {
305+ return 'script'
306+ }
307+ if ( ct . includes ( 'image/' ) ) {
308+ return 'image'
309+ }
310+ if ( ct . includes ( 'font/' ) || ct . includes ( 'woff' ) ) {
311+ return 'font'
312+ }
313+ if ( ct . includes ( 'application/json' ) ) {
314+ return 'fetch'
315+ }
316+ if ( u . endsWith ( '.html' ) || u . endsWith ( '.htm' ) ) {
317+ return 'document'
318+ }
319+ if ( u . endsWith ( '.css' ) ) {
320+ return 'stylesheet'
321+ }
322+ if ( u . endsWith ( '.js' ) || u . endsWith ( '.mjs' ) ) {
323+ return 'script'
324+ }
325+ if ( u . match ( / \. ( p n g | j p g | j p e g | g i f | s v g | w e b p | i c o ) $ / ) ) {
326+ return 'image'
327+ }
328+ if ( u . match ( / \. ( w o f f | w o f f 2 | t t f | e o t | o t f ) $ / ) ) {
329+ return 'font'
330+ }
295331 return 'xhr'
296332}
0 commit comments