Skip to content

Commit 4f05036

Browse files
committed
Add tests for interpolated outputReport filenames.
1 parent e0e3dea commit 4f05036

File tree

4 files changed

+63
-0
lines changed

4 files changed

+63
-0
lines changed

test/fixtures/error-multi-one.js

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Offset line by one
2+
var inone = stuff

test/fixtures/error-multi-two.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Offset line by two
2+
// Offset line by two
3+
var intwo = stuff

test/fixtures/error-multi.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
var one = require('./error-multi-one.js');
2+
var two = require('./error-multi-two.js');
3+
var foo = stuff

test/formatter.js

+55
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,58 @@ function(t) {
106106
t.end()
107107
})
108108
})
109+
110+
test("eslint-loader can be configured to write eslint results for more than one file",
111+
function(t) {
112+
113+
var outputFilename = "outputReport-[name].txt"
114+
var outputFilenamesArr = [
115+
"outputReport-error-multi.txt",
116+
"outputReport-error-multi-one.txt",
117+
"outputReport-error-multi-two.txt"
118+
]
119+
120+
webpack(assign({},
121+
conf,
122+
{
123+
entry: "./test/fixtures/error-multi.js",
124+
eslint: assign({}, conf.eslint, {
125+
formatter: require("eslint/lib/formatters/checkstyle"),
126+
outputReport: {
127+
filePath: outputFilename,
128+
},
129+
}),
130+
}
131+
),
132+
function(err, state) {
133+
if (err) {
134+
throw err
135+
}
136+
137+
console.log("### Here is the output of the formatter")
138+
console.log(
139+
"# " +
140+
stats.compilation.errors[0].message
141+
.split("\n")
142+
.join("\n# ")
143+
)
144+
145+
for (var i = 0; i < outputFilenamesArr.length; i++) {
146+
fs.readfile(conf.output.path + outputFilenamesArr[i],
147+
"utf8", function(err, contents) {
148+
if (err) {
149+
t.fail("Expected file to have been created")
150+
}
151+
else {
152+
t.pass("File '" + outputFilenamesArr[i] + "' has been created")
153+
154+
t.equal(stats.compilation.errors[i].message, contents,
155+
"File Contents should equal output")
156+
}
157+
}
158+
)
159+
}
160+
161+
t.end()
162+
})
163+
})

0 commit comments

Comments
 (0)