idomatic reads the labels already in your code, like aria-label, placeholder and button text, and writes them into stable ids. On the web that's id; in SwiftUI, Flutter and Compose it's what their test tools look for. Ids you already have are never renamed.
npm init @idomaticidomatic checks these in order and uses the first one it finds. Two elements that end up with the same name get -2, -3 and so on.
Native code works the same way: .accessibilityLabel, a title, labelText or contentDescription, then the text.
These labels are also an element's accessible name. If something comes out as plain div, a screen reader probably can't describe it either. Check it in your browser's accessibility panel or the Accessibility Inspector.
<button aria-label="Submit login">button-submit-login<input name="email">input-email<input placeholder="Search">input-search<img alt="Team photo">img-team-photo<a title="Read more">a-read-more<h1>Sign in</h1>h1-sign-in<section>sectionPick yours to see what it scans, what it writes and what your test looks like. Every example is real output from the parsers.
Markup that helpers build at runtime, like Rails' link_to, isn't in the file, so add those ids by hand.
Also Preact, Next.js, Remix
npm init @idomatic and choose React (JS/TSX)..jsx.tsx.js.tsexport function LoginForm() {
return (
<form onSubmit={signIn} id="form">
<h1 id="h1-sign-in">Sign in</h1>
<input name="email" placeholder="Email" id="input-email" />
<button aria-label="Submit login" id="button-submit-login">Log in</button>
</form>
);
}await page.locator("#button-submit-login").click();Run it once to catch up, then let CI keep it that way. New elements get their ids in the same pull request that adds them.
Lists the files that would change. Touches nothing.
$ npx idomatic scan --dry
[Dry Run] Would update: src/Login.tsx
[Dry Run] Would update: ios/Login.swift
Adds the missing ids. A second run finds nothing to do.
$ npx idomatic scan --write
✅ Updated: src/Login.tsx
✅ Updated: ios/Login.swift
Fail CI when a new element ships without one.
# .github/workflows/ids.yml
- run: npx idomatic scan --write
- run: git diff --exit-code
No. Before writing, idomatic collects every id already in the file. Those are never renamed, and new ids never collide with them. Running it twice gives the same file.
Yes. Set "attributeName": "data-testid" in .idomatic.config.json, or data-cy, or anything else. In Playwright you then select with page.getByTestId("button-submit-login").
An element inside .map(), {#each} or {{#each}} is written once in the source, so every rendered copy shares one id. Scope it in your test, for example page.locator("#nav-main #a").nth(1).
Yes. In JSX, <Button> gets an id like any other element, so your component needs to pass it through to the element it renders. Add a component to excludeTags if it shouldn't get one.
Yes. React Native gets testID for Detox and Maestro. SwiftUI gets .accessibilityIdentifier for XCUITest, Flutter gets a Key for find.byKey, and Jetpack Compose gets Modifier.testTag for onNodeWithTag.
Markup that only exists at runtime, such as HTML built by a helper function or a component library. idomatic only sees what is written in your files.
Setup asks which framework you use, writes .idomatic.config.json and installs the right parser. Point excludeFiles at everything but one folder, run with --dry, and read the list.
npm init @idomatic