oversized-setup-factory
a setup factory grown past its parameter cap
Deterministic checkadvisory by defaultbasetests
The argument
- One factory configures any number of mocks — a single factory call is the whole arrangement; variants come from parameters.
- A single explicit override is allowed for the one variable a test varies (
setupAvatar()then onemockReturnValueline). - Keep a factory from sprawling. A substantially different arrangement gets a second named factory (
setupEmployee), rather than another parameter on the first one.
The proof
failsubject.unit.test.ts
import { expect, describe, test } from '@jest/globals';
import { renderInvoice } from './renderInvoice';
const setupInvoice = ({
customer = 'Ada',
currency = 'USD',
amount = 100,
discount = 0,
taxRate = 0,
isPaid = false,
issuedOn = '2026-01-01',
}: {
customer?: string;
currency?: string;
amount?: number;
discount?: number;
taxRate?: number;
isPaid?: boolean;
issuedOn?: string;
} = {}) => {
return { customer, currency, amount, discount, taxRate, isPaid, issuedOn };
};
describe('renderInvoice', () => {
test('names the customer it was built for', () => {
const invoice = setupInvoice({ customer: 'Ada' });
const rendered = renderInvoice(invoice);
expect(rendered).toContain('Ada');
});
});
passsubject.unit.test.ts
import { expect, describe, test } from '@jest/globals';
import { renderInvoice } from './renderInvoice';
const setupInvoice = ({
customer = 'Ada',
currency = 'USD',
amount = 100,
discount = 0,
taxRate = 0,
isPaid = false,
}: {
customer?: string;
currency?: string;
amount?: number;
discount?: number;
taxRate?: number;
isPaid?: boolean;
} = {}) => {
return { customer, currency, amount, discount, taxRate, isPaid };
};
describe('renderInvoice', () => {
test('names the customer it was built for', () => {
const invoice = setupInvoice({ customer: 'Ada' });
const rendered = renderInvoice(invoice);
expect(rendered).toContain('Ada');
});
});
Its numbers
The defaults the pack ships. A repo may set its own.
- maxParams
- 6
{
"standards-checks": {
"oversized-setup-factory": {
"settings": {
"maxParams": 6
}
}
}
}Turn it down
Both lines go in your lightsout.config.json.
"standards-checks": { "oversized-setup-factory": "advisory" }"standards-checks": { "oversized-setup-factory": "off" }