Scaffolds unit tests and screenshot tests to establish visual and functional rendering baselines for views before refactoring.
73%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Passed
No findings from the security scan
Fix and improve this skill with Tessl
tessl review fix ./.agents/skills/ui-eng-vision-test-scaffolder/SKILL.mdThis subskill establishes the safety net of existing and new visual/functional tests before any codebase modifications occur, ensuring that no rendering or logical regressions are introduced during modernization.
Verify Existing Tests:
front_end/**/*.test.ts (for example,
front_end/panels/application/IndexedDBViews.test.ts for
IndexedDBViews.ts).assertScreenshot(...) golden tests in the co-located
*.test.ts file (with Linux golden PNGs under test/goldens/linux/) and
full-browser E2E tests under test/e2e/ to verify layout and styling.Detect Sub-component Testing Gaps (Hybrid Files):
IDBDatabaseView but are scarce/missing for IDBDataView).Scaffold Missing Tests:
If logic tests are missing, draft tests verifying that callbacks trigger the expected state updates or model interactions.
If rendering/screenshot tests are missing or inadequate for the legacy class being migrated, draft a basic Mocha/Chai rendering test.
Verify that the component compiles and mounts successfully inside a synthetic DOM helper or unit-test container.
Screenshot Tests: Create screenshot tests to establish visual baselines before refactoring. Follow the pattern seen in CategorizedBreakpointsSidebarPane.test.ts:
First run the test having renderElementIntoDOM with {includeCommonStyles: true} to ensure styles are applied.
The first run will generate the screenshot.
Now try removing {includeCommonStyles: true} to see if class is
adding the styles itself. If the test pass, keep the version without
{includeCommonStyles: true}. Otherwise, bring it back.
Screenshot tests are unittests that render either the full widget (if not migrated to the MVP architecture) or its view function (if already in MVP shape).
Ship unit tests in the same CL as the production code they cover; never defer tests to a follow-up test-only CL.
Test presenter logic via createViewFunctionStub and rely on assertScreenshot / E2E tests for template layout (per docs/ui_engineering.md). When adding targeted unit tests for view rendering, name the suite describe('view', ...) (never describe('... DEFAULT_VIEW', ...)), and avoid verbose synthetic DEFAULT_VIEW DOM assertion suites that duplicate presenter assertions.
Example structure:
describe('view', () => {
it('renders the base state', async () => {
const target = document.createElement('div');
target.style.width = '600px';
target.style.height = '400px';
renderElementIntoDOM(target, {includeCommonStyles: true});
MyComponent.DEFAULT_VIEW(mockViewInput, undefined, target);
await assertScreenshot('my_component/base.png');
});
});Keep assertScreenshot Containers Within Karma's Iframe Viewport:
Prefer 600x400 for compact component views (and <= 600px tall,
such as 800x600, for full panels or split views) so containers fit
inside Karma's ~685px-tall test iframe without triggering and
capturing Karma's outer iframe scrollbar.
Pass document.createElement('devtools-widget') for @scope (devtools-widget) Light DOM Widgets:
new MyWidget() defaults this.element to <div class="widget">
rather than <devtools-widget>. When testing a Light DOM widget
whose stylesheet uses an explicit @scope (devtools-widget) root,
instantiate new MyWidget(document.createElement('devtools-widget'))
(or mount via UI.Widget.widget(...)) so @scope rules match.
Direct DEFAULT_VIEW Tests Hosting <devtools-split-view> or WrapperWidget:
When calling DEFAULT_VIEW(input, output, target) directly for views
that render <devtools-split-view>, UI.Widget.WrapperWidget, or
imperatively attached child widgets:
UI.Widget.VBox (const container = renderElementIntoDOM(new UI.Widget.VBox()).contentElement;)
instead of a plain document.createElement('div'), otherwise
widgetCounterMap underflows during cleanTestDOM() and throws
Attempt to modify widget with native DOM method removeChild.UI.Widget.Widget instances (such as
new UI.Widget.VBox()) instead of
sinon.createStubInstance(MyWidget) (which stubs constraints()
to return undefined and throws on mount).UI.Widget.Widget.get(container)?.detachChildWidgets()
before teardown when child widgets are attached imperatively.Implementation-Decoupled Helpers & Screenshot Baselines Before Replacing Legacy Widgets:
When scaffolding unit tests ahead of replacing a legacy widget engine
(TreeOutline, DataGrid, ListControl, ListWidget):
dumpTree(),
findTreeItem(), activateRow(), openContextMenuOnRow()) rather
than scattering direct internal widget queries across every it()
block. When the legacy widget is subsequently swapped for
<devtools-tree> or <devtools-data-grid>, only the helper
implementations change while dozens of tests remain untouched.assertScreenshot(...) golden tests covering critical visual
states (grouping modes, icons/badges, dimmed/dirty states). Unit
tests often inspect internal state that changes during migration;
screenshot goldens ensure the user-visible UI remains identical.Wait for confirmation:
Always detect the execution environment first to run tests successfully:
Detection: Triggered if the workspace path starts with /google/cog/ or
/google/src/.
Execution Guide: Follow devtools-verification.
Resolution Steps:
Ensure depot_tools is at the front of your PATH:
export PATH="/path/to/depot_tools:$PATH"Execute tests using ./dt test directly from chromium/third_party/devtools-frontend/src:
./dt test front_end/panels/application/IndexedDBViews.test.tsDetection: Triggered if in an open-source or local standard Chromium checkout without Cog paths.
Troubleshooting vpython3 / depot_tools errors:
Symptom: Command fails with vpython3: command not found or
python3_bin_reldir.txt not found.
Resolution Steps:
Export depot_tools path:
export PATH="/path/to/depot_tools:$PATH"Initialize the depot_tools binaries by running update/gclient help once from the checkout root:
update_depot_toolsExecute the tests:
./dt test front_end/panels/application/IndexedDBViews.test.tsSymptom: Running lint checks fails with: TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for scripts/eslint_rules/...
Resolution Steps:
Compile the custom eslint rules and build assets first so that Node can parse the rules:
./dt builddiv -> span).{includeCommonStyles: true}.describe vs describeWithEnvironment)Do not use describeWithEnvironment or describeWithMockConnection in new or migrated unit tests. Use plain describe (from 'mocha') with TestUniverse and modular setup hooks (setupLocaleHooks(), setupSettingsHooks(), setupRuntimeHooks(); see foundation-test-migration).
Always reset singleton registries in afterEach:
When registering actions, shortcuts, or context menus in tests, singleton registries MUST be reset in afterEach:
afterEach(() => {
UI.ActionRegistration.reset();
UI.ActionRegistry.ActionRegistry.reset();
UI.ShortcutRegistry.ShortcutRegistry.removeInstance();
});Without these resets, repeated runs (such as --repeat=10 or CQ flake detection) will fail on iteration 2+ with Duplicate action ID: '...'.
GlassPane Container Setup:
If testing UI that opens a GlassPane or long-press option menu (e.g. bindToAction with long-press buttons) in a test suite using describe without describeWithEnvironment, call:
beforeEach(() => {
UI.GlassPane.GlassPane.setContainer(document.body);
});Otherwise, menu rendering will fail because GlassPane lacks an attached container element.
Drain RenderCoordinator in afterEach for Nested Dialog Components:
When a mounted panel or widget instantiates components that chain 3+ nested ScheduledRender passes (such as <devtools-shortcut-dialog> or <devtools-perf-export-trace-options> -> ButtonDialog -> Dialog), call await RenderCoordinator.done() after detach() in afterEach. Synchronous 0ms tests otherwise exceed checkForPendingActivity's retry budget under --repeat=10 CQ flake detection.
Advance Fake rAF (+16ms) After Timer-Triggered requestUpdate() Under sinon.useFakeTimers():
UI.Widget.prototype.requestUpdate() schedules performUpdate() on fake window.requestAnimationFrame (+16ms). Advance an additional animation frame (await clock.tickAsync(16) or clock.tick(16)) after fake-timer callbacks that trigger requestUpdate() (for example, clock.tick(300) for a popover delay) before asserting, before the test finishes when suite-level afterEach hooks reset state ahead of test_setup.ts (which otherwise drains and restores fake timers automatically, while @devtools/no-manual-sinon-restore forbids .restore() in after/afterEach), and before any mid-test clock.restore().
Before reporting back or committing, re-read the instructions and verify:
ChromeDevTools/devtools-frontend
9d90722
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.