mirror of
https://github.com/pnpm/pnpm.git
synced 2026-01-18 11:58:45 -05:00
* test: move expect blocks (without other changes) to end of test This is required for the refactor in the next commit. The log statements have to run before consuming the output stream, otherwise the output stream will be empty. * test: fix swallowed Jest expect errors in `default-reporter` package * test: fix expected to match actual values in default-reporter tests * refactor: remove redundant `.pipe(take(1))` With the refactor to use `firstValueFrom`, the `take(1)` is now redundant in many places. ```ts firstValueFrom(output$.pipe(take(1))) ``` ```ts firstValueFrom(output$) ```
31 lines
812 B
TypeScript
31 lines
812 B
TypeScript
import { requestRetryLogger } from '@pnpm/core-loggers'
|
|
import { toOutput$ } from '@pnpm/default-reporter'
|
|
import {
|
|
createStreamParser,
|
|
} from '@pnpm/logger'
|
|
import { firstValueFrom } from 'rxjs'
|
|
import { formatWarn } from '../src/reporterForClient/utils/formatWarn'
|
|
|
|
test('print warning about request retry', async () => {
|
|
const output$ = toOutput$({
|
|
context: {
|
|
argv: ['install'],
|
|
},
|
|
streamParser: createStreamParser(),
|
|
})
|
|
|
|
requestRetryLogger.debug({
|
|
attempt: 2,
|
|
error: new Error(),
|
|
maxRetries: 5,
|
|
method: 'GET',
|
|
timeout: 12500,
|
|
url: 'https://foo.bar/qar',
|
|
})
|
|
|
|
expect.assertions(1)
|
|
|
|
const output = await firstValueFrom(output$)
|
|
expect(output).toBe(formatWarn('GET https://foo.bar/qar error (undefined). Will retry in 12.5 seconds. 4 retries left.'))
|
|
})
|