Skip to content
This repository was archived by the owner on Sep 28, 2020. It is now read-only.

Commit 6f27778

Browse files
committed
Explode tests in multiples files
1 parent 92b7a42 commit 6f27778

10 files changed

Lines changed: 239 additions & 212 deletions

File tree

test/error.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
var test = require("tape")
2+
var webpack = require("webpack")
3+
var assign = require("object-assign")
4+
var conf = require("./utils/conf")
5+
6+
test("eslint-loader can return error if file is bad", function(t) {
7+
webpack(assign({},
8+
conf,
9+
{
10+
entry: "./test/fixtures/error.js",
11+
}
12+
),
13+
function(err, stats) {
14+
if (err) {throw err}
15+
16+
t.ok(stats.hasErrors(), "a file that contains eslint errors should return error")
17+
t.end()
18+
})
19+
})

test/eslintignore.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
var test = require("tape")
2+
var webpack = require("webpack")
3+
var assign = require("object-assign")
4+
var conf = require("./utils/conf")
5+
6+
test("eslint-loader ignores files present in .eslintignore", function(t) {
7+
webpack(assign({},
8+
conf,
9+
{
10+
entry: "./test/fixtures/ignore.js",
11+
eslint: assign({}, conf.eslint, {
12+
// we want to enable ignore, so eslint will parse .eslintignore and
13+
// should skip the file specified above
14+
ignore: true,
15+
}),
16+
}
17+
),
18+
function(err, stats) {
19+
if (err) {throw err}
20+
21+
t.ok(stats.hasWarnings(), "an ignored file gives a warning")
22+
t.end()
23+
})
24+
})

test/force-emit.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
var test = require("tape")
2+
var webpack = require("webpack")
3+
var assign = require("object-assign")
4+
var conf = require("./utils/conf")
5+
6+
test("eslint-loader can force to emit error", function(t) {
7+
webpack(assign({},
8+
conf,
9+
{
10+
entry: "./test/fixtures/warn.js",
11+
eslint: assign({}, conf.eslint, {
12+
emitError: true,
13+
}),
14+
}
15+
),
16+
function(err, stats) {
17+
if (err) {throw err}
18+
19+
t.ok(stats.hasErrors(), "a file should return error if asked")
20+
t.notOk(stats.hasWarnings(), "a file should return no warning if error asked")
21+
t.end()
22+
})
23+
})
24+
25+
test("eslint-loader can force to emit warning", function(t) {
26+
webpack(assign({},
27+
conf,
28+
{
29+
entry: "./test/fixtures/error.js",
30+
eslint: assign({}, conf.eslint, {
31+
emitWarning: true,
32+
}),
33+
}
34+
),
35+
function(err, stats) {
36+
if (err) {throw err}
37+
38+
t.ok(stats.hasWarnings(), "a file should return warning if asked")
39+
t.notOk(stats.hasErrors(), "a file should return no error if error asked")
40+
t.end()
41+
})
42+
})

test/formatter.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
var test = require("tape")
2+
var webpack = require("webpack")
3+
var assign = require("object-assign")
4+
var conf = require("./utils/conf")
5+
6+
test("eslint-loader can use eslint formatter", function(t) {
7+
webpack(assign({},
8+
conf,
9+
{
10+
entry: "./test/fixtures/error.js",
11+
}
12+
),
13+
function(err, stats) {
14+
if (err) {throw err}
15+
16+
console.log("### Here is a example of the default formatter")
17+
console.log("# " + stats.compilation.errors[0].message.split("\n").join("\n# "))
18+
t.ok(stats.compilation.errors[0].message, "webpack have some output")
19+
t.end()
20+
})
21+
})
22+
23+
test("eslint-loader can use custom formatter", function(t) {
24+
webpack(assign({},
25+
conf,
26+
{
27+
entry: "./test/fixtures/error.js",
28+
eslint: assign({}, conf.eslint, {
29+
formatter: require("eslint-friendly-formatter"),
30+
}),
31+
}
32+
),
33+
function(err, stats) {
34+
if (err) {throw err}
35+
36+
console.log("### Here is a example of another formatter")
37+
console.log("# " + stats.compilation.errors[0].message.split("\n").join("\n# "))
38+
t.ok(stats.compilation.errors[0].message, "webpack have some output with custom formatters")
39+
t.end()
40+
})
41+
})

test/index.js

Lines changed: 0 additions & 212 deletions
This file was deleted.

test/ok.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
var test = require("tape")
2+
var webpack = require("webpack")
3+
var assign = require("object-assign")
4+
var conf = require("./utils/conf")
5+
6+
test("eslint-loader don't throw error if file is ok", function(t) {
7+
webpack(assign({},
8+
conf,
9+
{
10+
entry: "./test/fixtures/good.js",
11+
}
12+
),
13+
function(err, stats) {
14+
if (err) {throw err}
15+
16+
t.notOk(stats.hasErrors(), "a good file doesn't give any error")
17+
t.notOk(stats.hasWarnings(), "a good file doesn't give any warning")
18+
t.end()
19+
})
20+
})

test/parameters.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
var test = require("tape")
2+
var webpack = require("webpack")
3+
var assign = require("object-assign")
4+
var conf = require("./utils/conf")
5+
6+
test("eslint-loader supports query strings parameters", function(t) {
7+
webpack(assign({},
8+
conf,
9+
{
10+
entry: "./test/fixtures/good-semi.js",
11+
module: {
12+
loaders: [
13+
{
14+
test: /\.js$/,
15+
loader: "./index?{rules:[{semi:0}]}",
16+
exclude: /node_modules/,
17+
},
18+
],
19+
},
20+
}
21+
),
22+
function(err, stats) {
23+
if (err) {throw err}
24+
25+
t.notOk(stats.hasErrors(), "a good file doesn't give any error")
26+
t.notOk(stats.hasWarnings(), "a good file doesn't give any warning")
27+
t.end()
28+
})
29+
})

0 commit comments

Comments
 (0)