-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
to-be-in-the-console.js
33 lines (30 loc) 路 925 Bytes
/
to-be-in-the-console.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* eslint-disable no-invalid-this */
import {getDefaultNormalizer} from '../matches'
import {checkCliInstance, getMessage} from './utils'
export function toBeInTheConsole(instance) {
if (instance !== null || !this.isNot) {
checkCliInstance(instance, toBeInTheConsole, this)
}
const errormessage = instance
? getDefaultNormalizer()(instance.stdoutArr.join('\n'))
: null
return {
// Does not change based on `.not`, and as a result, we must confirm if it _actually_ is there
pass: !!instance,
message: () => {
const to = this.isNot ? 'not to' : 'to'
return getMessage(
this,
this.utils.matcherHint(
`${this.isNot ? '.not' : ''}.toBeInTheConsole`,
'instance',
'',
),
`Expected ${to} find the instance in the console`,
'',
'Received',
this.utils.printReceived(errormessage),
)
},
}
}