| 1093 | console.timeEnd(`Time (${mode} mode): ${benchName}`); |
| 1094 | }, |
| 1095 | async beforeAll() { |
| 1096 | /** @type {Task} */ |
| 1097 | (this).collectBy = `${test}, scenario '${stringifiedScenario}'`; |
| 1098 | |
| 1099 | /** @type {((value?: void) => void)} */ |
| 1100 | let resolve; |
| 1101 | /** @type {((err: Error | null) => void)} */ |
| 1102 | let reject; |
| 1103 | |
| 1104 | const promise = new Promise((res, rej) => { |
| 1105 | resolve = res; |
| 1106 | reject = rej; |
| 1107 | }); |
| 1108 | |
| 1109 | next = (err, stats) => { |
| 1110 | if (err || !stats) { |
| 1111 | reject(err); |
| 1112 | return; |
| 1113 | } |
| 1114 | |
| 1115 | if (stats.hasWarnings() || stats.hasErrors()) { |
| 1116 | reject(new Error(stats.toString())); |
| 1117 | return; |
| 1118 | } |
| 1119 | |
| 1120 | // Construct and print stats to be more accurate with real life projects |
| 1121 | stats.toString(); |
| 1122 | resolve(); |
| 1123 | }; |
| 1124 | |
| 1125 | if (GENERATE_PROFILE) { |
| 1126 | await withProfiling( |
| 1127 | benchName, |
| 1128 | async () => |
| 1129 | (watching = await runWatch(webpack, config, watchCallback)) |
| 1130 | ); |
| 1131 | } else { |
| 1132 | watching = await runWatch(webpack, config, watchCallback); |
| 1133 | } |
| 1134 | |
| 1135 | // Make an extra fs call to warm up filesystem caches |
| 1136 | // Also wait a first run callback |
| 1137 | await new Promise( |
| 1138 | /** |
| 1139 | * @param {(value?: void) => void} resolve resolve |
| 1140 | * @param {(err: Error) => void} reject reject |
| 1141 | */ |
| 1142 | (resolve, reject) => { |
| 1143 | writeFile( |
| 1144 | entry, |
| 1145 | `${originalEntryContent};console.log('watch test')`, |
| 1146 | (err) => { |
| 1147 | if (err) { |
| 1148 | reject(err); |
| 1149 | return; |
| 1150 | } |
| 1151 | |
| 1152 | resolve(); |