Skip to content
Back to skills

Helpers

ASecurity

Use when adding a reusable plain function under helpers/**, wiring the auth bootstrap in tests/{area}/*.setup.ts, or deciding whether reusable code is a helper or a fixture. Not for fixtures with a setup/use/teardown lifecycle (see `fixtures`) or the helper-fixture promotion threshold (see `api-testing`).

  • 312 stars
  • 0 votes
  • 0 copies
  • 6 views
  • Added September 22, 2026
testingtypescripttestingapi

Works with

  • api

Security analysis

A100/100

Scanned November 29, 2026

npx -y skills add idavidov13/agentic-playwright --skill helpers --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Helpers?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Helpers
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/idavidov13-helpers/badge)](https://www.skillsdirectory.com/skills/idavidov13-helpers)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: helpers
description: Use when adding a reusable plain function under helpers/**, wiring the auth bootstrap in tests/{area}/*.setup.ts, or deciding whether reusable code is a helper or a fixture. Not for fixtures with a setup/use/teardown lifecycle (see `fixtures`) or the helper-fixture promotion threshold (see `api-testing`).
---

# Helpers

## Critical

- A helper is a plain exported function with no Playwright lifecycle: no `base.extend`, no `use()`. Code that must run before and after each test is a fixture (`fixtures`).
- App-specific helpers live in `helpers/{area}/`, generic utilities in `helpers/util/`; extend the existing file of the same domain before creating one, never a new top-level folder.
- Every exported helper has an explicit return type, typed parameters and a JSDoc block with `@param` and `@returns`; names are camelCase verbs (`createAppStorageState`, `formatDate`).

    ```typescript
    // CORRECT
    /**
     * @param value - Epoch milliseconds or a date string.
     * @returns The date formatted for en-US.
     */
    export function formatDate(value: number | string): string {
        return new Date(value).toLocaleDateString('en-US');
    }
    // WRONG
    export const formatDate = (value) => new Date(value).toLocaleDateString();
    ```

- URLs, credentials and tokens come from `process.env.*` (`config`); endpoint and storage-state paths from `enums/{area}/*` (`enums`); never a literal.
- A helper that calls the API takes `apiRequest` as a parameter and asserts the body with `expect(SchemaName.parse(body)).toBeTruthy();` (`api-testing`).
- `process.env` is written only by the auth bootstrap in `helpers/{area}/createStorageState.ts`; every other helper returns its result through its signature.

## Procedure

1. Classify: no lifecycle → helper; setup → `use()` → teardown → `fixtures`; locators and interactions on a page → `page-objects`; one API call in one test → `apiRequest` inline; happy-path data → `data-strategy`. `ls helpers/` resolves `{area}`.
2. Pick the file: `helpers/{area}/<domain>.ts` for app logic, `helpers/util/util.ts` for a generic utility.
3. Write the function with its signature and JSDoc, sources per Critical; auth work follows `references/auth-bootstrap.md`.
4. Call it from the setup spec, a test, a hook or a fixture; run `npx tsc --noEmit`, `npm run lint` and the consuming tests.

## References

- `references/auth-bootstrap.md`: open when touching `tests/{area}/*.setup.ts` or the token and storage-state chain, or when `process.env.ACCESS_TOKEN` is `undefined` in a test.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in testing →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.