Giter Club home page Giter Club logo

amper's Introduction

Amper

asciicast Run with retries: asciicast

This is an experiment of testing with concurrent multiple webdriver instances running.
A mocha-like test framework is created to run the tests. However, it differs from Mocha in that all it() are treated as individual tasks and scheduled as soon as possible. Therefore, local variables inside describe would not work in our case. We only allow passing information from beforeEach() to it() and then to afterEach() through env object. Furthermore, nested describe is not currently supported...

How to run

Put your tests in spec/**/*.js.

yarn install-drivers # install drivers. Just run once at the very beginning
yarn # install packages (express, etc.)
yarn server # start server at localhost:8080, allowing accessing pages in pages/ folder
yarn start [--spec="file1,file2"] [--cap="firefox,chrome,safari"] # run tests, with given files and capabilities. Separate with comma

Tests should look like this:

const fs = require('fs');

describe('Test suite', () => {
  beforeEach((browser, env) => {
    env.data = 1;
  });

  afterEach((browser, env) => {
    expect(env.data).to.equal(1);
  });

  it('should take screenshot', async (browser, env) => {
    await browser.get('http://www.google.com/ncr');
    // save screenshot
    fs.writeFileSync(`screenshots.png`, await browser.takeScreenshot(), 'base64');
  });
});

To change the capability available (which browsers, how many), go to config.js and change there.

Custom Test Suite API

// Create a new suite. Suite name MUST be unique!
describe('suite name', () => {
  beforeEach((browser, env) => {}); // OPTIONAL Runs before each test unit. `env` is passed across beforeEach, it and afterEach
  afterEach((browser, env) => {}); // OPTIONAL Runs after each test unit. `env` is passed across beforeEach, it and afterEach
  it('test name', (browser, env) => {}) // A single test unit. `env` is passed across beforeEach, it and afterEach
    .timeout(1000) // OPTIONAL Set timeout for this single test (beforeEach and afterEach has their own timeout, inherited from suite)
  it.skip('skipped', (browser, env) => {}); // This test is skipped
  it.only('only', (browser, env) => {}); // Only run this test in the suite
}) // create a test suite
.timeout(1000) // OPTIONAL Set timeout for suite (will be applied to beforeEach, afterEach, and by default on all it() test units)

describe.skip('suite name', () => {}); // This suite is skipped
describe.only('suite name', () => {}); // This suite will be the only one to be run
describe.withCapabilities(['chrome'], 'suite name', () => {}); // This suite will only run under the specified capabilities (edit config.js for new ones)
describe.exceptForCapabilities(['mobile-chrome'], 'suite name', () => {}); // This suite will only run if current capabilities is not in specified capabilities
describe.onlyWithCapabilities(['chrome'], 'suite name', () => {}); // .only version of withCapabilities
describe.onlyExceptForCapabilities(['mobile-chrome'], 'suite name', () => {}); // .only version of exceptForCapabilities

Known issues

setTimeout would block process from ever exist or more... AVOID using it.

amper's People

Contributors

kevinkassimo avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

cvializ

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.