How to use the chai.assert.throws function in chai

To help you get started, we’ve selected a few chai examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jsdom / jsdom / test / api / methods.js View on Github external
it("should allow passing through options", { skipIfBrowser: true }, () => {
      const dom = new JSDOM(``, { runScripts: "outside-only" });
      const script = new vm.Script("while(true) {}");

      assert.throws(() => dom.runVMScript(script, { timeout: 50 }), /Script execution timed out(?: after 50ms|\.)/);
    });
  });
github gristlabs / ts-interface-checker / test / test_checker.ts View on Github external
it("should support enum literals", () => {
    const tt = createCheckers(sample, {
      foo: t.enumlit("Direction", "Left"),
      bar: t.enumlit("DirectionStr", "Right"),
    });
    tt.foo.check(17);
    tt.bar.check("RIGHT");
    assert.throws(() => tt.foo.check("Left"), /value is not Direction.Left/);
    assert.throws(() => tt.foo.check(0), /value is not Direction.Left/);
    assert.throws(() => tt.bar.check("LEFT"), /value is not DirectionStr.Right/);
    assert.throws(() => tt.bar.check("Right"), /value is not DirectionStr.Right/);

    assert.throws(() => createCheckers(sample, {foo: t.enumlit("Direction", "bad")}),
      /Unknown value Direction.bad used in enumlit/);
    assert.throws(() => createCheckers(sample, {foo: t.enumlit("MyType", "bad")}),
      /Type MyType used in enumlit is not an enum type/);
    assert.throws(() => createCheckers(sample, {foo: t.enumlit("Bad", "bad")}),
      /Unknown type Bad/);
  });
github dominiek / shoal / test / manager.js View on Github external
it('should check if logging dir exists', function(){
    var manager = new Manager();
    var newConfiguration = JSON.parse(JSON.stringify(configuration));
    newConfiguration.processes[1].logRoot = 'bla';
    assert.throws(function() { manager.deploy(newConfiguration); }, Error, /folder does not exist/);
  });
github raineorshine / cint / test / spec.js View on Github external
it('should throw a TypeError if undefined is passed', function() {
		assert.throws(
			cint.intoString.bind(cint, undefined), 'undefined')
	})
})
github Gaafar / deppie / test / index.js View on Github external
it('should throw exception for modifying created modules', () => {
            const dep1 = () => ({ a: 1 });
            const dep2 = ({ dep1 }) => noop(dep1);
            const modules = deppie({ dep1, dep2 });
            assert.throws(() => { modules.dep1 = {}; },
                'modifying dependency'
            );
        });
    });
github waltheri / wgo.js / test / KNode.js View on Github external
it("Invalid SGF throws an error", function() {
			assert.throws(function() {
				node.innerSGF = "AW[fk]C[Cool!];W[hn]C";
			}, SGFSyntaxError);
			
			assert.throws(function() {
				node.innerSGF = "AW[fk]C[Cool!];W[hn]C[)(])(;W[hm];)";
			}, SGFSyntaxError);
			
			assert.throws(function() {
				node.innerSGF = "AW[fk]C[Cool!];W[hn]C[)(](;W[hm]";
			}, SGFSyntaxError);
		});
	});
github funkia / io / test / index.ts View on Github external
it("handles computation ending with `of`", () => {
      const comp = wrapped1(3).chain((_n) => IO.of(4));
      testIO(comp, [[wrapped1(3), 3]], 4);
      assert.throws(() => {
        testIO(comp, [[wrapped1(3), 3]], 5);
      });
    });
    it("handles computation with map and chain", () => {
github markdown-it / markdown-it / test / utils.js View on Github external
it('assign', function () {
    var assign = require('../lib/common/utils').assign;

    assert.deepEqual(assign({ a: 1 }, null, { b: 2 }), { a: 1, b: 2 });
    assert.throws(function () {
      assign({}, 123);
    });
  });
github thomas4019 / mongo-query-to-postgres-jsonb / test / filter.js View on Github external
it('fail for strings', function() {
    assert.throws(() => convert('data', { arr: { $size: 'abc' } }), '$size only supports positive integer')
  })
  it('fail for decimals', function() {
github jsdom / jsdom / test / to-port-to-wpts / compare-document-position.js View on Github external
specify("Testing a node against a non node type throws an error", () => {
    const doc = load("test");

    assert.throws(doc.compareDocumentPosition.bind(this, {}));
  });
});