Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

TSLint test doesn't support multiline failure messages #271

Open
gabritto opened this issue Feb 15, 2020 · 0 comments
Open

TSLint test doesn't support multiline failure messages #271

gabritto opened this issue Feb 15, 2020 · 0 comments

Comments

@gabritto
Copy link
Member

gabritto commented Feb 15, 2020

TSLint rule tests don't support testing rules that have failure messages that span over multiple lines.
This happens because when TSLint parses a .lint file for the expected failure messages, it always parses lines separately.
For example:

declare var foo;
~~~~~           [This is a multiline
error message]

TSLint will parse the failure message as "This is a multiline" instead of "This is a multiline error message".

ESLint
As far as I could tell, ESLint takes a different approach to rule unit tests, so this issue will be deprecated once #214 is solved.

Workaround
As a workaround, I had my rule take a "single-line" boolean argument. If this is set, the messages the rules generates get joined into a single line. The "single-line" argument is then set in the test TSLint configurations. When running the rule in "production", this boolean is not set, so the messages can preserve their line breaks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant