Write unit tests for pool commands following project patterns.
Use this skill when writing unit tests for a pool:* command.
test/commands/pool/<name>.test.tsTestContext and stubSfCommandUxpnpm run test:onlyimport { 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 () => {
// arrange: stub org connections, config reads, etc.
// act
const result = await <Name>.run(['--target-dev-hub', '[email protected]']);
// assert
expect(result).to.exist;
});
it('handles missing config gracefully', async () => {
try {
await <Name>.run(['--target-dev-hub', '[email protected]']);
expect.fail('should have thrown');
} catch (err) {
expect(err).to.have.property('name', 'SfError');
}
});
});
sfCommandStubs.log contains expected messagesTestContext sandbox (no real org calls)CommandClass.run([...args])pnpm run test:only passes