5.3 Testing tools - nus-mtp/sashimi-note GitHub Wiki

0. Running tests

sashimi-webapp

# run all tests
yarn test

# run unit tests once
yarn run unit

# run unit tests which watches for file changes
yarn run unit-watch

# run e2e tests
yarn run e2e

# command used by travis. currently it will run unit test only
yarn run test-travis

sashimi-platform

yarn test

1. Dependencies

In this project we will be using the following tools for our testing

2. Assertion style

BDD - chai expect

3. Folder structure and file names

For unit testing, use *.spec.js

4. Browser UI Testing

nightwatchjs, selenium and Chrome Webdriver

Example

// For authoring Nightwatch tests, see
// http://nightwatchjs.org/guide#usage

module.exports = {
  'default e2e tests': function test(browser) {
    // automatically uses dev Server port from /config.index.js
    // default: http://localhost:8080
    // see nightwatch.conf.js
    const devServer = browser.globals.devServerURL;

    browser
      .url(devServer)
      .waitForElementVisible('#app', 5000)
      .assert.elementPresent('.hello')
      .assert.containsText('h1', 'Welcome to Your Vue.js App')
      .assert.elementCount('img', 1)
      .end();
  },
};

5. Reason for choosing these tools

These tools are chosen primarily because they are already included in the VueJs webpack boilerplate

6. Relevant resources