forked from fanruan/fineui
Zoupers
6 months ago
6 changed files with 232 additions and 3 deletions
@ -1,2 +1,2 @@ |
|||||||
puppeteer_download_host=https://npm.taobao.org/mirrors |
PUPPETEER_DOWNLOAD_BASE_URL=https://cdn.npmmirror.com/binaries/chrome-for-testing |
||||||
@fui:registry=https://npm.fineres.com/ |
@fui:registry=https://npm.fineres.com/ |
@ -0,0 +1,167 @@ |
|||||||
|
// Karma configuration
|
||||||
|
// Generated on Mon Nov 27 2017 11:16:26 GMT+0800 (中国标准时间)
|
||||||
|
|
||||||
|
const os = require("os"); |
||||||
|
const webpackConfig = require("./webpack/webpack.dev") |
||||||
|
|
||||||
|
process.env.CHROME_BIN = require("puppeteer").executablePath(); |
||||||
|
|
||||||
|
module.exports = function (config) { |
||||||
|
config.set({ |
||||||
|
|
||||||
|
// base path that will be used to resolve all patterns (eg. files, exclude)
|
||||||
|
basePath: "", |
||||||
|
|
||||||
|
|
||||||
|
// frameworks to use
|
||||||
|
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
|
||||||
|
frameworks: ["webpack", "mocha", "chai"], |
||||||
|
|
||||||
|
|
||||||
|
// list of files / patterns to load in the browser
|
||||||
|
files: [].concat( |
||||||
|
webpackConfig.entry.fineui, |
||||||
|
["test/**/*.js", "src/**/*.test.js"] |
||||||
|
), |
||||||
|
|
||||||
|
exclude: [ |
||||||
|
"src/base/tree/ztree/jquery.ztree.core-3.5.js", |
||||||
|
"src/base/tree/ztree/jquery.ztree.excheck-3.5.js", |
||||||
|
"src/base/single/input/file.js", |
||||||
|
"src/case/loading/loading_pane.js", |
||||||
|
"src/base/tree/ztree/**/*.js", |
||||||
|
"src/case/tree/ztree/*.js", |
||||||
|
"src/widget/multitree/**/*.js", |
||||||
|
"src/widget/multiselecttree/**/*.js", |
||||||
|
"src/component/treevaluechooser/*.js" |
||||||
|
], |
||||||
|
|
||||||
|
|
||||||
|
// preprocess matching files before serving them to the browser
|
||||||
|
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
|
||||||
|
preprocessors: { |
||||||
|
"src/less/**/*.less": ["webpack"], |
||||||
|
"ui/**/*.less": ["webpack"], |
||||||
|
"src/*.js": ["webpack"], |
||||||
|
"src/**/!(*.test).js": ["webpack"], |
||||||
|
}, |
||||||
|
|
||||||
|
|
||||||
|
// test results reporter to use
|
||||||
|
// possible values: 'dots', 'progress'
|
||||||
|
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
|
||||||
|
reporters: ["progress", "coverage", "html"], |
||||||
|
|
||||||
|
browserDisconnectTolerance: 3, |
||||||
|
browserDisconnectTimeout : 300000, |
||||||
|
browserNoActivityTimeout : 300000, |
||||||
|
|
||||||
|
coverageReporter: { |
||||||
|
// specify a common output directory
|
||||||
|
dir: "coverage/", |
||||||
|
reporters: [ |
||||||
|
// reporters not supporting the `file` property
|
||||||
|
{ type: "html", subdir: "report-html" }, |
||||||
|
{ type: "json-summary", subdir: "report-json-summary" }, |
||||||
|
{ type: "cobertura", subdir: "report-cobertura"} |
||||||
|
] |
||||||
|
}, |
||||||
|
|
||||||
|
htmlReporter: { |
||||||
|
outputFile: "logs/test-report.html" |
||||||
|
}, |
||||||
|
|
||||||
|
|
||||||
|
// web server port
|
||||||
|
port: 9878, |
||||||
|
|
||||||
|
|
||||||
|
// enable / disable colors in the output (reporters and logs)
|
||||||
|
colors: true, |
||||||
|
|
||||||
|
|
||||||
|
// level of logging
|
||||||
|
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
|
||||||
|
logLevel: config.LOG_INFO, |
||||||
|
|
||||||
|
loggers: [ |
||||||
|
{ |
||||||
|
type: "console" |
||||||
|
}, |
||||||
|
{ |
||||||
|
type: "file", |
||||||
|
filename: "logs/karma.log" |
||||||
|
} |
||||||
|
], |
||||||
|
|
||||||
|
|
||||||
|
// enable / disable watching file and executing tests whenever any file changes
|
||||||
|
autoWatch: true, |
||||||
|
|
||||||
|
// you can define custom flags
|
||||||
|
customLaunchers: { |
||||||
|
HeadlessChrome: { |
||||||
|
base: "ChromeHeadless", |
||||||
|
flags: [ |
||||||
|
"--no-sandbox", |
||||||
|
"--remote-debugging-port=9222", |
||||||
|
"--enable-logging", |
||||||
|
"--user-data-dir=./karma-chrome", |
||||||
|
"--v=1", |
||||||
|
"--disable-background-timer-throttling", |
||||||
|
"--disable-renderer-backgrounding", |
||||||
|
"--proxy-bypass-list=*", |
||||||
|
"--disable-web-security", |
||||||
|
"--disable-gpu", |
||||||
|
], |
||||||
|
}, |
||||||
|
ChromeDebug: { |
||||||
|
base: "Chrome", |
||||||
|
flags: [ |
||||||
|
"--no-sandbox", |
||||||
|
"--remote-debugging-port=9222", |
||||||
|
"--enable-logging", |
||||||
|
"--user-data-dir=./karma-chrome", |
||||||
|
"--v=1", |
||||||
|
"--disable-background-timer-throttling", |
||||||
|
"--disable-renderer-backgrounding", |
||||||
|
"--proxy-bypass-list=*", |
||||||
|
"--disable-web-security", |
||||||
|
"--disable-gpu", |
||||||
|
], |
||||||
|
}, |
||||||
|
}, |
||||||
|
|
||||||
|
// // start these browsers
|
||||||
|
// // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
|
||||||
|
browsers: [os.platform() === "win32" |
||||||
|
&& parseFloat(os.release() |
||||||
|
.split(".") |
||||||
|
.slice(0, 2) |
||||||
|
.join(".")) <= 6.1 |
||||||
|
? "HeadlessChrome" : "ChromeHeadless"], |
||||||
|
|
||||||
|
retryLimit: 30, |
||||||
|
|
||||||
|
captureTimeout: 30000, |
||||||
|
|
||||||
|
// Continuous Integration mode
|
||||||
|
// if true, Karma captures browsers, runs the tests and exits
|
||||||
|
singleRun: true, |
||||||
|
|
||||||
|
// Concurrency level
|
||||||
|
// how many browser should be started simultaneous
|
||||||
|
concurrency: Infinity, |
||||||
|
|
||||||
|
webpack: webpackConfig, |
||||||
|
|
||||||
|
plugins: [ |
||||||
|
"karma-webpack", |
||||||
|
"karma-mocha", |
||||||
|
"karma-chai", |
||||||
|
"karma-chrome-launcher", |
||||||
|
"karma-coverage", |
||||||
|
"karma-htmlfile-reporter", |
||||||
|
] |
||||||
|
}); |
||||||
|
}; |
@ -0,0 +1,3 @@ |
|||||||
|
while (BI.prepares && BI.prepares.length > 0) { |
||||||
|
BI.prepares.shift()() |
||||||
|
} |
@ -0,0 +1,45 @@ |
|||||||
|
BI.Test = {}; |
||||||
|
BI.extend(BI.Test, { |
||||||
|
createWidget: function (widgetJson) { |
||||||
|
var widget = BI.createWidget(BI.extend(widgetJson, { |
||||||
|
root: true |
||||||
|
})); |
||||||
|
widget.element.appendTo("body"); |
||||||
|
return widget; |
||||||
|
}, |
||||||
|
|
||||||
|
/** |
||||||
|
* 模拟一次输入框的keydown事件 |
||||||
|
*/ |
||||||
|
triggerKeyDown: function (element, value, keyCode, callback) { |
||||||
|
// keydown
|
||||||
|
var e = BI.$.Event("keydown"); |
||||||
|
e.keyCode = keyCode; |
||||||
|
element.trigger(e); |
||||||
|
|
||||||
|
// input
|
||||||
|
BI.isNotNull(value) && element.val(value); |
||||||
|
var e1 = BI.$.Event("input"); |
||||||
|
e1.originalEvent = {}; |
||||||
|
e1.keyCode = keyCode; |
||||||
|
element.trigger(e1); |
||||||
|
|
||||||
|
// keyup 至少等300ms后触发
|
||||||
|
var e2 = BI.$.Event("keyup"); |
||||||
|
e2.keyCode = keyCode; |
||||||
|
element.trigger(e2); |
||||||
|
BI.delay(function () { |
||||||
|
callback(); |
||||||
|
}, 300); |
||||||
|
}, |
||||||
|
|
||||||
|
/** |
||||||
|
* 模拟一次鼠标hover |
||||||
|
*/ |
||||||
|
triggerMouseover: function (element, callback) { |
||||||
|
// keydown
|
||||||
|
var e = BI.$.Event("mouseover"); |
||||||
|
element.trigger(e); |
||||||
|
callback && callback(); |
||||||
|
} |
||||||
|
}) |
Loading…
Reference in new issue