Skip to content

Commit ccf9da2

Browse files
committed
fix: use LoaderOptionsPlugin to set updateIndex
1 parent f523b17 commit ccf9da2

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

test/HotTestCases.test.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ describe("HotTestCases", function() {
3232
var recordsPath = path.join(outputDirectory, "records.json");
3333
if(fs.existsSync(recordsPath))
3434
fs.unlinkSync(recordsPath);
35+
var fakeUpdateLoaderOptions = {
36+
options: {
37+
updateIndex: 0
38+
}
39+
};
3540
var options = {
3641
context: testDirectory,
3742
entry: "./index.js",
@@ -48,10 +53,10 @@ describe("HotTestCases", function() {
4853
target: "async-node",
4954
plugins: [
5055
new webpack.HotModuleReplacementPlugin(),
51-
new webpack.NamedModulesPlugin()
56+
new webpack.NamedModulesPlugin(),
57+
new webpack.LoaderOptionsPlugin(fakeUpdateLoaderOptions)
5258
],
53-
recordsPath: recordsPath,
54-
updateIndex: 0
59+
recordsPath: recordsPath
5560
}
5661
var compiler = webpack(options);
5762
compiler.run(function(err, stats) {
@@ -71,14 +76,14 @@ describe("HotTestCases", function() {
7176
}
7277

7378
function _next(callback) {
74-
options.updateIndex++;
79+
fakeUpdateLoaderOptions.options.updateIndex++;
7580
compiler.run(function(err, stats) {
7681
if(err) return done(err);
7782
var jsonStats = stats.toJson({
7883
errorDetails: true
7984
});
80-
if(checkArrayExpectation(testDirectory, jsonStats, "error", "errors" + options.updateIndex, "Error", done)) return;
81-
if(checkArrayExpectation(testDirectory, jsonStats, "warning", "warnings" + options.updateIndex, "Warning", done)) return;
85+
if(checkArrayExpectation(testDirectory, jsonStats, "error", "errors" + fakeUpdateLoaderOptions.options.updateIndex, "Error", done)) return;
86+
if(checkArrayExpectation(testDirectory, jsonStats, "warning", "warnings" + fakeUpdateLoaderOptions.options.updateIndex, "Warning", done)) return;
8287
if(callback) callback();
8388
})
8489
}

0 commit comments

Comments
 (0)