| name | pool-test |
| description | Write unit tests for pool commands following project patterns. |
Pool Test Skill
Use this skill when writing unit tests for a pool:* command.
Steps
- Create the test file at
test/commands/pool/<name>.test.ts
- Follow the sandbox pattern — use
TestContext and stubSfCommandUx
- Run tests —
pnpm run test:only
- Check coverage — review nyc output for uncovered branches
Test Template
import { TestContext } from '@salesforce/core/testSetup';
import { expect } from 'chai';
import { stubSfCommandUx } from '@salesforce/sf-plugins-core';
import <Name> from '../../../../src/commands/pool/<name>.js';
describe('pool <name>', () => {
const $$ = new TestContext();
let sfCommandStubs: ReturnType<typeof stubSfCommandUx>;
beforeEach(() => {
sfCommandStubs = stubSfCommandUx($$.SANDBOX);
});
afterEach(() => {
$$.restore();
});
it('returns expected result', async () => {
const result = await <Name>.run(['--target-dev-hub', 'test@hub.org']);
expect(result).to.exist;
});
it('handles missing config gracefully', async () => {
try {
await <Name>.run(['--target-dev-hub', 'test@hub.org']);
expect.fail('should have thrown');
} catch (err) {
expect(err).to.have.property('name', 'SfError');
}
});
});
What to Test
- Happy path — command returns typed result with correct data
- Flag validation — required flags reject missing input
- Error cases — bad config, missing org, expired credentials → SfError
- Output — verify
sfCommandStubs.log contains expected messages
- Edge cases — empty pools, zero count, concurrent access
Acceptance Criteria