Skip to content

Commit

Permalink
fix for jUnit test.
Browse files Browse the repository at this point in the history
  • Loading branch information
konakonall committed Oct 26, 2020
1 parent 8c0920e commit 47b3367
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 5 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"express": "^4.16.4",
"qcloud-cos-sts": "^3.0.2",
"request": "^2.87.0",
"webpack": "^3.12.0"
"webpack": "^3.12.0",
"puppeteer": "^5.3.1"
}
}
7 changes: 3 additions & 4 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ var config = {
};
config.Uin = '10001';

QUnit.jUnitDone(function(report) {
console.log('[report]' + report.xml);
console.log('[finish]');
QUnit.done(function(details) {
console.log("[test-result]" + JSON.stringify(details));
});

var util = {
Expand Down Expand Up @@ -124,7 +123,7 @@ var getAuthorization = function (options, callback) {

// // 格式四、(不推荐,适用于前端调试,避免泄露密钥)前端使用固定密钥计算签名,通过 COS.getAuthorization 静态方法计算
// var authorization = COS.getAuthorization({
// SecretId: 'AKIDxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', // 可传固定密钥或者临时密钥
// SecretId: 'AKIDxxxxxxxxxxxx', // 可传固定密钥或者临时密钥
// SecretKey: 'xxx', // 可传固定密钥或者临时密钥
// Method: options.Method,
// Pathname: options.Pathname,
Expand Down
39 changes: 39 additions & 0 deletions test/watcher.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const puppeteer = require('puppeteer');

var fs = require('fs');
var util = require('util');

var logFile = fs.createWriteStream('log.txt', { flags: 'w' });
// Or 'w' to truncate the file every time the process starts.
var logStdout = process.stdout;

console.log = function () {
logFile.write(util.format.apply(null, arguments) + '\n');
logStdout.write(util.format.apply(null, arguments) + '\n');
}
console.error = console.log;

puppeteer.launch({
args: [
'--no-proxy-server',
]
}).then(function (browser) {
browser.newPage().then(function (page) {
page.on('console', function (msg) {
var text = msg.text();
var type = msg.type();
if (text.startsWith('[test-result]')) {
console.log('==[TESTING-ENDS]==')

const details = JSON.parse(text.replace('[test-result]', ''))
console.log(details)

browser.close()
} else {
console.log(msg)
}

});
page.goto(`http://127.0.0.1:3000/test`);
})
});

0 comments on commit 47b3367

Please sign in to comment.