ember-qunit icon indicating copy to clipboard operation
ember-qunit copied to clipboard

test-support styles causes component tests to fail

Open nightire opened this issue 6 years ago • 1 comments

I have a component needs to get the parent element's height and width during its didInsertElement phase, so I set up a test case renders a template snippet:

await render(hbs`
  <div {{style width="400px" height="300px"}}>
    <MyComponent />
  </div>
`);

then I got a weird result like below:

image

As we saw in this screenshot, the wrapper element renders only half of width and height compares to its styles, it causes the test to fail even its implementation is actually correct.

I found the root cause is the default styles in:

https://github.com/emberjs/ember-qunit/blob/633f7c2a44cc5559697ab767d59a91253e0fbe2c/vendor/ember-qunit/test-container-styles.css#L23-L25

but I'm not confident to remove it at all. I use this temporary solution currently:

await render(hbs`
  // reset styles only for this test case:
  <style>
    #ember-testing { width: initial; height: initial; transform: initial; }
  </style>

  <div {{style width="400px" height="300px"}}>
    <MyComponent />
  </div>
`);

nightire avatar Jul 16 '19 15:07 nightire

Related to https://github.com/emberjs/ember-qunit/issues/595#issue-525024482.

rohitpaulk avatar Oct 23 '20 12:10 rohitpaulk