assert.js (678B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */ 4 5 import { isNodeTest } from "./environment"; 6 7 let assert; 8 // TODO: try to enable these assertions on mochitest by also enabling it on: 9 // import flags from "devtools/shared/flags"; 10 // if (flags.testing) 11 // Unfortunately it throws a lot on mochitests... 12 13 if (isNodeTest()) { 14 assert = function (condition, message) { 15 if (!condition) { 16 throw new Error(`Assertion failure: ${message}`); 17 } 18 }; 19 } else { 20 assert = function () {}; 21 } 22 export default assert;