Skip to content

Proposal: Should we include a matcher? #200

Open
@orta

Description

@orta

I had a fail based on two long strings which I fixed this way:

screen shot 2017-03-24 at 10 13 05

After putting a console.log in the dangerfile. This ain't good.


Code looked like this:

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 <code>yarn declarations</code> and update this PR."
  fail(`${message}<br/><i>${idea}</i>`)
}

We already have jest-diff inside the app, due to jest-config, so what about instead we provide something like:

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 <code>yarn declarations</code> and update this PR."
const failureMessage =`${message}<br/><i>${idea}</i>`

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

or

screen shot 2017-03-24 at 10 18 26

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions