chai-avro

0.0.2 • Public • Published

chai-avro

A chaijs plugin to use Avro schema definitions in tests

Info

This is a very simple plugin to use the Avro schemas within the chaijs testing framework, which allows for easily testing against schemas. Behind the scenes it is based on the Avro implementation from AVSC. Currently only supports loading protocols from Avro IDL files (*.avdl).

Usage

Load chai and chai-avro modules

const chai = require('chai');
const chaiAvro = require('chai-avro');
chai.use(chaiAvro);

Load an Avro protocol from IDL (*.avdl) file (e.g. in before handler in mocha)

chaiAvro
  .loadProtocol('./com/example/types/MyProtocolFile.avdl')
  .then(function() {
    // start tests
  });

Test your objects against the Avro schema, using your favorite style

expect(obj).to.be.a.avroType('com.example.types.Foo');
assert.isAvroType(obj, 'com.example.types.Foo');

For real-world examples see docs/example-mochajs.md.

About

by Rico Pfaus | (c) 2016 | MIT licensed

Dependencies (1)

Dev Dependencies (2)

Package Sidebar

Install

npm i chai-avro

Weekly Downloads

3

Version

0.0.2

License

MIT

Last publish

Collaborators

  • ryx