lightsoutAlpha

framework-basics

a component test importing the wrong testing library, extension or interaction helper for the package

Agent checkadvisory by defaultreacttests

The argument

Framework Basics

  • Import from @testing-library/react (React) or @testing-library/preact (Preact) — check the package's package.json; the API is identical.
  • Component test files use .unit.test.tsx (JSX requires .tsx), co-located with the component.
  • Framework route/page files never get co-located unit tests — they are thin wiring (guards, layout, a screen render) verified through e2e tests and the screen component's own tests.
  • Interactions use userEvent when the package depends on @testing-library/user-event (check its package.json); otherwise use fireEvent from the testing-library package. Never add the dependency yourself — that is the repo owner's decision, surfaced by lightsout doctor.

The proof

failsrc/routes/dashboard.route.unit.test.ts
import { expect, describe, test } from '@jest/globals';
import { DashboardRoute } from './dashboard.route';

// A route file is thin wiring covered by e2e tests and the screen component's
// own tests, and a component test cannot live in a .ts file at all.
describe('DashboardRoute', () => {
	test('is defined', () => {
		expect(DashboardRoute).toBeDefined();
	});
});
passsrc/notifications/NotificationBanner.unit.test.tsx
import { expect, describe, test } from '@jest/globals';
import { render, screen } from '@testing-library/react';
import { NotificationBanner } from './NotificationBanner';

const setupNotificationBanner = () => {
	render(<NotificationBanner message="Action required" />);
};

describe('NotificationBanner', () => {
	test('renders the notification message', () => {
		setupNotificationBanner();

		const message = screen.getByText('Action required');

		expect(message).toBeInTheDocument();
	});
});

Turn it down

Both lines go in your lightsout.config.json.

"standards-checks": { "framework-basics": "advisory" }
"standards-checks": { "framework-basics": "off" }