원클릭으로
tdd-workflow
Use this skill when writing new features, fixing bugs, or refactoring code. Enforces test-driven development.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Use this skill when writing new features, fixing bugs, or refactoring code. Enforces test-driven development.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
| name | tdd-workflow |
| description | Use this skill when writing new features, fixing bugs, or refactoring code. Enforces test-driven development. |
This skill ensures all code development follows TDD principles with comprehensive test coverage.
ALWAYS write tests first, then implement code to make tests pass.
Considering the purpose of the component and the properties it accepts, identify the user journeys it supports and various scenarios that could occur based on its features.
For each scenario or feature, create comprehensive test cases:
import { html } from 'lit';
import { fixture, expect } from '@open-wc/testing';
import './dt-search-component.js';
describe('DT-Search-Component', () => {
it('returns relevant results for query', async () => {
const el = await fixture(html`<dt-search-component></dt-search-component>`);
// Test implementation
// expect(el.results).to.have.lengthOf(5);
})
it('handles empty query gracefully', async () => {
const el = await fixture(html`<dt-search-component query=""></dt-search-component>`);
// Test edge case
})
it('is accessible', async () => {
const el = await fixture(html`<dt-search-component></dt-search-component>`);
await expect(el).shadowDom.to.be.accessible();
})
})
npm test
# Tests should fail - we haven't implemented yet
Write minimal code to make tests pass:
import { LitElement, html } from 'lit';
export class DtSearchComponent extends LitElement {
static properties = {
query: { type: String },
results: { type: Array }
};
render() {
return html`<div>...</div>`;
}
}
customElements.define('dt-search-component', DtSearchComponent);
npm test
# Tests should now pass
Improve code quality while keeping tests green:
// Don't test internal state
expect(component.__count).to.equal(5)
// Test what users see or public API
const input = el.shadowRoot.querySelector('input');
expect(input.value).to.equal('John Doe');
// Breaks easily
const button = el.shadowRoot.querySelector('.css-class-xyz')
// Resilient to changes
const button = el.shadowRoot.querySelector('button[type="submit"]')
const field = el.shadowRoot.querySelector('#main-input')
// Tests depend on each other
let sharedEl;
it('creates user', async () => { sharedEl = await fixture(html`<dt-user></dt-user>`) })
it('updates same user', async () => { /* depends on previous test */ })
// Each test sets up its own data/fixture
it('creates user', async () => {
const el = await fixture(html`<dt-user></dt-user>`)
// Test logic
})
it('updates user', async () => {
const el = await fixture(html`<dt-user></dt-user>`)
// Update logic
})
npm test:watch
# Tests run automatically on file changes
--coverage flag)Remember: Tests are not optional. They are the safety net that enables confident refactoring, rapid development, and production reliability.