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

Refactor - enable hideNothingWarning option by default #1195

Merged
merged 1 commit into from Sep 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/index.js
Expand Up @@ -157,6 +157,7 @@ export default async function loader(content, map, meta) {

try {
result = await postcss(plugins).process(content, {
hideNothingWarning: true,
from: resourcePath,
to: resourcePath,
map: options.sourceMap
Expand Down
24 changes: 24 additions & 0 deletions test/loader.test.js
Expand Up @@ -449,4 +449,28 @@ describe('loader', () => {
expect(getWarnings(stats)).toMatchSnapshot('warnings');
expect(getErrors(stats)).toMatchSnapshot('errors');
});

// TODO unskip after updating postcss to 8 version
it.skip('should not generate console.warn when plugins disabled and hideNothingWarning is "true"', async () => {
jest.spyOn(console, 'warn').mockImplementation(() => {});

const compiler = getCompiler('./empty.js', {
import: false,
url: false,
});
const stats = await compile(compiler);

// eslint-disable-next-line no-console
expect(console.warn).not.toHaveBeenCalledWith(
'You did not set any plugins, parser, or stringifier. ' +
'Right now, PostCSS does nothing. Pick plugins for your case ' +
'on https://www.postcss.parts/ and use them in postcss.config.js.'
);
expect(getModuleSource('./empty.css', stats)).toMatchSnapshot('module');
expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot(
'result'
);
expect(getWarnings(stats)).toMatchSnapshot('warnings');
expect(getErrors(stats)).toMatchSnapshot('errors');
});
});