Skip to content

Commit a324352

Browse files
committed
add tests
1 parent c9011fe commit a324352

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

test/Errors.test.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,4 +168,23 @@ describe("Errors", () => {
168168
done();
169169
});
170170
});
171+
it("should show loader name when emit an error from a loader", (done) => {
172+
getErrors({
173+
mode: "development",
174+
entry: "./entry-point",
175+
module: {
176+
rules: [{
177+
test: /entry-point\.js$/,
178+
use: path.resolve(base, "./emit-error-loader")
179+
}]
180+
}
181+
182+
}, (errors, warnings) => {
183+
errors.length.should.be.eql(1);
184+
warnings.length.should.be.eql(1);
185+
errors[0].split("\n")[1].should.match(/^Module build failed\(from emit-error-loader\.js\)/);
186+
warnings[0].split("\n")[1].should.match(/^Module warning\(from emit-error-loader\.js\)/);
187+
done();
188+
});
189+
});
171190
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = function(source) {
2+
this.emitWarning(new Error("a warning from loader"));
3+
this.emitError(new Error("a error from loader"));
4+
return source;
5+
};

0 commit comments

Comments
 (0)