Stryker

readConfigStream.js - Stryker report

File / Directory
Mutation score
# Killed
# Survived
# Timeout
# No coverage
# Runtime errors
# Transpile errors
Total detected
Total undetected
Total mutants
readConfigStream.js
8.33 %
8.33 1 11 0 0 1 0 1 11 13
Expand all
const yaml = require('js-yaml')
const Joi = require('joi')
const schema = Joi.object().keys({
  juiceShopUrl: 0[Joi.string().uri().required(), Joi.string().ip().required()],
  ctfKey: Joi.string().required(),
  insertHints: Joi.any().valid('none', 'free', 'paid').required(),
  insertHintUrls: Joi.any().valid('none', 'free', 'paid').required()
})

const hintsMap = {'none': 0, 'free': 1, 'paid': 2}

function readConfigStream (stream) 1{
  return new Promise((resolve, reject) => 2{
    let data = ''
    stream.on('data', (chunk) => 3{
      data = 4data + chunk
    })
    stream.on('end', () => 5{
      try 6{
        yaml.safeLoadAll(data, (doc) => 7{
          const validation = Joi.validate(doc, schema)
          if (89validation.error) 10{
            reject(validation.error)
          } else 11{
            const result = validation.value
            result.insertHints = hintsMap[result.insertHints]
            result.insertHintUrls = hintsMap[result.insertHintUrls]
            resolve(result)
          }
        })
      } catch (error) 12{
        reject(error)
      }
    })
  })
}

module.exports = readConfigStream

# Mutator State Location Original Replacement
0 ArrayDeclarator RuntimeError 3 : 16 [ .... ()] []
1 BlockStatement Killed 11 : 35 { ...}) } { }
2 BlockStatement Survived 12 : 42 { ... } { }
3 BlockStatement Survived 14 : 33 { ... } { }
4 BinaryOperator Survived 15 : 13 + -
5 BlockStatement Survived 17 : 27 { ... } { }
6 BlockStatement Survived 18 : 10 { ... } { }
7 BlockStatement Survived 19 : 40 { ... } { }
8 RemoveConditionals Survived 21 : 14 .
9 RemoveConditionals Survived 21 : 14 .
10 BlockStatement Survived 21 : 32 { ... } { }
11 BlockStatement Survived 23 : 17 { ... } { }
12 BlockStatement Survived 30 : 22 { ... } { }