0.0.2 • Published 7 years ago

chai-avro v0.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

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

0.0.2

7 years ago

0.0.1

8 years ago