Skip to content

Commit

Permalink
Add test for helpful error
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert committed Mar 23, 2020
1 parent 59636d7 commit a7fe879
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion test/cli/index.js
Expand Up @@ -13,7 +13,7 @@ const cwd = process.cwd();
sander.rimrafSync(__dirname, 'node_modules');
sander.copydirSync(__dirname, 'node_modules_rename_me').to(__dirname, 'node_modules');

runTestSuiteWithSamples.only(
runTestSuiteWithSamples(
'cli',
path.resolve(__dirname, 'samples'),
(dir, config) => {
Expand Down
14 changes: 13 additions & 1 deletion test/cli/samples/config-no-module/_config.js
@@ -1,4 +1,16 @@
const { assertStderrIncludes } = require('../../../utils.js');

module.exports = {
description: 'provides a helpful error message if a transpiled config is interpreted as "module"',
command: 'cd sub && rollup -c'
command: 'cd sub && rollup -c',
error: () => true,
stderr: stderr =>
assertStderrIncludes(
stderr,
'[!] While loading the Rollup configuration from "rollup.config.js", Node tried to require an ES module from a CommonJS ' +
'file, which is not supported. A common cause is if there is a package.json file with "type": "module" in the same folder. You can ' +
'try to fix this by changing the extension of your configuration file to ".cjs" or ".mjs" depending on the content, which will ' +
'prevent Rollup from trying to preprocess the file but rather hand it to Node directly.\n' +
'https://rollupjs.org/guide/en/#using-untranspiled-config-files'
)
};

0 comments on commit a7fe879

Please sign in to comment.