Migrate chromium test

From ChromeDevTools/devtools-frontend · View interactive version

Migrate chromium test is an AI agent skill from the GitHub repository ChromeDevTools/devtools-frontend. Use when migrating Chromium layout tests to DevTools unit tests or API tests.

How to use this skill

Skill file

Workflow

1. Identify the Test to Move

2. Determine Target Location & Test Suite Type

Investigate what files are being tested, start location should be front_end/.Consult the devtools-testing-guidance skill to select the appropriate test suite.

3. Convert the Test Content

4. Update BUILD.gn Configuration

Every newly created test file must be added to the appropriate target in its folder's BUILD.gn:

[!IMPORTANT]

If you omit the test file from BUILD.gn, the test target will not be compiled by Ninja and will be skipped by test runners.

When adding a brand-new unittests, foundation_unittests, or api_tests target in a subdirectory BUILD.gn, also wire it into the matching root group(...) in front_end/BUILD.gn (see devtools-testing-guidance).

5. Verify the Changes

Use the devtools-verification skill to build and verify your changes.

6. Evaluate Test Completeness and Utility

7. Upload the CL

Follow the devtools-version-control skill when uploading CLs.

Follow the following format and constraints:

Example commit message:

[test-migration] Migrate console-eval-global test to unit test

This CL migrates the legacy layout test
http/tests/devtools/console/console-eval-global.js to a unit test in
ConsolePrompt.test.ts. It verifies that the evaluation in ConsolePrompt
is performed in the correct execution context (the active one) and with
the correct expression.

https://crsrc.org/c/third_party/blink/web_tests/http/tests/devtools/console/console-eval-global.js;drc=4d51e9cab50efd0f8029c45a486e199a1d519fd1

Bug: <issue number>
Ai-Assisted: true

Conversion Examples

Example 1: UI Unit Test (`DataGrid.test.ts`)

Legacy Test (`datagrid-editable-longtext.js`)
import {TestRunner} from 'test_runner';
import * as DataGrid from 'devtools/ui/legacy/components/data_grid/data_grid.js';

(async function () {
  TestRunner.addResult('This tests long text in datagrid.');
  // ... setup grid ...
  TestRunner.addResult('Original lengths');
  // ... dump results ...
  TestRunner.completeTest();
})();
Converted UI Test (`DataGrid.test.ts`)
import {assert} from 'chai';
import {describe, it} from 'mocha';

import {renderElementIntoDOM} from '../../../../testing/DOMHelpers.js';
import {setupLocaleHooks} from '../../../../testing/LocaleHelpers.js';

import * as DataGrid from './data_grid.js';

describe('DataGrid', () => {
  setupLocaleHooks();

  it('tests long text in datagrid', () => {
    // ... setup grid ...
    const grid = new DataGrid.DataGrid.DataGridImpl({...});
    renderElementIntoDOM(grid.element);

    // Use Chai assertions instead of printing results.
    assert.strictEqual(keyElement.textContent.length, 1500);
  });
});

Tips & Troubleshooting


After Finishing the Migration

If you encountered any novel issues, workarounds, or helpful tips during the migration that are not already documented, please inform the user so the skill documentation can be further updated.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.