( run: (name: string) => Promise<void> | void, steps: string[], type: 'setup' | 'test' | 'initializer', )
| 271 | }); |
| 272 | |
| 273 | async function runSteps( |
| 274 | run: (name: string) => Promise<void> | void, |
| 275 | steps: string[], |
| 276 | type: 'setup' | 'test' | 'initializer', |
| 277 | ) { |
| 278 | const capsType = type[0].toUpperCase() + type.slice(1); |
| 279 | |
| 280 | for (const [stepIndex, relativeName] of steps.entries()) { |
| 281 | // Make sure this is a windows compatible path. |
| 282 | let absoluteName = path.join(e2eRoot, relativeName).replace(SRC_FILE_EXT_RE, ''); |
| 283 | if (/^win/.test(process.platform)) { |
| 284 | absoluteName = absoluteName.replace(/\\/g, path.posix.sep); |
| 285 | } |
| 286 | |
| 287 | const name = relativeName.replace(SRC_FILE_EXT_RE, ''); |
| 288 | const start = Date.now(); |
| 289 | |
| 290 | printHeader(name, stepIndex, steps.length, type); |
| 291 | |
| 292 | // Run the test function with the current file. |
| 293 | try { |
| 294 | await run(absoluteName); |
| 295 | } catch (e) { |
| 296 | console.log('\n'); |
| 297 | console.error(styleText(['red'], `${capsType} "${name}" failed...`)); |
| 298 | |
| 299 | throw e; |
| 300 | } |
| 301 | |
| 302 | console.log('----'); |
| 303 | printFooter(name, type, start); |
| 304 | } |
| 305 | } |
| 306 | |
| 307 | function runSetup(absoluteName: string): Promise<void> { |
| 308 | const module = require(absoluteName); |
no test coverage detected