Testing components

If you have started you widget from our boilerplate you already have a sample test suite under the tests folder. To test a component, use the CLI to run your tests:

$ fliplet test

The above code will:

Stack to write tests

Where should my tests go

You should include your tests under tests folder of the widget.

Available to write your tests

Sample test

describe('WHEN start component', function() {
  this.timeout(10000);
  describe('Interface', function() {
    it('should have empty username', function(done) {
      interfaceBrowser
        .evaluate(function (selector) {
          return document.querySelector(selector).value;
        }, '#username')
        .then(function(username) {
          expect(username).to.equal('');
          done();
        })
    });
  });

  describe('Build', function() {
    it('should have message to configure widget', function(done) {
      const selector = `${buildSelector} h3`;
      buildBrowser
        .evaluate(function (selector) {
          return document.querySelector(selector).textContent;
        }, selector)
        .then(function(message) {
          expect(message).to.equal('This is the output of your widget');
          done();
        });
    });
  });
});