| 151 | } |
| 152 | |
| 153 | get(): Cache { |
| 154 | if (this._cache) { |
| 155 | return this._cache; |
| 156 | } |
| 157 | |
| 158 | if (this._done) { |
| 159 | return {clear: '', content: ''}; |
| 160 | } |
| 161 | |
| 162 | const width = process.stdout.columns; |
| 163 | let content = '\n'; |
| 164 | for (const record of this._currentTests.get()) { |
| 165 | if (record) { |
| 166 | const {config, testPath} = record; |
| 167 | |
| 168 | const projectDisplayName = config.displayName |
| 169 | ? `${printDisplayName(config)} ` |
| 170 | : ''; |
| 171 | const prefix = RUNNING + projectDisplayName; |
| 172 | |
| 173 | content += `${wrapAnsiString( |
| 174 | prefix + |
| 175 | trimAndFormatPath(stringLength(prefix), config, testPath, width), |
| 176 | width, |
| 177 | )}\n`; |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | if (this._showStatus && this._aggregatedResults) { |
| 182 | content += `\n${getSummary(this._aggregatedResults, { |
| 183 | currentTestCases: this._currentTestCases, |
| 184 | estimatedTime: this._estimatedTime, |
| 185 | roundTime: true, |
| 186 | seed: this._globalConfig.seed, |
| 187 | showSeed: this._globalConfig.showSeed, |
| 188 | width, |
| 189 | })}`; |
| 190 | } |
| 191 | |
| 192 | let height = 0; |
| 193 | |
| 194 | for (const char of content) { |
| 195 | if (char === '\n') { |
| 196 | height++; |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | const clear = '\r\u001B[K\r\u001B[1A'.repeat(height); |
| 201 | return (this._cache = {clear, content}); |
| 202 | } |
| 203 | |
| 204 | private _emit() { |
| 205 | this._cache = null; |