Commit cca43fe3 authored by Haoqun Jiang's avatar Haoqun Jiang

test: use stats.hasErrors & stats.toString instead of stats.compilation

parent 2d6b83ab
...@@ -83,15 +83,13 @@ function bundle (options, cb, wontThrowError) { ...@@ -83,15 +83,13 @@ function bundle (options, cb, wontThrowError) {
webpackCompiler.outputFileSystem = mfs webpackCompiler.outputFileSystem = mfs
webpackCompiler.outputFileSystem.join = path.join.bind(path) webpackCompiler.outputFileSystem.join = path.join.bind(path)
webpackCompiler.run((err, stats) => { webpackCompiler.run((err, stats) => {
const errors = stats.compilation.errors
if (!wontThrowError) { if (!wontThrowError) {
expect(err).toBeNull() expect(err).toBeNull()
if (errors && errors.length) {
errors.forEach(error => { if (stats.hasErrors()) {
console.error(error) return console.error(stats.toString('errors-only'))
})
} }
expect(errors).toHaveLength(0) expect(stats.hasErrors()).toBeFalsy()
} }
cb(mfs.readFileSync('/test.build.js').toString(), stats, err) cb(mfs.readFileSync('/test.build.js').toString(), stats, err)
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment