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

Fallback symbols are not covered by tests in Unicode-capable environments, including CI #94

Closed
gibson042 opened this issue Aug 7, 2022 · 4 comments

Comments

@gibson042
Copy link
Contributor

Observed at #93 (comment) , the test for replaceSymbols verifies the absence of replacements (in a Unicode-capable environment) OR replacement with fallback symbols (in other environments), but not both. It would be good to update the tests for more complete coverage, or failing that to at least update CI to include less capable environments.

@ehmicky
Copy link
Collaborator

ehmicky commented Aug 7, 2022

Nice find @gibson042!
Would you be interested in submitting a PR?

@gibson042
Copy link
Contributor Author

Yes, but I may need help with this one. Is there a standard approach in these packages to mocking dependencies such that isUnicodeSupported() can be forced to return false inside a test? And if not, then what would be your alternative recommendation?

@ehmicky
Copy link
Collaborator

ehmicky commented Aug 8, 2022

Good point.

Not sure how @sindresorhus feels about this, but I personally try to avoid mocking whenever possible because:

  • It can end up creating complex test setups
  • It makes the tests less similar than the environment the users actually experience, which makes the tests less useful, and can miss some bugs

In this situation, I think what'd be best would be to run the tests in CI in an environment where isUnicodeSupported() returns false. In principle, Windows machines on GitHub actions use ConsoleHost (through cmd.exe) which uses its own charset and has issues displaying many Unicode characters. Unfortunately , isUnicodeSupported() returns true when the CI environment variable is set. What was the reason behind this @sindresorhus?

If changing is-unicode-supported is not an option, I am wondering whether setting CI to an empty string in the GitHub actions workflow file for the Windows environment would work? 🤔

@sindresorhus
Copy link
Owner

Unfortunately , isUnicodeSupported() returns true when the CI environment variable is set. What was the reason behind this @sindresorhus?

I don't remember. It's definitely not the correct behavior.

https://github.com/sindresorhus/is-unicode-supported/releases/tag/v2.0.0

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

No branches or pull requests

3 participants