Tests

There is nothing special about testing your code. You can use any tools for testing. Below is an example with mocha + chai.

import { assert } from 'chai';
import Akili from 'akili';

class MyComponent extends Akili {
  created() {
    this.scope.example = 'Hello';
  }
}

let myComponentEl = document.createElement('my-component');

myComponentEl.innerHTML = '${ this.example }';
document.body.appendChild(myComponentEl);
Akili.component('my-component',  MyComponent);

describe('Application initialization', () => {
  before(() => {
    return Akili.init();
  });

  describe('Test MyComponent', () => {
    let component;

    before(() => {
      component = myComponentEl.__akili; // or Akili.root.child('my-component');
    });

    it('should be initialization scope value', () => {
      assert.equal(component.scope.example, 'Hello');
    });

    it('should be parsed the expression in the template', () => {
      assert.equal(myComponentEl.innerHTML, 'Hello');
    });

    it('should be changed value in the template', () => {
      component.scope.example = 'Goodbye';
      assert.equal(myComponentEl.innerHTML, 'Goodbye');
    });
  });
});

So, as you can see, you have two ways to get a component anywhere you want:

If you need to compile some component after the framework initialization use Akili.compile.