How to use gavel - 2 common examples

To help you get started, we’ve selected a few gavel 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 apiaryio / dredd / lib / TransactionRunner.js View on Github external
validateTransaction(test, transaction, callback) {
    logger.debug('Validating HTTP transaction by Gavel.js');
    let gavelResult = { fields: {} };

    try {
      gavelResult = gavel.validate(transaction.expected, transaction.real);
    } catch (validationError) {
      logger.debug('Gavel.js validation errored:', validationError);
      this.emitError(validationError, test);
    }

    test.title = transaction.id;
    test.actual = transaction.real;
    test.expected = transaction.expected;
    test.request = transaction.request;

    // TODO
    // Gavel result MUST NOT be undefined. Check transaction runner tests
    // to find where and why it is.
    const { valid: isValid } = gavelResult;

    if (isValid) {
github stoplightio / prism / test-harness / index.ts View on Github external
try {
          if (isXml) {
            return xmlValidator.validate(expected, output).then(res => {
              expect(res).toStrictEqual([]);
              delete expected.body;
              delete output.body;

              const isValid = validate(expected, output).valid;
              expect(isValid).toBeTruthy();

              return shutdownPrism(prismMockProcessHandle, done);
            });
          }

          const isValid = validate(expected, output).valid;

          if (!!isValid) {
            expect(isValid).toBeTruthy();
          } else {
            expect(output).toMatchObject(expected);
          }
          if (parsed.expect) {
            expect(output.body).toStrictEqual(expected.body);
          }
        } finally {
          shutdownPrism(prismMockProcessHandle, done);
        }
      });
    });

gavel

Validator of HTTP transactions (JavaScript implementation)

MIT
Latest version published 2 years ago

Package Health Score

57 / 100
Full package analysis

Popular gavel functions