Completed
Push — master ( f2a0af...598926 )
by Fike
39s
created

test/support/setup.js   A

Complexity

Total Complexity 1
Complexity/F 1

Size

Lines of Code 15
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
nc 1
dl 0
loc 15
rs 10
c 1
b 0
f 0
wmc 1
mnd 0
bc 1
fnc 1
bpm 1
cpm 1
noi 0
1
/* global allure */
2
/* eslint-env mocha */
3
4
var AllurePolyfill = require('@ama-team/allure-polyfill')
5
var Sinon = require('sinon')
6
7
AllurePolyfill.ensure(new AllurePolyfill.sink.Console())
8
9
var logs = []
10
11
global.Logger = {
12
  write: Sinon.spy(function (message) {
13
    logs.push(message)
14
  })
15
}
16
17
beforeEach(function () {
18
  global.VarArgLogger = {}
19
  var methods = ['trace', 'debug', 'info', 'notice', 'warn', 'error']
20
  methods.forEach(function (method) {
21
    global.VarArgLogger[method] = function (pattern) {
22
      var message = pattern;
23
      [].slice.call(arguments, 1).map(JSON.stringify).forEach(function (_) {
24
        message = message.replace('{}', _)
25
      })
26
      global.Logger.write(message)
27
    }
28
  })
29
})
30
31
afterEach(function () {
32
  if (logs.length) {
33
    allure.createAttachment('voxengine.log', logs.join('\n'), 'text/plain')
34
    logs = []
35
  }
36
})
37