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

MockHTMLElement is missing animate method #2802

Closed
JonasMa opened this issue Jan 15, 2021 · 1 comment
Closed

MockHTMLElement is missing animate method #2802

JonasMa opened this issue Jan 15, 2021 · 1 comment
Labels
ionitron: stale issue This issue has not seen any activity for a long period of time

Comments

@JonasMa
Copy link

JonasMa commented Jan 15, 2021

Stencil version:

 @stencil/core@2.3.0

I'm submitting a:
[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://stencil-worldwide.herokuapp.com/ or https://forum.ionicframework.com/

Current behavior:
I am writing jest tests for my web-components. I,m animating HTMLElelements with the animate method. It works fine when I create the component in the browser in normal way, But it breaks if I create the component in my unit tests using newSpecPage interface. The reason for breaking is that jest in stencil replace normal DOM with MockDOM and the mockHTMLElement on which I am using animate is missing the method animate

Expected behavior:
MockHtmlElement should have all the methods of an HTMLElement

Steps to reproduce:
1- Create a simple component, use animate on any Element
2- Run unit tests over the component

Related code:

my-component.spec.ts

 it('should work',()=>{
   const myComponent = await newSpecPage({
        components: [MyComponent],
        html: `<my-component></my-component>`
   }); // throws ERROR
   expect(myComponent.root.querySelector('#test')).notToBeNull(); // fails
 });

my-component.tsx

@Component({
    tag: 'my-component'
})
export class MyComponent {
@Element() rootElem:HTMLElement;

    componentDidLoad() {
      // throws TypeError: this.rootElem.animate is not a function
      // this.rootElem is of type MockHTML element when run from test else HTMLELement
      this.rootElem.animate([{ transform: 'rotate(90deg)' }]);
    }


    render() {
        return (
            <div id="container">
            </div>
        );
    }
}
@ionitron-bot ionitron-bot bot added the triage label Jan 15, 2021
@claviska claviska added bug and removed triage labels Jan 15, 2021
@ionitron-bot ionitron-bot bot added the ionitron: stale issue This issue has not seen any activity for a long period of time label Feb 14, 2021
@ionitron-bot
Copy link

ionitron-bot bot commented Feb 14, 2021

Thanks for the issue! This issue is being closed due to inactivity. If this is still an issue with the latest version of Stencil, please create a new issue and ensure the template is fully filled out.

Thank you for using Stencil!

@ionitron-bot ionitron-bot bot closed this as completed Feb 14, 2021
@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Feb 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
ionitron: stale issue This issue has not seen any activity for a long period of time
Projects
None yet
Development

No branches or pull requests

2 participants