Skip to content

Commit

Permalink
tests: loader's error regression test for #1581
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 committed Aug 6, 2020
1 parent 02ffa05 commit c6c063c
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,4 @@ packages/**/*.map

# temporary test files
test-assets/
./lib/
13 changes: 13 additions & 0 deletions test/loader/error-test/loader-error.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict';

// eslint-disable-next-line node/no-unpublished-require
const { run } = require('../../utils/test-utils');

describe('loader error regression test for #1581', () => {
it(`should not ignore loader's error produce a failing build`, () => {
const { stderr, stdout } = run(__dirname, [], false);
expect(stderr).toBeFalsy();
expect(stdout).toContain('[built] [failed] [1 error]');
expect(stdout).toContain(`Cannot assign to 'foobar' because it is a constant`);
});
});
6 changes: 6 additions & 0 deletions test/loader/error-test/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"dependencies": {
"ts-loader": "^7.0.5",
"typescript": "^3.9.3"
}
}
4 changes: 4 additions & 0 deletions test/loader/error-test/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const foobar = 'foobar';
// eslint-disable-next-line no-const-assign
foobar = 'barbaz'; // Error!
console.log(foobar);
25 changes: 25 additions & 0 deletions test/loader/error-test/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const path = require('path');

module.exports = {
mode: 'development',

entry: {
bundle: './src/index.ts',
},

output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js',
},

module: {
rules: [
{
test: /.(ts|tsx)?$/,
loader: 'ts-loader',
include: [path.resolve(__dirname, 'src')],
exclude: [/node_modules/],
},
],
},
};

0 comments on commit c6c063c

Please sign in to comment.