Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate value argument in "to have property" #688

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

alexjeffburke
Copy link
Member

This commit adds a small utility function that can be used when we add deprecation notices for assertions. I've also added a nice deprecation notice for that value argument in "to have property", outputted once, that informs the user what to do:
Screenshot 2020-01-05 at 17 09 41

Arrange for this to contain the logic for showing once. Do a little
extra work to make sure the warning is coloured on the console.
lib/utils.js Outdated
.text(message, 'bgYellow', 'black')
.toString(format)
);
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can get the output format this way:

const format = expect.outputFormat()

So this should also work:

const output = expect.output.clone(expect.outputFormat())

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sunesimonsen that actually doesn't work currently - seems that the method is only allowed on the top-level expect.. should we change that?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be okay with me. Just keep in mind that this method also allow you to give it an argument to change the default format.

lib/utils.js Outdated
return;
}

deprecationWarningDisplayed = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should be cleaver about how much we show that warning.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then we can make a proper style for the warning in styles.js and make a util for printing them to the console.

Copy link
Member Author

@alexjeffburke alexjeffburke Jan 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep it simple.

Create a deprecationWarning style used for the yellow on black
colouring. Keep things simple (per review) and remove the one-time
only check which further reduces things down to a simple call. Pass
the expect instance for its .output rather than requiring magicpen.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants