Skip to content

Commit 8deec71

Browse files
committed
tests: loader's error regression test for #1581
1 parent 4fe8045 commit 8deec71

5 files changed

Lines changed: 51 additions & 0 deletions

File tree

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,4 @@ packages/**/*.map
5252

5353
# temporary test files
5454
test-assets/
55+
./lib/
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict';
2+
3+
// eslint-disable-next-line node/no-unpublished-require
4+
const { run } = require('../../utils/test-utils');
5+
6+
describe('loader error regression test for #1581', () => {
7+
it(`should not ignore loader's error produce a failing build`, () => {
8+
// Ignoring assertion on stderr because ts-loader is producing depreciation warnings
9+
// with webpack@v5.0.0-beta.24 -> https://github.com/TypeStrong/ts-loader/issues/1169
10+
const { stdout } = run(__dirname, [], false);
11+
12+
expect(stdout).toContain('[1 error]');
13+
expect(stdout).toContain(`Cannot assign to 'foobar' because it is a constant`);
14+
});
15+
});
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"dependencies": {
3+
"ts-loader": "^7.0.5",
4+
"typescript": "^3.9.3"
5+
}
6+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
const foobar = 'foobar';
2+
// eslint-disable-next-line no-const-assign
3+
foobar = 'barbaz'; // Error!
4+
console.log(foobar);
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const path = require('path');
2+
3+
module.exports = {
4+
mode: 'development',
5+
6+
entry: {
7+
bundle: './src/index.ts',
8+
},
9+
10+
output: {
11+
path: path.resolve(__dirname, 'dist'),
12+
filename: '[name].js',
13+
},
14+
15+
module: {
16+
rules: [
17+
{
18+
test: /.(ts|tsx)?$/,
19+
loader: 'ts-loader',
20+
include: [path.resolve(__dirname, 'src')],
21+
exclude: [/node_modules/],
22+
},
23+
],
24+
},
25+
};

0 commit comments

Comments
 (0)