We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cc3af32 commit 17f2b90Copy full SHA for 17f2b90
test/integration/modules/console/assert.js
@@ -0,0 +1,8 @@
1
+const assert = (condition, message) => {
2
+ if (!condition) {
3
+ throw new Error('Assert failed: ' + (message || ''));
4
+ }
5
+};
6
+
7
8
+module.exports = assert;
test/integration/modules/console/assert.test.js
@@ -0,0 +1,22 @@
+const assert = require("./assert.js")
+describe("assert()", () => {
+ test("if passed", () => {
+ expect(() => {
+ assert(true);
+ }).not.toThrow();
9
+ });
10
11
+ test("if failed without msg", () => {
12
13
+ assert(false);
14
+ }).toThrow("Assert failed: ");
15
16
17
+ test("if failed with msg", () => {
18
19
+ assert(false, "err msg");
20
+ }).toThrow("Assert failed: err msg");
21
22
+});
0 commit comments