UNPKG

520 BJavaScriptView Raw
1import config from './config'
2
3export default {
4 warn (func, msg, url) {
5 if (!config().ignoreWarnings && typeof console === 'object' && console.warn) {
6 console.warn(`Warning: testdouble.js - ${func} - ${msg}${withUrl(url)}`)
7 }
8 },
9
10 error (func, msg, url) {
11 if (!config().suppressErrors) {
12 throw new Error(`Error: testdouble.js - ${func} - ${msg}${withUrl(url)}`)
13 }
14 },
15
16 fail (msg) {
17 throw new Error(msg)
18 }
19}
20
21var withUrl = (url) =>
22 url != null
23 ? ` (see: ${url} )`
24 : ''