mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-29 12:31:52 -04: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$) ```
90 lines
1.9 KiB
TypeScript
90 lines
1.9 KiB
TypeScript
import { peerDependencyIssuesLogger } from '@pnpm/core-loggers'
|
|
import { toOutput$ } from '@pnpm/default-reporter'
|
|
import {
|
|
createStreamParser,
|
|
logger,
|
|
} from '@pnpm/logger'
|
|
import { firstValueFrom } from 'rxjs'
|
|
|
|
test('print peer dependency issues warning', async () => {
|
|
const output$ = toOutput$({
|
|
context: {
|
|
argv: ['install'],
|
|
},
|
|
streamParser: createStreamParser(),
|
|
})
|
|
|
|
peerDependencyIssuesLogger.debug({
|
|
issuesByProjects: {
|
|
'.': {
|
|
missing: {},
|
|
bad: {
|
|
a: [
|
|
{
|
|
parents: [
|
|
{
|
|
name: 'b',
|
|
version: '1.0.0',
|
|
},
|
|
],
|
|
foundVersion: '2',
|
|
resolvedFrom: [],
|
|
optional: false,
|
|
wantedRange: '3',
|
|
},
|
|
],
|
|
},
|
|
conflicts: [],
|
|
intersections: {},
|
|
},
|
|
},
|
|
})
|
|
|
|
expect.assertions(1)
|
|
|
|
const output = await firstValueFrom(output$)
|
|
expect(output).toContain('.')
|
|
})
|
|
|
|
test('print peer dependency issues error', async () => {
|
|
const output$ = toOutput$({
|
|
context: { argv: ['install'] },
|
|
streamParser: createStreamParser(),
|
|
})
|
|
|
|
const err = Object.assign(new Error('some error'), {
|
|
code: 'ERR_PNPM_PEER_DEP_ISSUES',
|
|
issuesByProjects: {
|
|
'.': {
|
|
missing: {},
|
|
bad: {
|
|
a: [
|
|
{
|
|
foundVersion: '2',
|
|
parents: [
|
|
{
|
|
name: 'b',
|
|
version: '1.0.0',
|
|
},
|
|
],
|
|
optional: false,
|
|
resolvedFrom: [],
|
|
wantedRange: '3',
|
|
},
|
|
],
|
|
},
|
|
conflicts: [],
|
|
intersections: {},
|
|
},
|
|
},
|
|
})
|
|
logger.error(err, err)
|
|
|
|
expect.assertions(1)
|
|
|
|
expect.assertions(1)
|
|
|
|
const output = await firstValueFrom(output$)
|
|
expect(output).toContain('.')
|
|
})
|