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

Testing component logic results in warning #2275

Closed
scifihotchoc opened this issue Mar 17, 2020 · 5 comments
Closed

Testing component logic results in warning #2275

scifihotchoc opened this issue Mar 17, 2020 · 5 comments
Labels

Comments

@scifihotchoc
Copy link

Stencil version:

 @stencil/core@1.10.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:
Running a unit test in .spec.ts for component logic gives out a warning:

console.warn node_modules/@stencil/core/internal/testing/index.js:2900 Use newSpecPage() to instanciate component instances.
Comment out the component logic test and the warning disappears. Example of component logic test:
it('builds', () => { expect(new Note()).toBeTruthy(); });

Expected behavior:
No warning should come out.

Steps to reproduce:
Already described above

Related code:
Already shown above

// insert any relevant code here

Other information:

@manucorporat
Copy link
Contributor

This is the expected behaviour, we recommend to use newSpecPage() instead of new:
https://stenciljs.com/docs/unit-testing#newspecpage-

@notbear
Copy link

notbear commented Mar 31, 2020

This is the expected behaviour, we recommend to use newSpecPage() instead of new:

@manucorporat but a few lines below you can find a chapter named 'Testing Component Class Logic' https://stenciljs.com/docs/unit-testing#testing-component-class-logic which shows an instatiation example with new. Inconsistency in the code or outdated documentation?

@apillard
Copy link

apillard commented Apr 6, 2020

See corresponding issue against stencil docs site here. Either the stencil cli or docs site needs a fix.

ionic-team/stencil-site#594

@ashika01
Copy link

ashika01 commented Sep 2, 2020

@manucorporat Why was this issue closed? The warning message is kinda misleading considering both in docs and the app created through the CLI has the usage mentioned here

@doliG
Copy link

doliG commented Feb 11, 2021

@manucorporat agree with op, could you please reopen and handle the issue ?
These warnings pollute test logs.

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

No branches or pull requests

6 participants