页面UI测试
配置
Usage: torch [options]
Options:
-h, --help output usage information
-V, --version output the version number
-C, --no-colors force disabling of colors
-O, --reporter-options <k=v,k2=v2,...> reporter-specific options
-R, --reporter <name> specify the reporter to use
-S, --sort sort test files
-b, --bail bail after first test failure
-g, --grep <pattern> only run tests matching <pattern>
-f, --fgrep <string> only run tests containing <string>
-i, --invert inverts --grep and --fgrep matches
-r, --require <name> require the given module
-s, --slow <ms> "slow" test threshold in milliseconds [75]
-t, --timeout <ms> set test-case timeout in milliseconds [2000]
-u, --ui <name> specify user-interface (bdd|tdd|exports)
--check-leaks check for global variable leaks
--compile compile with babel
--compilers <ext>:<module>,... use the given module(s) to compile files
--coverage report coverage
--debug enable Electron debugger on port [5858]; for --renderer tests show window and dev-tools
--globals <names> allow the given comma-delimited global [names]
--inline-diffs display actual/expected differences inline within each string
--interactive run tests in renderer process in a visible window that can be reloaded to re-run tests
--interfaces display available interfaces
--no-timeouts disables timeouts
--notify-on-fail notify on failures
--notify-on-success notify on success
--opts <path> specify opts path
--preload <name> preload the given script in renderer process
--recursive include sub directories
--renderer run tests in renderer process
--require-main <name> load the given script in main process before executing tests
--source-pattern <sources> glob pattern of source files
--watch watching source file changes
--watch-aggregate-timeout delay time for re-run test cases after files changed
使用 UITest
用法
直接引入 uitest-mocha-shim.js
文件即可在浏览器中运行。
<!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>
<script src="./node_modules/mocha/mocha.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>
在命令行里运行
Gulp
也可以通过 Gulp 引入:
$ npm i gulp-uitest --save-dev
- 更多关于 UITest
- 示例:
- 游戏框架Hilo测试示例: Hilo Game
- 游戏框架pillow测试示例:
- canvas框架monitor.js测试示例: Hilo Game