- Home
- Skills
- Code Quality & Review
- JS Method Body Test
JS Method Body Test
Extract JavaScript method bodies for static Python testing using indentation-aware string slicing.
$5
Works with the AI tools you already use
JS Method Body Test
Example session with this skill installed
Write a pytest to check if the _onDrop method in app.js calls event.preventDefault(). The file uses 4-space indentation.
- Read your context and instructions
- Compiled the js method body
Method: CSS Anchor Slicing
def test_onDrop_calls_preventDefault():
from pathlib import Path
js = Path("app.js").read_text(encoding="utf-8")
sig = "_onDrop(event)"
sig_idx = js.find(sig + " {")
body_start = sig_idx + len(sig) + 2
body = js[body_start:js.find("\n },\n", body_start)]
assert "event.preventDefault()" in body
Expected outcome: Pass if the call exists.
Why it works: Uses the \n },\n anchor to isolate the method body.
Connects securely to your tools. The creator never sees your data.
What you get
About this skill
The problem
Python developers need to verify JavaScript function internals in pytest suites without the overhead of a Node.js runtime or complex AST parsers. Conventional regex approaches frequently fail on nested objects, template strings, or HTML attributes containing method signatures.
What it does
- Extracts JavaScript or TypeScript method bodies using indentation-aware string slicing.
- Detects file indentation styles (2-space, 4-space, or tabs) to identify function boundaries accurately.
- Avoids false positives from method names appearing inside strings or comments.
- Handles nested object literals and if-blocks that typically break standard regex patterns.
- Generates self-contained pytest functions for static source code assertions.
Frameworks & tools
Python, pytest, JavaScript, TypeScript.
Why this beats prompting it yourself
Writing reliable code-slicing logic manually is error-prone due to edge cases like trailing commas and varied indentation styles. This skill provides a specialized, tested algorithm that handles these boundaries out of the box without requiring heavy external dependencies like Esprima or Acorn.
Use cases
- Verify that a specific JS event handler calls a required API like
setData. - Ensure a legacy JS file contains necessary cleanup logic in a specific method.
- Audit source code for the presence of specific keywords within a restricted function scope.
- Perform fast, static validation of frontend logic inside a backend CI pipeline.
Known limitations
Requires consistent indentation patterns to identify method boundaries. It will not work on minified code or files with inconsistent spacing.
How to install
Works the same in every agent - Claude, Cursor, Codex, Copilot and 20+ more.
- 1
Download the ZIP
Free skills download straight away. Paid skills unlock right after purchase.
- 2
Unzip into your skills folder
Every agent reads skills from one folder on your machine. Drop the unzipped folder in there.
- 3
Ask your agent to use it
Restart the agent if it was already running. It picks the skill up automatically - no config needed.
Skills folder by agent
Click the path to copy it. Create the folder if it does not exist yet.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill passes our trust checks below.
Security scanned
Passed our 8-point scan before listing
Fresh listing
Recently published to Agensi
30-day refund
Not a fit? Get your money back
Trust & safety
Security scanned
Verified clean 1 month ago
- Passed all security checks, Safe to install