-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fixed .not.toBeInTheConsole matcher usage
- Loading branch information
1 parent
02120e2
commit b34b0b0
Showing
3 changed files
with
42 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,31 @@ | ||
/* eslint-disable @babel/no-invalid-this */ | ||
import {checkCliInstance} from "./utils"; | ||
import {getDefaultNormalizer} from "../matches"; | ||
import {checkCliInstance, getMessage} from "./utils"; | ||
|
||
export function toBeInTheConsole(instance) { | ||
if (instance !== null || !this.isNot) { | ||
checkCliInstance(instance, toBeInTheConsole, this) | ||
} | ||
|
||
// Assuming it passed above, it must have passed | ||
const errormessage = instance ? getDefaultNormalizer()(instance.stderrArr.join('\n')) : null | ||
|
||
return { | ||
pass: true, | ||
message: () => [] | ||
// 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), | ||
) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters