Proposal: Should we include a matcher?
- Dominant language
- TypeScript
- Stars
- 5.5k
- Forks
- 381
- Avg merge
- 2h 8m
- Merged PRs (30d)
- 6
Description
I had a fail based on two long strings which I fixed this way:

After putting a `console.log` in the dangerfile. This ain't good.
---
Code looked like this:
```ts
import dtsGenerator from "./scripts/danger-dts"
const currentDTS = dtsGenerator()
const savedDTS = fs.readFileSync("source/danger.d.ts").toString()
if (currentDTS !== savedDTS) {
const message = "There are changes to the Danger DSL which are not reflected in the current danger.d.ts."
const idea = "Please run yarn declarations and update this PR."
fail(`${message}
${idea}`)
}
```
We already have `jest-diff` inside the app, due to `jest-config`, so what about instead we provide something like:
```ts
import dtsGenerator from "./scripts/danger-dts"
const currentDTS = dtsGenerator()
const savedDTS = fs.readFileSync("source/danger.d.ts").toString()
const message = "There are changes to the Danger DSL which are not reflected in the current danger.d.ts."
const idea = "Please run yarn declarations and update this PR."
const failureMessage =`${message}
${idea}`
danger.utils.checkEqual(fail, failureMessage, currentDTS, savedDTS)
```
Where we can present jest-matcher like messages inline. For example:

or

Contributor guide
Research direction
Start by locating the existing danger.utils entry point and reviewing scripts/danger-dts and source/danger.d.ts, which are used in the example. Check how the existing jest-diff dependency is available, then define and test the proposed checkEqual API and its inline diff output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100