Skip to content

Commit

Permalink
Remove colors from test assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
Couto committed Mar 20, 2017
1 parent 357ce52 commit d04cc3b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions test/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,19 @@ function strictSuite () {
});
// describe
describe("When \"codeFrame\"", () => {
// Strip chalk colors, these are not relevant for the test
const stripAnsi = (str) => str.replace(
/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,
""
);

it("should display codeFrame when option is absent", (done) => {
lint({
fixture: ["syntax-error"],
eslint: baseEslintOpts
}, (err, report) => {
if (err) return done(err);
assert(report[0].message.indexOf("^\n 5 |") > -1);
assert(stripAnsi(report[0].message).indexOf("^\n 5 |") > -1);
done();
});
});
Expand All @@ -222,7 +228,7 @@ function strictSuite () {
})
}, (err, report) => {
if (err) return done(err);
assert(report[0].message.indexOf("^\n 5 |") > -1);
assert(stripAnsi(report[0].message).indexOf("^\n 5 |") > -1);
done();
});
});
Expand All @@ -237,7 +243,7 @@ function strictSuite () {
})
}, (err, report) => {
if (err) return done(err);
assert(report[0].message.indexOf("^\n 5 |") === -1);
assert(stripAnsi(report[0].message).indexOf("^\n 5 |") === -1);
done();
});
});
Expand Down

0 comments on commit d04cc3b

Please sign in to comment.