File tree Expand file tree Collapse file tree 3 files changed +35
-26
lines changed Expand file tree Collapse file tree 3 files changed +35
-26
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515 - The test(s) is/are marked as pending and will not be executed. Helpful for planning and organizing future tests.
1616 - ` describe.todo() ` Declares a test group as "to-do."
1717 - ` test.todo() ` Declares a test as "to-do."
18+ - Added test time execution to the ` HTML ` report:
1819- Based on [ Review&Add additional ` unit-tests ` ] ( https://github.com/scripterio-js/scripterio/issues/58 )
1920 - Added unit tests for:
2021 -` config.mjs `
Original file line number Diff line number Diff line change 99} from '../utils/transform.mjs'
1010import { printNewLine , printSkippedMsg } from './output.mjs'
1111import { getConfig } from '../config/config.mjs'
12+ import { timeStamp } from '../utils/support.mjs'
1213
1314const config = getConfig ( )
1415const failures = [ ]
@@ -163,6 +164,7 @@ const runTest = async (test) => {
163164 global . currentTest = test
164165 currentTest . describeStack = [ ...describeStack ]
165166
167+ const startTimeStamp = timeStamp ( )
166168 if ( test . todo ) {
167169 result . numTodo ++
168170 console . log (
@@ -195,6 +197,8 @@ const runTest = async (test) => {
195197 }
196198 attempts ++
197199 }
200+
201+ const endTimeStamp = timeStamp ( )
198202 if ( ! passed ) {
199203 result . numFailed ++
200204 console . log ( indent ( applyColor ( `<red>✗</red> ${ currentTest . name } ` ) ) )
@@ -206,6 +210,7 @@ const runTest = async (test) => {
206210 }
207211 result . numTests ++
208212 result . results . push ( currentTest )
213+ currentTest . duration = endTimeStamp - startTimeStamp
209214 global . currentTest = null
210215}
211216
Original file line number Diff line number Diff line change @@ -341,34 +341,37 @@ export const template = ({
341341 return content
342342 . map (
343343 ( test ) => `
344- <div class="test-case" style="padding-left: ${ padding } px">
345- <div class="test-name ${
346- test . todo ? 'todo' : test . errors . length ? 'failed' : 'passed'
347- } ">
348- ${ test . name } ${ test . todo ? ' (TODO)' : '' }
349- </div>
350- ${
351- test . errors . length
352- ? `
353- <a class="toggle-error" onclick="toggleError(this)">Show error details</a>
354- <div class="error-details">
355- ${ test . errors
356- . map (
357- ( error ) => `
358- <div class="error">
359- <pre>${ stripAnsi ( error . message ) } </pre>
360- <pre>${ stripAnsi ( error . stack ) } </pre>
361- </div>
362- `
363- )
364- . join ( '' ) }
365- </div>
366- `
367- : ''
368- }
369- ${ test . apiDetails ? renderApiDetails ( test . apiDetails ) : '' }
344+ <div class="test-case" style="padding-left: ${ padding } px">
345+ <div class="test-name ${
346+ test . todo ? 'todo' : test . errors . length ? 'failed' : 'passed'
347+ } ">
348+ ${ test . name } ${ test . todo ? ' (TODO)' : '' }
349+ <span style="color:#888; font-size:0.95em; margin-left:0.5em;">${
350+ typeof test . duration === 'number' ? `${ test . duration } ms` : ''
351+ } </span>
352+ </div>
353+ ${
354+ test . errors . length
355+ ? `
356+ <a class="toggle-error" onclick="toggleError(this)">Show error details</a>
357+ <div class="error-details">
358+ ${ test . errors
359+ . map (
360+ ( error ) => `
361+ <div class="error">
362+ <pre>${ stripAnsi ( error . message ) } </pre>
363+ <pre>${ stripAnsi ( error . stack ) } </pre>
370364 </div>
371365 `
366+ )
367+ . join ( '' ) }
368+ </div>
369+ `
370+ : ''
371+ }
372+ ${ test . apiDetails ? renderApiDetails ( test . apiDetails ) : '' }
373+ </div>
374+ `
372375 )
373376 . join ( '' )
374377 }
You can’t perform that action at this time.
0 commit comments