uitest
uitest
Last updated 5 months ago by xudafeng .
MIT · Repository · Bugs · Original npm · Tarball
$ cnpm install uitest 
SYNC missed versions from official npm registry.

uitest

NPM version build status Test coverage node version npm download

uitest framework for Node.js based on Macaca

Installation

$ npm i uitest --save-dev

Sample

uitest-sample

Usage

You should configure your entry HTML by including uitest-mocha-shim.js.

Here is an example test.html

<!DOCTYPE html>
<html>
  <head>
    <title>macaca mocha test</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="./node_modules/mocha/mocha.css" />
  </head>
  <body>
    <div id="mocha"></div>
    <script src="./node_modules/mocha/mocha.js"></script>
    <script src='./node_modules/uitest/uitest-mocha-shim.js'></script>
    <script src="./node_modules/should/should.js"></script>
    <script>
    _macaca_uitest.setup({
      ui: 'bdd',
      timeout: 5000,
      slow: 2000
    });
    </script>
    <script>
    describe('sample', function() {

      beforeEach('init', function() {
      });

      it('#case_1', function() {
      });

    });
    </script>
    <script>
    _macaca_uitest.run();
    </script>
  </body>
</html>

Node.js

Your can start uitest using Node API:

const uitest = require('uitest');

uitest({
  url: 'file:///Users/name/path/index.html',
  width: 600,
  height: 480,
  hidpi: false,
  useContentSize: true,
  show: false,
}).then(() => {
  console.log('uitest success')
}).catch(() => {
  console.log('uitest error')
});

Gulp

Or with Gulp:

$ npm i gulp-uitest --save-dev
const uitest = require('gulp-uitest');
//test
gulp.task('test', function() {
  return gulp
    .src('test/html/index.html')
    .pipe(uitest({
      width: 600,
      height: 480,
      hidpi: false,
      useContentSize: true,
      show: false,
    }));
});

Screenshots

_macaca_uitest.screenshot(name[String], cb[Function]);

Advanced

If you do not want the page to display in retina mode, set hidpi to false.

For more options, see Electron BrowserWindow options

License

The MIT License (MIT)

Maintainers (2)
Downloads
Today 0
This Week 0
This Month 9
Last Day 0
Last Week 3
Last Month 7
Dependencies (2)
Dev Dependencies (9)
Dependents (2)

Copyright 2014 - 2017 © taobao.org |