Testing and documenting ES6 code

Daniel Popescu

Computer Scientist

Adobe Romania

Why you should always write tests?

Because...Regression

Improve implementation

Maintainability

Self documentation

What tools can I use for testing ES6 code?

import AnimalFactory from './AnimalFactory';

describe("AnimalFactory", ()=> {
    it("should throw an error if the animal type does not exists", ()=> {
        expect(AnimalFactory.getAnimal).toThrowError(Error, "Invalid animal type");
    });

    it("should create a new dog", ()=> {
        expect(AnimalFactory.getAnimal("dog").constructor.name).toBe("Dog");
    });

    it("should create a new cat", ()=> {
        expect(AnimalFactory.getAnimal("cat").constructor.name).toBe("Cat");
    });
});

Ok...can I see some code?

Thank you

Testing and documenting ES6 code

By Daniel Popescu

Testing and documenting ES6 code

  • 95