karatelabs/karate · error · Error
Invalid ignore
Error message
Invalid ignore: ${ignore} What it means
resemble.compare() accepts an options.ignore string that selects which color channel comparison ignores. Only undefined, 'none', 'red', 'green', 'blue', 'alpha' are accepted; anything else hits the default branch and throws. It is a strict enum validation on the caller-supplied options object.
Solutions
- Use one of the exact values: undefined/'none', 'red', 'green', 'blue', 'alpha'
- Lowercase/trim the option value before passing it
- Validate options against the allowed set in your wrapper before calling compare
Example fix
// before
resemble.compare(a, b, { ignore: 'Alpha' }, cb);
// after
resemble.compare(a, b, { ignore: 'alpha' }, cb); Defensive patterns
Strategy: validation
Validate before calling
const ALLOWED = [undefined, 'none', 'red', 'green', 'blue', 'alpha'];
if (!ALLOWED.includes(options && options.ignore)) throw new Error('ignore must be one of ' + ALLOWED.join(', ')); Type guard
function isValidIgnore(v) { return v === undefined || ['none','red','green','blue','alpha'].includes(v); } Try / catch
try { resemble.compare(a, b, opts, cb); } catch (e) { if (String(e.message).startsWith('Invalid ignore:')) { opts.ignore = 'none'; resemble.compare(a, b, opts, cb); } else { throw e; } } Prevention
- Copy ignore values exactly from resemble's documented enum
- Normalize options.ignore with toLowerCase() before use
- Centralize compare() options in one validated helper
When it happens
Trigger: Calling resemble.compare(img1, img2, {ignore: 'transparency'}) or any misspelled channel name such as 'Alpha', 'redes', or 'colour' instead of the exact supported strings.
Common situations: Typos in ignore options, casing mistakes, or copying option values from a different diff library with richer enums.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Unable to resolve global `this`
- no such match api:
- karate-boot.js evaluation failed
- Dynamic expression must return a list or function
- Failed to evaluate dynamic expression
AI-assisted analysis of karatelabs/karate@a22eb90246 (2026-09-12).
Data as JSON: /api/errors/18c99613559fd461.
Report an issue: GitHub.
Appendix: source
Thrown at karate-image/src/main/resources/META-INF/karate-ext/static/resemble.js:1022
function applyIgnore(api, ignore, customTolerance) {
switch (ignore) {
case "nothing":
api.ignoreNothing();
break;
case "less":
api.ignoreLess();
break;
case "antialiasing":
api.ignoreAntialiasing();
break;
case "colors":
api.ignoreColors();
break;
case "alpha":
api.ignoreAlpha();
break;
default:
throw new Error("Invalid ignore: " + ignore);
}
api.setupCustomTolerance(customTolerance);
}
resemble.compare = function (image1, image2, options, cb) {
var callback;
var opt;
if (typeof options === "function") {
callback = options;
opt = {};
} else {
callback = cb;
opt = options || {};
}
var res = resemble(image1);View on GitHub (pinned to a22eb90246)