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

Not possible to have both value and message be optional for hasAttribute assertion #255

Open
houli opened this issue Jan 30, 2019 · 2 comments

Comments

@houli
Copy link

houli commented Jan 30, 2019

The type signature of hasAttribute lists both value and message as optional however this isn't possible to pull off in TypesScript as passing a message string as the second argument means that the message string is interpreted as the value string.
https://github.com/simplabs/qunit-dom/blob/08cedfad10c8ab7fbb3c800b59d91d18f64a11ae/lib/assertions.ts#L300

It is not currently clear how to write an assertion to only check the attribute's existence and not it's value but also include a message.

From reading the code the object referred to in the documentation is the object { any: true } which seems to accomplish what I want but it feels like an internal implementation detail of the library.

I've ended up writing my tests like this

assert.dom('.bar').hasAttribute('data-test-foo', { any: true }, 'My assertion message');
@Turbo87
Copy link
Collaborator

Turbo87 commented Jan 30, 2019

@houli that is the correct solution for now, yes. For hasText() we had a similar issue and decided to introduce a hasAnyText() assertion which essentially just calls hasText() with { any: true }. I guess we missed that for hasAttribute(), but I'm open to PRs that add it :)

Turbo87 pushed a commit to Turbo87/qunit-dom that referenced this issue Apr 27, 2019
Bumps [ember-cli-eslint](https://github.com/ember-cli/ember-cli-eslint) from 4.2.3 to 5.0.0.
<details>
<summary>Release notes</summary>

*Sourced from [ember-cli-eslint's releases](https://github.com/ember-cli/ember-cli-eslint/releases).*

> ## v5.0.0
> #### 💥 Breaking Change
> * [mainmatter#284](https://github-redirect.dependabot.com/ember-cli/ember-cli-eslint/pull/284) Upgrade `broccoli-lint-eslint` to v5.0.0 ([[**Gaurav0**](https://github.com/Gaurav0)](https://github.com/Gaurav0))
> * [mainmatter#256](https://github-redirect.dependabot.com/ember-cli/ember-cli-eslint/pull/256) Drop support for IE9 and IE10 ([[**Gaurav0**](https://github.com/Gaurav0)](https://github.com/Gaurav0))
> * [mainmatter#254](https://github-redirect.dependabot.com/ember-cli/ember-cli-eslint/pull/254) Drop support for Node.js 4 ([[**Gaurav0**](https://github.com/Gaurav0)](https://github.com/Gaurav0))
> 
> #### 🏠 Internal
> * [mainmatter#251](https://github-redirect.dependabot.com/ember-cli/ember-cli-eslint/pull/251) Upgrade to ember cli 3.4 via ember-cli-update ([[**Gaurav0**](https://github.com/Gaurav0)](https://github.com/Gaurav0))
> * [mainmatter#255](https://github-redirect.dependabot.com/ember-cli/ember-cli-eslint/pull/255) Use Chrome instead of PhantomJS to run tests ([[**Gaurav0**](https://github.com/Gaurav0)](https://github.com/Gaurav0))
> * [mainmatter#263](https://github-redirect.dependabot.com/ember-cli/ember-cli-eslint/pull/263) Remove obsolete `es6-promise` dev dependency ([[**Turbo87**](https://github.com/Turbo87)](https://github.com/Turbo87))
> * [mainmatter#262](https://github-redirect.dependabot.com/ember-cli/ember-cli-eslint/pull/262) yarn: Add `integrity` hashes ([[**Turbo87**](https://github.com/Turbo87)](https://github.com/Turbo87))
> 
> #### Committers: 2
> - Gaurav Munjal ([[**Gaurav0**](https://github.com/Gaurav0)](https://github.com/Gaurav0))
> - Tobias Bieniek ([[**Turbo87**](https://github.com/Turbo87)](https://github.com/Turbo87))
</details>
<details>
<summary>Changelog</summary>

*Sourced from [ember-cli-eslint's changelog](https://github.com/ember-cli/ember-cli-eslint/blob/master/CHANGELOG.md).*

> ## v5.0.0 (2018-11-09)
> 
> #### 💥 Breaking Change
> * [mainmatter#284](https://github-redirect.dependabot.com/ember-cli/ember-cli-eslint/pull/284) Upgrade `broccoli-lint-eslint` to v5.0.0 ([[**Gaurav0**](https://github.com/Gaurav0)](https://github.com/Gaurav0))
> * [mainmatter#256](https://github-redirect.dependabot.com/ember-cli/ember-cli-eslint/pull/256) Drop support for IE9 and IE10 ([[**Gaurav0**](https://github.com/Gaurav0)](https://github.com/Gaurav0))
> * [mainmatter#254](https://github-redirect.dependabot.com/ember-cli/ember-cli-eslint/pull/254) Drop support for Node.js 4 ([[**Gaurav0**](https://github.com/Gaurav0)](https://github.com/Gaurav0))
> 
> #### 🏠 Internal
> * [mainmatter#251](https://github-redirect.dependabot.com/ember-cli/ember-cli-eslint/pull/251) Upgrade to ember cli 3.4 via ember-cli-update ([[**Gaurav0**](https://github.com/Gaurav0)](https://github.com/Gaurav0))
> * [mainmatter#255](https://github-redirect.dependabot.com/ember-cli/ember-cli-eslint/pull/255) Use Chrome instead of PhantomJS to run tests ([[**Gaurav0**](https://github.com/Gaurav0)](https://github.com/Gaurav0))
> * [mainmatter#263](https://github-redirect.dependabot.com/ember-cli/ember-cli-eslint/pull/263) Remove obsolete `es6-promise` dev dependency ([[**Turbo87**](https://github.com/Turbo87)](https://github.com/Turbo87))
> * [mainmatter#262](https://github-redirect.dependabot.com/ember-cli/ember-cli-eslint/pull/262) yarn: Add `integrity` hashes ([[**Turbo87**](https://github.com/Turbo87)](https://github.com/Turbo87))
> 
> #### Committers: 2
> - Gaurav Munjal ([[**Gaurav0**](https://github.com/Gaurav0)](https://github.com/Gaurav0))
> - Tobias Bieniek ([[**Turbo87**](https://github.com/Turbo87)](https://github.com/Turbo87))
</details>
<details>
<summary>Commits</summary>

- [`3b7f296`](ember-cli/ember-cli-eslint@3b7f296) v5.0.0
- [`0beb115`](ember-cli/ember-cli-eslint@0beb115) Update Changelog
- [`5c23ac0`](ember-cli/ember-cli-eslint@5c23ac0) Add `lerna-changelog` dev dependency
- [`5657eec`](ember-cli/ember-cli-eslint@5657eec) Merge pull request [mainmatter#284](https://github-redirect.dependabot.com/ember-cli/ember-cli-eslint/issues/284) from Gaurav0/eslint_5
- [`0d484e6`](ember-cli/ember-cli-eslint@0d484e6) Upgrade to broccoli-lint-eslint 5
- [`4f88dbc`](ember-cli/ember-cli-eslint@4f88dbc) Bump qunit-dom from 0.7.1 to 0.8.0 ([mainmatter#287](https://github-redirect.dependabot.com/ember-cli/ember-cli-eslint/issues/287))
- [`6da2ee2`](ember-cli/ember-cli-eslint@6da2ee2) Merge pull request [mainmatter#286](https://github-redirect.dependabot.com/ember-cli/ember-cli-eslint/issues/286) from ember-cli/dependabot/npm_and_yarn/lodash-4.17.11
- [`50645c3`](ember-cli/ember-cli-eslint@50645c3) [Security] Bump lodash from 4.17.4 to 4.17.11
- [`d48f347`](ember-cli/ember-cli-eslint@d48f347) Merge pull request [mainmatter#285](https://github-redirect.dependabot.com/ember-cli/ember-cli-eslint/issues/285) from ember-cli/dependabot/npm_and_yarn/debug-2.6.9
- [`89101ac`](ember-cli/ember-cli-eslint@89101ac) [Security] Bump debug from 2.6.3 to 2.6.9
- Additional commits viewable in [compare view](ember-cli/ember-cli-eslint@v4.2.3...v5.0.0)
</details>
<br />

[![Dependabot compatibility score](https://api.dependabot.com/badges/compatibility_score?dependency-name=ember-cli-eslint&package-manager=npm_and_yarn&previous-version=4.2.3&new-version=5.0.0)](https://dependabot.com/compatibility-score.html?dependency-name=ember-cli-eslint&package-manager=npm_and_yarn&previous-version=4.2.3&new-version=5.0.0)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot ignore this [patch|minor|major] version` will close this PR and stop Dependabot creating any more for this minor/major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language
- `@dependabot badge me` will comment on this PR with code to add a "Dependabot enabled" badge to your readme

Additionally, you can set the following in your Dependabot [dashboard](https://app.dependabot.com):
- Update frequency (including time of day and day of week)
- Automerge options (never/patch/minor, and dev/runtime dependencies)
- Pull request limits (per update run and/or open at any time)
- Out-of-range updates (receive only lockfile updates, if desired)
- Security updates (receive only security updates, if desired)

Finally, you can contact us by mentioning @dependabot.

</details>
@ghost
Copy link

ghost commented Oct 9, 2020

@Turbo87 how about adding an assertion called hasAttributeAnyValue() that basically calls hasAttribute with { any: true }?

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

No branches or pull requests

2 participants