| 1 |
"use strict"; |
| 2 |
|
| 3 |
var path = require("node:path").posix; |
| 4 |
var helpers = require("../helpers"); |
| 5 |
var runMochaJSON = helpers.runMochaJSON; |
| 6 |
var resolvePath = helpers.resolveFixturePath; |
| 7 |
|
| 8 |
describe("--ignore", function () { |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
function runMochaTest(fixture, args, handleResult, done) { |
| 19 |
runMochaJSON(fixture, args, function (err, res) { |
| 20 |
if (err) { |
| 21 |
return done(err); |
| 22 |
} |
| 23 |
|
| 24 |
handleResult(res); |
| 25 |
done(); |
| 26 |
}); |
| 27 |
} |
| 28 |
|
| 29 |
it("should ignore specific files", function (done) { |
| 30 |
var fixtures = path.join("options", "ignore", "*"); |
| 31 |
runMochaTest( |
| 32 |
fixtures, |
| 33 |
[ |
| 34 |
"--ignore", |
| 35 |
resolvePath(path.join("options", "ignore", "fail")).replace(/\\/g, "/"), |
| 36 |
], |
| 37 |
function (res) { |
| 38 |
expect(res, "to have passed") |
| 39 |
.and("to have run test", "should find this test") |
| 40 |
.and("not to have pending tests"); |
| 41 |
}, |
| 42 |
done, |
| 43 |
); |
| 44 |
}); |
| 45 |
|
| 46 |
it("should ignore globbed files", function (done) { |
| 47 |
var fixtures = path.join("options", "ignore", "**", "*"); |
| 48 |
runMochaTest( |
| 49 |
fixtures, |
| 50 |
["--ignore", "**/fail.fixture.js"], |
| 51 |
function (res) { |
| 52 |
expect(res, "to have passed") |
| 53 |
.and("not to have pending tests") |
| 54 |
.and("to have passed test count", 2); |
| 55 |
}, |
| 56 |
done, |
| 57 |
); |
| 58 |
}); |
| 59 |
|
| 60 |
it("should ignore multiple patterns", function (done) { |
| 61 |
var fixtures = path.join("options", "ignore", "**", "*"); |
| 62 |
runMochaTest( |
| 63 |
fixtures, |
| 64 |
[ |
| 65 |
"--ignore", |
| 66 |
resolvePath(path.join("options", "ignore", "fail")).replace(/\\/g, "/"), |
| 67 |
"--ignore", |
| 68 |
resolvePath(path.join("options", "ignore", "nested", "fail")).replace( |
| 69 |
/\\/g, |
| 70 |
"/", |
| 71 |
), |
| 72 |
], |
| 73 |
function (res) { |
| 74 |
expect(res, "to have passed") |
| 75 |
.and("not to have pending tests") |
| 76 |
.and("to have passed test count", 2); |
| 77 |
}, |
| 78 |
done, |
| 79 |
); |
| 80 |
}); |
| 81 |
}); |