I want to set up tests for the project I'm building. In the examples I can find, they all say including the relevant code to test is done by a require statement: require('foo');. However my project isn't built in modules, but in ES6 classes that are then translated to ES5 prototypes.
I'm wondering how to include the file/s?
So for instance the ES6 class:
class Foo {
constructor() {
// do things
}
}
Translates roughly to:
// ES5 compatible code is here (_classCallCheck etc).
var Foo = (function () {
function Foo() {
_classCallCheck(this, Foo);
// do things
}
}
And I'd like to know how to include it in my test file:
var expect = require('chai').expect;
// how to require or whatever else here?
describe('Foo', function() {
it('creates an Foo object', function() {
var foo = new Foo({});
});
});
Aucun commentaire:
Enregistrer un commentaire