willWarn
Requests that [can-log/dev/dev.warn canDev.warn] track and notify about matching warnings.
dev.willWarn(expected, [fn])
Parameters
- expected
{String|Regexp}
:The warning message to check for
- fn
{function(String, Boolean)}
:an optional callback to fire on every warning; each call has the actual warning message and a Boolean indicating whether it was matched
Returns
{function}
:
A function that tears down the warning check and returns the number of matched warnings when called.
willWarn()
takes either a String or a RegExp as its expected
warning, and does a full, case-sensitive String
match in the case of a String, or a regex test in the case of a RegExp, for every warning logged through
[can-log/dev/dev.warn]. In addition, if fn
is provided, it is fired on every warning with the content
of the warning message and whether it matched expected
.
willWarn()
returns a teardown function, which must be called at least once to disable the tracking of the matched
warning. when called, the teardown function returns the number of times expected
was matched by a dev warning.
var dev = require('can-log/dev/dev');
var devHelpers = require('can-test-helpers/lib/dev');
var finishWarningCheck = devHelpers.willWarn("something evil", function(message, match) {
message; // -> "something evil"
match; // true
});
canDev.warn("something evil");
finishWarningCheck(); // -> 1