danger / danger/danger-js

Proposal: Should we include a matcher?

Open
#200 1 comment 0 reactions 0 assignees View on GitHub
enhancement Open for Discussion
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:

![screen shot 2017-03-24 at 10 13 05](https://cloud.githubusercontent.com/assets/49038/24289751/82805d18-107a-11e7-8222-9fafcc19d197.png)

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:

![screen shot 2017-03-24 at 10 16 57](https://cloud.githubusercontent.com/assets/49038/24289944/1a26f1b8-107b-11e7-84e6-27fc73fa3455.png)

or

![screen shot 2017-03-24 at 10 18 26](https://cloud.githubusercontent.com/assets/49038/24289987/42d446ec-107b-11e7-82bf-a7459e923f08.png)

Contributor guide

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.