forked from webpack-contrib/eslint-loader
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request webpack-contrib#141 from wrakky/test_restructure
Test restructure
- Loading branch information
Showing
18 changed files
with
285 additions
and
240 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
language: node_js | ||
|
||
node_js: | ||
- 7 | ||
- 6 | ||
- 5 | ||
- 4 | ||
|
||
env: | ||
- WEBPACK_VERSION=2 | ||
- WEBPACK_VERSION=1 | ||
|
||
matrix: | ||
fast_finish: true | ||
|
||
before_script: | ||
- npm install webpack@$WEBPACK_VERSION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
var test = require("ava") | ||
var webpack = require("webpack") | ||
var conf = require("./utils/conf") | ||
|
||
test.cb("eslint-loader can force to emit error", function(t) { | ||
t.plan(2) | ||
webpack(conf( | ||
{ | ||
entry: "./test/fixtures/warn.js", | ||
}, | ||
{ | ||
emitError: true, | ||
} | ||
), | ||
function(err, stats) { | ||
if (err) { | ||
throw err | ||
} | ||
|
||
// console.log(stats.compilation.errors) | ||
t.true(stats.hasErrors(), "a file should return error if asked") | ||
// console.log(stats.compilation.warnings) | ||
t.false( | ||
stats.hasWarnings(), | ||
"a file should return no warning if error asked" | ||
) | ||
t.end() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
var test = require("ava") | ||
var webpack = require("webpack") | ||
var conf = require("./utils/conf") | ||
|
||
test.cb("eslint-loader can force to emit warning", function(t) { | ||
t.plan(2) | ||
webpack(conf( | ||
{ | ||
entry: "./test/fixtures/error.js", | ||
}, | ||
{ | ||
emitWarning: true, | ||
} | ||
), | ||
function(err, stats) { | ||
if (err) { | ||
throw err | ||
} | ||
|
||
// console.log(stats.compilation.warnings) | ||
t.true(stats.hasWarnings(), "a file should return warning if asked") | ||
// console.log(stats.compilation.errors) | ||
t.false(stats.hasErrors(), "a file should return no error if error asked") | ||
t.end() | ||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* eslint-disable no-console */ | ||
var test = require("ava") | ||
var webpack = require("webpack") | ||
var conf = require("./utils/conf") | ||
|
||
test.cb("eslint-loader can use custom formatter", function(t) { | ||
t.plan(1) | ||
webpack(conf( | ||
{ | ||
entry: "./test/fixtures/error.js", | ||
}, | ||
{ | ||
formatter: require("eslint-friendly-formatter"), | ||
} | ||
), | ||
function(err, stats) { | ||
if (err) { | ||
throw err | ||
} | ||
|
||
console.log("### Here is a example of another formatter") | ||
console.log( | ||
"# " + | ||
stats.compilation.errors[0].message | ||
.split("\n") | ||
.join("\n# ") | ||
) | ||
t.truthy( | ||
stats.compilation.errors[0].message, | ||
"webpack have some output with custom formatters" | ||
) | ||
t.end() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* eslint-disable no-console */ | ||
var test = require("ava") | ||
var webpack = require("webpack") | ||
var conf = require("./utils/conf") | ||
|
||
test.cb("eslint-loader can use eslint formatter", function(t) { | ||
t.plan(1) | ||
webpack(conf( | ||
{ | ||
entry: "./test/fixtures/error.js", | ||
} | ||
), | ||
function(err, stats) { | ||
if (err) { | ||
throw err | ||
} | ||
|
||
console.log("### Here is a example of the default formatter") | ||
console.log( | ||
"# " + | ||
stats.compilation.errors[0].message | ||
.split("\n") | ||
.join("\n# ") | ||
) | ||
t.truthy(stats.compilation.errors[0].message, "webpack have some output") | ||
t.end() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* eslint-disable no-console */ | ||
var test = require("ava") | ||
var webpack = require("webpack") | ||
var conf = require("./utils/conf") | ||
var fs = require("fs") | ||
|
||
test.cb("eslint-loader can be configured to write eslint results to a file", | ||
function(t) { | ||
t.plan(2) | ||
|
||
var outputFilename = "outputReport.txt" | ||
var config = conf( | ||
{ | ||
entry: "./test/fixtures/error.js", | ||
}, | ||
{ | ||
formatter: require("eslint/lib/formatters/checkstyle"), | ||
outputReport: { | ||
filePath: outputFilename, | ||
}, | ||
} | ||
) | ||
|
||
webpack(config, | ||
function(err, stats) { | ||
if (err) { | ||
throw err | ||
} | ||
|
||
console.log("### Here is a the output of the formatter") | ||
console.log( | ||
"# " + | ||
stats.compilation.errors[0].message | ||
.split("\n") | ||
.join("\n# ") | ||
) | ||
|
||
fs.readFile(config.output.path + outputFilename, | ||
"utf8", function(err, contents) { | ||
if (err) { | ||
t.fail("Expected file to have been created") | ||
} | ||
else { | ||
t.pass("File has been created") | ||
|
||
t.is(stats.compilation.errors[0].message, contents, | ||
"File Contents should equal output") | ||
} | ||
|
||
t.end() | ||
|
||
}) | ||
}) | ||
}) |
Oops, something went wrong.