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

hasText() doesn't work on string like things #1240

Open
mehulkar opened this issue Sep 16, 2021 · 0 comments
Open

hasText() doesn't work on string like things #1240

mehulkar opened this issue Sep 16, 2021 · 0 comments

Comments

@mehulkar
Copy link

mehulkar commented Sep 16, 2021

we often write assertions in ember-land like this:

const i18n = this.owner.lookup('service:i18n')
assert.dom('[data-test-foo']
  .hasText(i18n.t('Some.Key'))

This test fails because i18n.t('Some.Key') is not a string and a TypeError is thrown: https://github.com/simplabs/qunit-dom/blob/e2b3b4f4f82da36733ce659815e092e73ee1c598/lib/assertions.ts#L919-L921

We work around this by changing the assertion to

assert.dom('[data-test-foo']
-  .hasText(i18n.t('Some.Key'))
+  .hasText(String(i18n.t('Some.Key')))

I'm not sure what the right answer, but wanted to report anyway. In our case, we're using ember-i18n, so the return type happens to be a SafeString from Ember's htmlSafe() util.

https://github.com/jamesarosen/ember-i18n/blob/6e4a999d4693e2b85fb99e8c6e34aca4b1670df2/addon/utils/i18n/compile-template.js#L24

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

1 participant