Skip to content
Sven Mischkewitz edited this page Nov 1, 2015 · 32 revisions

Testing

webKnossos support both unit tests and integration/end-to-end (E2E) tests.

Requirements

  • Google Chrome with webdriver support
  • node v0.12+

Running Tests

./start
npm run webdriver
npm test

Protractor

Link to API.

Protractor is a wedriver/selenium abstraction that allows for easy access to DOM elements. See Helpers section below for advice.

explorativeTab = element(By.css("#tab-explorative"))

Jasmine

All tests are run as Jasmine tests. Jasmine can be used to write plain old unit tests or rely on Protractor to access DOM elements for E2E tests.

describe("A suite", function() {
  it("contains spec with an expectation", function() {
    expect(true).toBe(true);
  });
});

Helpers

PageObject Pattern

All major wK pages (e.g. Dashboard, Users List, etc) should be wrapped in Page Class that has convenience methods for navigating to the page and access certain buttons / DOM elements.

class Dashboard extends BaseTestPage

  get : ->
    browser.get '/dashboard'

  clickButton : ->
     return @waitForButton()
      .then (btn) -> btn.click()

All protractor calls to elements should make sure that the element is already rendered / available in the DOM by waiting for it. Selecting an element through a CSS selection is easily done through the helper method XYZ().

element = XYZ("#tab-explorative")
Clone this wiki locally