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

Fix warnings inside our tests #2196

Closed
danielduan opened this issue Oct 31, 2017 · 18 comments
Closed

Fix warnings inside our tests #2196

danielduan opened this issue Oct 31, 2017 · 18 comments
Labels
cleanup Minor cleanup style change that won't show up in release changelog good first issue help wanted

Comments

@danielduan
Copy link
Member

danielduan commented Oct 31, 2017

When running tests for cra-kitchen-sink, we have lots of warnings and messages thrown for react things.

Some of them are simply fixing the usage examples, some are resolving things react likes to complain about.

It'd be nice to have a clean test.

@danielduan danielduan added cleanup Minor cleanup style change that won't show up in release changelog good first issue help wanted labels Oct 31, 2017
@syneva-runyan
Copy link
Contributor

If no one's looking into this yet I can take a go at it

@danielduan
Copy link
Member Author

@syneva-runyan if you can, that would be great. thanks!

@syneva-runyan
Copy link
Contributor

@danielduan are the console.info statements good to be left in? For example, the ones that print out from app/react/src/server/babel_config.test.js

@danielduan
Copy link
Member Author

I don't see any info statements in that file. Can you link it?

@dangreenisrael
Copy link
Member

dangreenisrael commented Nov 12, 2017

@danielduan @syneva-runyan Any thoughts on making console.error and console.warn fail tests? I could put together a PR for it, and they it can be merged in after @syneva-runyan gets rid of all the warnings.

@Hypnosphi
Copy link
Member

@dangreenisrael I think it's a good idea

@dangreenisrael
Copy link
Member

@Hypnosphi Should this be onto master or release 3.3?

@danielduan
Copy link
Member Author

danielduan commented Nov 12, 2017

I think tests that don't significantly impact the code we ship to users can be put on master.

In general, bug fixes and developer oriented tooling can go on master.

@dangreenisrael
Copy link
Member

#2297

@syneva-runyan
Copy link
Contributor

@danielduan, line 86 in app/react/src/server/babel_config.js for instance prints out => Loading custom .babelrc

logger.info('=> Loading custom .babelrc');

We could mock the logger so the messages don't show up in the console when running tests.

@danielduan
Copy link
Member Author

danielduan commented Nov 14, 2017

@syneva-runyan that would be great, thanks!

I think a todo in the future would be to have a silent mode for webpack and babel so these info outputs can be turned off for CI builds to avoid polluting logs too.

@syneva-runyan
Copy link
Contributor

syneva-runyan commented Nov 14, 2017

Regarding a specific issue from tree/master/addons/info:

An Invalid DOM nesting error is being thrown in the first test, <pre> cannot be a decendant of <p>

This error comes from the following:

withInfo(
'# Test story \n## with markdown info \ncontaing bold, cursive text and code'
)

The provided markdown is rendered inside a <p> tag, as definied in text.js, <P>.

When the rest of the markdown parsed with marksy, the code portion of the info is rendered in a <pre> tag, which causes the invalid DOM nesting error.

A similar error would be thrown if a link was provided in the markdown, ex

withInfo(
'# Test story \n## with markdown info \ncontaing [I'm an inline-style link with title]'
)

Possible solutions to this problem would be:

  • Change <p> to render content inside of a <div> or other containing element. (markdown/text.js)
  • Change <code> to render content inside a <span> or other element. (markdown/code.js) (Would not fix the link scenario)
  • A technical solution involving understanding what markdown is being passed to component and responding appropriately or throwing an error.

Thoughts on the best approach here? @danielduan

@danielduan
Copy link
Member Author

It should probably just be a <div> if there aren't any huge regressions visually.

@syneva-runyan
Copy link
Contributor

syneva-runyan commented Nov 19, 2017

Raised a pull request, #2343 Sorry for taking so long!

Regarding warning from addons/info/scr/index.test.js line 10:

I thought about putting in a fix for an issue that came up here where using marksy to output a function (rather than a string) spat out a warning, but figured that may be a separate issue (or maybe a marksy issue?) to deal with. Instead, I've added a .toString() to the passed function, suppressing the warning for now.

Hypnosphi added a commit that referenced this issue Nov 21, 2017
…ail-tests-#2196

Issue #2196 - Set console.warn and console.error to throw in tests
@dangreenisrael
Copy link
Member

If this is merged into master, should the issue be closed? @Hypnosphi. This (#1138) seems to imply that we want to get issues closed on the sooner side.

@Hypnosphi
Copy link
Member

Let's close it when the same is done for release/3.3

@syneva-runyan
Copy link
Contributor

Put in pull request for the warnings in release/3.3 https://github.com/storybooks/storybook/pull/2381/files

@Hypnosphi
Copy link
Member

Fixed with #2343 and #2381

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup Minor cleanup style change that won't show up in release changelog good first issue help wanted
Projects
None yet
Development

No branches or pull requests

4 participants