test(curriculum): suppress redundant errors (#33327)

<!-- Please follow this checklist and put an x in each of the boxes, like this: [x]. It will ensure that our team takes your pull request seriously. -->

- [x] I have read [freeCodeCamp's contribution guidelines](https://github.com/freeCodeCamp/freeCodeCamp/blob/master/CONTRIBUTING.md).
- [x] My pull request has a descriptive title (not a vague title like `Update index.md`)
- [x] My pull request targets the `master` branch of freeCodeCamp.
- [x] None of my changes are plagiarized from another source without proper attribution.
- [x] My article does not contain shortened URLs or affiliate links.

If your pull request closes a GitHub issue, replace the XXXXX below with the issue number.

Closes #33195
This commit is contained in:
Valeriy
2018-11-01 18:56:15 +03:00
committed by mrugesh mohapatra
parent 3651a6c242
commit d5c0c2273f

View File

@ -1,4 +1,5 @@
const assert = require('chai').assert; const { assert, AssertionError } = require('chai');
const Mocha = require('mocha');
const { flatten } = require('lodash'); const { flatten } = require('lodash');
const path = require('path'); const path = require('path');
@ -26,6 +27,15 @@ const { challengeTypes } = require('../../client/utils/challengeTypes');
const { LOCALE: lang = 'english' } = process.env; const { LOCALE: lang = 'english' } = process.env;
const oldRunnerFail = Mocha.Runner.prototype.fail;
Mocha.Runner.prototype.fail = function(test, err) {
// Don't show stacktrace for assertion errors.
if (err.stack && err instanceof AssertionError) {
delete err.stack;
}
return oldRunnerFail.call(this, test, err);
};
let mongoIds = new MongoIds(); let mongoIds = new MongoIds();
let challengeTitles = new ChallengeTitles(); let challengeTitles = new ChallengeTitles();
@ -127,6 +137,9 @@ const jQueryScript = fs.readFileSync(
} }
it('Test suite must fail on the initial contents', async function() { it('Test suite must fail on the initial contents', async function() {
// suppress errors in the console.
const oldConsoleError = console.error;
console.error = () => {};
let fails = ( let fails = (
await Promise.all(tests.map(async function(test) { await Promise.all(tests.map(async function(test) {
try { try {
@ -141,6 +154,7 @@ const jQueryScript = fs.readFileSync(
return true; return true;
} }
}))).some(v => v); }))).some(v => v);
console.error = oldConsoleError;
assert(fails, 'Test suit does not fail on the initial contents'); assert(fails, 'Test suit does not fail on the initial contents');
}); });