How to use the assert.fail function in assert

To help you get started, we’ve selected a few assert 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 Azure / azure-sdk-for-js / test / integration / authorization.spec.ts View on Github external
it("Accessing container without permission fails", async function() {
    const clientNoPermission = new CosmosClient({ endpoint, auth: null });

    try {
      await clientNoPermission
        .database(database.id)
        .container(container.id)
        .read();
      assert.fail("accessing container did not throw");
    } catch (err) {
      assert(err !== undefined); // TODO: should check that we get the right error message
    }
  });
github named-data / ndn-js / tests / node / integration-tests / test-validator.js View on Github external
it("MalformedCertificate", function() {
    // Copy the default certificate.
    var malformedCertificate = new Data
      (this.fixture_.subIdentity_.getDefaultKey().getDefaultCertificate());
    malformedCertificate.getMetaInfo().setType(ContentType.BLOB);
    this.fixture_.keyChain_.sign
      (malformedCertificate, new SigningInfo(this.fixture_.identity_));
    // It has the wrong content type and a missing ValidityPeriod.
    try {
      new CertificateV2(malformedCertificate).wireEncode();
      assert.fail('', '', "Did not throw the expected exception");
    } catch (ex) {
      if (!(ex instanceof CertificateV2.Error))
        assert.fail('', '', "Did not throw the expected exception");
    }

    var originalProcessInterest = this.fixture_.face_.processInterest_;
    this.fixture_.face_.processInterest_ = function
        (interest, onData, onTimeout, onNetworkNack) {
      if (interest.getName().isPrefixOf(malformedCertificate.getName()))
        onData(interest, malformedCertificate);
      else
        originalProcessInterest.processInterest
          (interest, onData, onTimeout, onNetworkNack);
    };

    var data = new Data(new Name("/Security/V2/ValidatorFixture/Sub1/Sub2/Data"));
    this.fixture_.keyChain_.sign(data, new SigningInfo(this.fixture_.subIdentity_));

    this.validateExpectFailure(data, "Signed by a malformed certificate");
github mikegerwitz / easejs / test / test-member_builder-method.js View on Github external
}
    catch ( e )
    {
        assert.ok( e.message.search( mb_common.name ) !== -1,
            "Method override getter failure should contain method name"
        );

        // ensure we have the correct error
        assert.ok( e.message.search( 'getter' ) !== -1,
            "Proper error is thrown for getter override failure"
        );

        return;
    }

    assert.fail(
        "Should not be permitted to override getters with methods"
    );
} )();
github mikegerwitz / easejs / test / test-class-name.js View on Github external
( function testNamedClassDefinitionRequiresThatDefinitionBeAnObject()
{
    var name = 'Foo';

    try
    {
        Class( name, 'Bar' );

        // if all goes well, we'll never get to this point
        assert.fail( "Second argument to named class must be the definition" );
    }
    catch ( e )
    {
        assert.notEqual(
            e.message.match( name ),
            null,
            "Class definition argument count error string contains class name"
        );
    }
} )();
github getstation / electron-chrome-extension / test / cx-fetcher / storage-provider.ts View on Github external
const storager = new StorageProvider({
        extensionsFolder: { path: TEST_PATH_EXTENSIONS },
        cacheFolder: new Location(
          `${TEST_PATH_EXTENSIONS}-cache`
        ),
      });
      storager.unzipCrx = () => Promise.reject('Cannot unzip archive');

      // todo: someday, use assert.rejects (availabe in node 10)
      try {
        await storager.installExtension(FAKE_DL_DESCRIPTOR);
      } catch (err) {
        assert.equal('Cannot unzip archive', err);
        return;
      }
      assert.fail('Install should fail if archive cannot be unzipped');
    });
github maticnetwork / sol-trace / test / web3-trace-provider.spec.js View on Github external
it('data too short error.', async() => {
      try {
        tp.pickUpRevertReason(Buffer.from('hoge'))
        assert.fail('must be error')
      } catch (e) {
        assert.equal('returndata.length is MUST 100+.', e.message)
      }
    })
  })
github Master76 / dotnetjs / tests / index.js View on Github external
function asserEqual(expected, actual) {
    if (!actual.Equals(expected)) {
        var msg = String.Format('{0} was expected, but got {1} instead.', expected, actual);
        assert.fail(actual, expected, msg, 'Object.Equals(Object)');
    }
}
//# sourceMappingURL=index.js.map
github jamesshore / lets_code_javascript / node_modules / selenium-webdriver / testing / assert.js View on Github external
return evaluate(this.subject_, function (actual) {
      if (!isNumber(actual) || actual > expected) {
        assert.fail(actual, expected, opt_message, '<=');
      }
    });
  }
github graalvm / graaljs / test / parallel / test-process-no-deprecation.js View on Github external
function listener() {
  assert.fail('received unexpected warning');
}
github vowsjs / vows / lib / assert / macros.js View on Github external
assert.isEmpty = function (actual, message) {
    assertMissingArguments(arguments, assert.isEmpty);
    if ((isObject(actual) && Object.keys(actual).length > 0) || actual.length > 0) {
        assert.fail(actual, 0, message || "expected {actual} to be empty", "length", assert.isEmpty);
    }
};
assert.isNotEmpty = function (actual, message) {