我正在使用一个使用量角器和javascript的自动化框架。我们正在使用winston进行日志记录。但是通过配置,我只能创建一个不断追加的.log文件。
var winston = require('winston');
winston.remove(winston.transports.Console);
winston.add(winston.transports.Console, { timestamp: true });
winston.add(winston.transports.File, { filename: 'test-basic.log' });
module.exports = winston;
我想要的是每个测试用例(如testcase1.log,testcase2.log)的.log文件,并使用日期时间作为追加器来创建新的每次。 我有办法吗?
答案 0 :(得分:0)
一个选项是在您的配置中创建您自己的茉莉花记者。每次测试开始时都会声明一个新的Winston文件,并在结束时完成。
jasmine.getEnv().addReporter({
jasmineStarted: function (options) {
console.log(`jas start: ${options}`);
},
suiteStarted: function (options) {
console.log(`suite start: ${options}`);
//start your log here.
},
specStarted: function (options) {
console.log(`spec start: ${options}`);
},
specDone: function (result) {
console.log(`spec done: ${result}`);
},
suiteDone: function (result) {
},
jasmineDone: async function (result) {
}
}
挂单
--- beforeLaunch
--- onPrepare
--- jasmineStarted (set in jasmine reporter)
--- beforeAll
--- suiteStarted (set in jasmine reporter)
--- specStarted (set in jasmine reporter)
--- beforeEach
+++ afterEach
+++ specDone (set in jasmine reporter)
+++ suiteDone (set in jasmine reporter)
+++ afterAll
+++ jasmineDone (set in jasmine reporter)
+++ onComplete
+++ afterLaunch