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
bug: "CustomElements not defined" while executing the unit tests. #24149
Comments
Thanks for the issue! This issue has been labeled as Please reproduce this issue in an Ionic starter application and provide a way for us to access it (GitHub repo, StackBlitz, etc). Without a reliable code reproduction, it is unlikely we will be able to resolve the issue, leading to it being closed. If you have already provided a code snippet and are seeing this message, it is likely that the code snippet was not enough for our team to reproduce the issue. For a guide on how to create a good reproduction, see our Contributing Guide. |
Submitted the pull request for the fix. Please take a look, these are the small changes but unblock us big time. Let us know if we still need to provide the code reproduction url. |
Hi there, Yes, we still need a code reproduction so we can verify the fix. Can you please send over a GitHub repo? |
Hey I appreciate your prompt response. https://github.com/anantsharma1310/ionic-react-unit-test Do let us know if you guys need something else. Thank you |
Can you double check your repo? I get the following error when running
|
Hey
I appreciate your prompt response.
I have made some changes on the repo please take the latest pull and follow the same steps again.
https://github.com/anantsharma1310/ionic-react-unit-test
Do let us know if you guys need something else.
Thankyou
________________________________
From: Liam DeBeasi ***@***.***>
Sent: Tuesday, November 16, 2021 4:17 AM
To: ionic-team/ionic-framework ***@***.***>
Cc: Rishabh Kumar Srivastava ***@***.***>; Manual ***@***.***>
Subject: Re: [ionic-team/ionic-framework] bug: "CustomElements not defined" while executing the unit tests. (Issue #24149)
Can you double check your repo? I get the following error when running npm test:
SyntaxError: /Users/liamdebeasi/Ionic/ionic-react-unit-test/src/App.test.js: Support for the experimental syntax 'jsx' isn't currently enabled (16:29):
14 | describe("Testing <App/> Component", () => {
15 | it("App renders a message", () => {
16 | const wrapper = mount(<App />);
| ^
17 | expect(wrapper.find('p[data-testid="message"]')).to.be.exist;
18 | });
19 | });
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub<#24149 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AS3K7SMO5VWT6R6TQX2TCFLUMGEYXANCNFSM5HGJCAWQ>.
Triage notifications on the go with GitHub Mobile for iOS<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Thanks! I can reproduce this behavior. This indeed looks like a bug. |
Thanks for the issue. This has been resolved via #24156, and a fix will be available in an upcoming release of Ionic Framework. Thank you for the PR! |
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out. |
Prerequisites
Ionic Framework Version
Current Behavior
We were executing our unit tests using Mocha test runner but after importing
@ionic/react
(version: 5.8.4) in our components, mocha started to throw error before getting to any test case. Everything else is working fine on web and IOS/Android devices, but we are not able to get a workaround for our unit tests. We have debugged ourselves and we like to share our findings.customElements
is a method available in a window object. Since we are using ajsdom
, we do getwindow.customElements
in our test cases. However, in ionic code, we found that there was a piece of code which is accessingcustomElements
method usingwindow
inif
condition and insideif
block, it is usingthis
reference to access customElements method which will definitely throw an error sincethis
is not equal towindow
in the test runner env.Attaching the buggy code, we can also post a PR for the fix if it's too much work but if possible, please expedite it.
Thank you
Expected Behavior
Should execute in test env as well.
Steps to Reproduce
You can use any test runner to run any dummy test case, it should throw an error right if you are testing component has imported
@ionic/react
.Code Reproduction URL
No response
Ionic Info
@ionic/react": 5.8.4
jsdom: 16.6.0
mocha: 8.4.0
Additional Information
No response
The text was updated successfully, but these errors were encountered: