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

[feature] test-fixture-mocha to accept HTML in addition to ID #55

Open
sashafirsov opened this issue Jun 3, 2018 · 1 comment
Open

Comments

@sashafirsov
Copy link

Description

As for test author the splitting tested HTML and fixture(id) ( within HTML and test JS module ) become significant inconvenience. It forced to switch between HTML and JS while the size of common identifier (id) is often comparable to size of tested HTML itself

<test-fixture id="SomeElementFixture">
  <template>
    <some-element></some-element>
  </template>
</test-fixture>
someElement = fixture('SomeElementFixture');

Proposed

To pass an HTML string which will be instantiated instead of template body on separate HTML.

someElement = fixture(`<some-element></some-element>`);

Backward compatibe

The original signature with ID as parameter still will be in place. The HTML string could be detected either by presence of '<' character as 1st character of anywhere in string.

Benefits

  • no need to jump between HTML and test module during test development and debug
  • shorter code overall
  • no need to rely on any IDs, explicit element reference is used instead
  • no risk of using wrong IDs
  • yada-yada
@sashafirsov
Copy link
Author

Extending the test code shortening idea by providing automatic fixture for describeFixture or itFixture:

describeFixture ('<some-element>', function ( ) {...
// beforeEach() will re-populate this.someElementInstance or pass it as parameter to it()

or

describe('<some-element>', function () {
itFixture('<some-element foo="baz"> can receive property `foo`  </some-element>', function ( someEl ){
expect(someElement.foo).to.be.equal('baz');

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