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
Engine unit test is too verbose #94
Comments
Yeah, we need to spend time fixing all tests to either a) slice tests more so is easy to manage different tagNames in the same test, or b) use different tagName for each tests in every test file. Part of that work is also to do the following for each tagName: interface HTMLElementTagNameMap {
'x-foo1': MyComponent1
} which indicates to the type system that creation of such tags will be bound to that class definition, and this will remove many type errors in tests. |
What about disabling the check in test mode ? |
@pmdartus do we have such mode? |
Jest sets by default We can rewrite export function registerComponent(tagName: string, Ctor: ComponentConstructor) {
if (!isUndefined(TagNameToCtor[tagName])) {
if (TagNameToCtor[tagName] === Ctor) {
return;
} else if (process.env.NODE_ENV !== 'production' && process.env.NODE_ENV !== 'test') {
// TODO: eventually we should throw, this is only needed for the tests today
assert.logWarning(`Different component class cannot be registered to the same tagName="${tagName}".`);
}
}
TagNameToCtor[tagName] = Ctor;
} |
@pmdartus I thought that we talked about having multiple modes and it was a no-go because it would get complicated really quickly. I prefer the other approach of not recycling tag names because that matches more closely how LWC will be used, especially when |
Then going down this route we need to be more restrictive and throw if 2 tests are using the same name. A warning is not enough the prevent new test to reuse existing names. My main concern is that we will see an explosion of components with convoluted names, and I don't think it will be maintainable in the long run. That being said we still have a couple of options to avoid adding another mode:
After listing the different options we have, I still believe that using |
@pmdartus Could we run the tests in production mode as opposed to dev mode? |
Today the tests run in I think it's useful to run the tests in Edit: React runs 4 suites of tests:
|
Here is branch with all the verbose unit test skipped: https://github.com/salesforce/lwc/compare/pmdartus/localize-all-warnings That would be useful for the willing to tackle this issue. |
## Details This PR changes the way jest is configured in the mono-repo, to leverage the `projects` feature properly. This would allow us to have a different jest config for each project. Changes: * Remove component registry in the engine * Fix tests that are using `root` instead of `template` * Fix tests with duplicate component names > The test running will also print the package name next to the test 💃 <img width="710" alt="screen shot 2018-05-21 at 8 41 41 am" src="https://user-images.githubusercontent.com/2567083/40316332-db609542-5cd2-11e8-9144-9085667896d4.png"> ---- In upcoming a PR I want to get rid of all the remaining warnings by introducing a custom matcher that will trap the warnings and the errors (#94, #104). All the unexpected console `log`, `warn` and `error` should make the test fail. Doing this would greatly improve quality and the consistency of the warnings the engine surfaces. ## Does this PR introduce a breaking change? * [ ] Yes * [X] No
Description
Since the merge of the snabdom refactor (#47), the engine test became extremely verbose. It produces more than 10k lines of lines of stack traces. All those logs is a real block for running the engine tests in watch mode
One of the big offenders is that the engine checks if the same tag name is used by multiple components: registerComponent
The text was updated successfully, but these errors were encountered: