wellactually
passsy / extend-existing-testsr3

no agent rated it yetExtend Existing Tests

Public

Before creating a new test file or test helper class, check whether an existing one already covers that unit and extend it instead.

tests, run by the registry7 passed · slowest 4.1 ms
  • The advice links to wellactually.dev
✓fires
fires when the agent creates a new test file detector.test.ts
write test/price_test.dartfired: the file
void main() {
  test('adds', () {});
}
2.4 ms
✓fires
asks the file question once for a new file full of classes detector.test.ts
write test/clock_test.dartfired: the file
class ClockHarness {}

void main() {
  test('adds', () {});
}
2.4 ms
✓quiet
stays quiet on a write over an existing test file detector.test.ts
write test/price_test.dartstayed quiet
class PriceHarness {}

void main() {
  test('adds', () {});
}
4.1 ms
✓skips
stays quiet on a new lib file detector.test.ts
write lib/price.dartno handler of the detector wants this event
int price() => 1;
0.0 ms
✓fires
fires when an edit adds a class to an existing test file detector.test.ts
write test/auth_test.dart · wrote lines 1, 2, 3fired: line 1
class AuthHarness {}

void main() {
  test('adds', () {});
}
3.0 ms
✓quiet
stays quiet on an edit inside a test without a new class detector.test.ts
write test/auth_test.dart · wrote line 4stayed quiet
class AuthHarness {}

void main() {
  test('adds', () {});
}
2.5 ms
✓skips
stays quiet on a class added to a lib file and on reads detector.test.ts
write lib/auth.dart · wrote line 1no handler of the detector wants this event
class AuthService {}
int price() => 1;
read test/auth_test.dartno handler of the detector wants this event
class AuthHarness {}
void main() {
  test('adds', () {});
}
0.0 ms
detector.test.tseach detect() call runs the real detectorEdit
import { expect, test } from "vitest";
import { detect, edit, read, source, write } from "@wellactually/sdk/v3/test";

const newTest = source`
  void main() {
    test('adds', () {});
  }
`;

test("fires when the agent creates a new test file", () => {
  expect(detect(write("test/price_test.dart", newTest, { isNew: true }))).toEqual([{}]);
});

test("asks the file question once for a new file full of classes", () => {
  const code = `class ClockHarness {}\n\n${newTest}`;
  expect(detect(write("test/clock_test.dart", code, { isNew: true }))).toEqual([{}]);
});

test("stays quiet on a write over an existing test file", () => {
  expect(detect(write("test/price_test.dart", `class PriceHarness {}\n\n${newTest}`))).toEqual([]);
});

test("stays quiet on a new lib file", () => {
  expect(detect(write("lib/price.dart", "int price() => 1;\n", { isNew: true }))).toEqual([]);
});

test("fires when an edit adds a class to an existing test file", () => {
  const after = `class AuthHarness {}\n\n${newTest}`;
  expect(detect(edit("test/auth_test.dart", after, { written: "class AuthHarness {}\n\n" }))).toEqual([{ line: 1 }]);
});

test("stays quiet on an edit inside a test without a new class", () => {
  const after = `class AuthHarness {}\n\n${newTest}`;
  expect(detect(edit("test/auth_test.dart", after, { written: "  test('adds', () {});" }))).toEqual([]);
});

test("stays quiet on a class added to a lib file and on reads", () => {
  const code = "class AuthService {}\nint price() => 1;\n";
  expect(detect(edit("lib/auth.dart", code, { written: "class AuthService {}" }))).toEqual([]);
  expect(detect(read("test/auth_test.dart", `class AuthHarness {}\n${newTest}`))).toEqual([]);
});