Package io.karatelabs.core
Class ReportAssets
java.lang.Object
io.karatelabs.core.ReportAssets
Imperative spec for one ext's report-asset contribution, built fluently inside
Ext.onBoot(Suite) and handed to
Suite.registerReportAssets(ReportAssets, ClassLoader) (see EXT.md § Report assets).
There is deliberately no manifest.json — the ext object is already live
at onBoot, so asset wiring is declared in one place (Java), type-safe, with
no JSON-vs-file drift. getManifest() on Ext still carries the
SUITE_ENTER metadata; this type carries only what the report writer needs.
suite.registerReportAssets(
ReportAssets.named("image")
.js("static/ext.js")
.css("static/ext.css")
.page("nav.pages", "Image diffs", "pages/image-comparison.html"),
getClass().getClassLoader());
There is no core-version guard here yet (D8's strict-match) — exts ship in lockstep with core for now; revisit if independently-versioned drop-in JARs make a mismatch likely.
Asset paths are resolved against BASE on the ext's classloader, so a
.js("static/ext.js") reads META-INF/karate-ext/static/ext.js and is
copied to target/karate-reports/ext/<name>/ext.js (the static/ prefix
is stripped for the web path; pages/ is kept).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordOne nav-page (or other slot) contribution. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionAdd an extra static file copied verbatim toext/<name>/(e.g. a vendored library the JS loads at runtime, likestatic/resemble.js).voidCopy the declared assets (JS, optional CSS, page HTML) intoextDir(target/karate-reports/ext/<name>/).Optional stylesheet, loaded if set.cssHref()Web-relative path of the CSS,static/stripped; null when no CSS.Override the report's top-bar call-to-action.ctaHref()The ext-supplied CTA href, or null if this ext registered none.ctaLabel()The ext-supplied CTA label, or null if this ext registered none.The JS entry registered inalpine:init(D5).jsHref()Web-relative path of the JS entry,static/stripped.name()static ReportAssetsStart a spec for the ext registered undername.Add a slot page contribution (e.g.pages()
-
Field Details
-
BASE
Resource root inside an ext JAR for all asset paths in this spec.- See Also:
-
-
Method Details
-
named
Start a spec for the ext registered undername. -
js
The JS entry registered inalpine:init(D5). Required. -
css
Optional stylesheet, loaded if set. -
page
Add a slot page contribution (e.g.nav.pages). -
cta
Override the report's top-bar call-to-action. Core pages ship a default "Try Karate Enterprise" upsell; an ext (e.g. a licensed product) can replace it with its own subtle link — the report then signals which product produced it rather than pitching an upgrade. The first ext to register a CTA wins (HtmlReportWriter.buildCtaHtml);labelis the button text,hrefits target. -
asset
Add an extra static file copied verbatim toext/<name>/(e.g. a vendored library the JS loads at runtime, likestatic/resemble.js). Not auto-injected into the page — the ext's own JS references it by its report-relative URL. -
name
-
pages
-
jsHref
Web-relative path of the JS entry,static/stripped. -
cssHref
Web-relative path of the CSS,static/stripped; null when no CSS. -
ctaLabel
The ext-supplied CTA label, or null if this ext registered none. -
ctaHref
The ext-supplied CTA href, or null if this ext registered none. -
copyTo
Copy the declared assets (JS, optional CSS, page HTML) intoextDir(target/karate-reports/ext/<name>/).static/prefixes are stripped sostatic/ext.jslands at<extDir>/ext.js; pages keep theirpages/prefix.- Throws:
IOException
-