Remove console.warn of babel-plugin-import when the tests are running
See original GitHub issueEnvironment(required)
- antd version: 2.8 & 2.9
- OS and its version: Ubuntu 16.04
- Browser and its version: Chrome 57.0.2987.98 (64-bit)
What did you do? Please provide steps to re-produce your problem.
Run npm test
in:
- Project antd.
- Another project created with Create-React-App
What do you expected?
No warnings.
What happen?
Both projects always show this message:
PASS components/locale-provider/__tests__/index.test.js
Console
console.warn components/index.tsx:60
You are using a whole package of antd,
please use https://www.npmjs.com/package/babel-plugin-import to reduce app bundle size.
I think it will be important remove it when you’re executing the tests.
I think, too, the solution is change this kind of code:
if (process.env.NODE_ENV !== 'production') {
if (typeof console !== 'undefined' && console.warn && typeof window !== 'undefined') {
console.warn(`You are using a whole package of antd,
please use https://www.npmjs.com/package/babel-plugin-import to reduce app bundle size.`);
}
}
Providing another conditional for remove warnings if you are lauching the tests. What do you think about it?
Re-producible online demo
Just download the antd project and run npm test
.
Issue Analytics
- State:
- Created 7 years ago
- Comments:12 (8 by maintainers)
Top Results From Across the Web
React Native 0.60.3 babel-plugin-transform-remove-console ...
this will remove console.log in the production build. if you wanna a test in development you can pass development instead of production.
Read more >babel-plugin-transform-remove-console
exclude - An array of console methods to exclude from removal. You can read more about configuring plugin options here. Example; Installation; Usage....
Read more >babel-plugin-transform-remove-console - npm package - Snyk
The npm package babel-plugin-transform-remove-console was scanned for known vulnerabilities and missing license, and no issues were found. Thus the package was ...
Read more >deploy-testing (#14830) · Jobs · m4lab_tv1 / User Account · GitLab
1Running with gitlab-runner 14.8.1 (6a42249e) ... 14Checking out d983558b as testing. ... 79Removing node_modules/@babel/plugin-proposal-dynamic-import/.
Read more >Configuration | Stryker Mutator
Enable checker plugins here. A checker plugin will be invoked for each mutant before it is run in a test runner. It can...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
#10363
Not only that, but this assumes the user is using Babel. I use Typescript with Webpack. I know that, because of Webpack, dead code is going to be eliminated. This warning is useless in this scenario and there’s no way to turn it off.
I don’t need this warning cluttering up my terminal. You shouldn’t expect the user to change NODE_ENV to production to disable this. In tests, NODE_ENV should be test. You also really shouldn’t encourage the user to know about the directory structure of your library. You have exposed a context module, as is the usual pattern; let users use it without being told off.
http://www.linfo.org/rule_of_silence.html