Skip to content

Migrate test suite from mocha + chai to ava#171

Merged
soulgalore merged 1 commit into
mainfrom
migrate-tests-to-ava
May 17, 2026
Merged

Migrate test suite from mocha + chai to ava#171
soulgalore merged 1 commit into
mainfrom
migrate-tests-to-ava

Conversation

@soulgalore
Copy link
Copy Markdown
Member

Sitespeed.io and browsertime have standardised on ava for testing, so
coach-core was the odd one out — mocha as runner, chai for assertions,
and chai-as-promised purely for two should.eventually callers. Moving
to ava drops three devDependencies in one swoop and gives anyone
hopping between the three repos a single testing model.

All 45 test files were converted: the nested describe/it structure is
flattened into ava's flat test('Suite / Case', t => ...) form so the
old suite grouping stays visible in the test names; chai's should and
expect assertions are mapped onto the corresponding t.is,
t.deepEqual, t.truthy, t.regex, t.true / t.false. Browser-
driven tests keep their per-browser runner setup, but as a single
module-level Map populated in test.before and torn down in
test.after.always, with test.serial + t.timeout(60_000) per
case.

One file rename came along for the ride: test/har/performance/
mimeTypes.js → mimeTypesTest.js, so it matches the *Test.js convention
every other file already followed. Mocha's recursive scan was happy to
pick it up under the old name; ava's glob is stricter.

Co-authored-by: Claude noreply@anthropic.com

  Sitespeed.io and browsertime have standardised on ava for testing, so
  coach-core was the odd one out — mocha as runner, chai for assertions,
  and chai-as-promised purely for two should.eventually callers. Moving
  to ava drops three devDependencies in one swoop and gives anyone
  hopping between the three repos a single testing model.

  All 45 test files were converted: the nested describe/it structure is
  flattened into ava's flat test('Suite / Case', t => ...) form so the
  old suite grouping stays visible in the test names; chai's should and
  expect assertions are mapped onto the corresponding t.is,
  t.deepEqual, t.truthy, t.regex, t.true / t.false. Browser-
  driven tests keep their per-browser runner setup, but as a single
  module-level Map populated in test.before and torn down in
  test.after.always, with test.serial + t.timeout(60_000) per
  case.

  One file rename came along for the ride: test/har/performance/
  mimeTypes.js → mimeTypesTest.js, so it matches the *Test.js convention
  every other file already followed. Mocha's recursive scan was happy to
  pick it up under the old name; ava's glob is stricter.

  Co-authored-by: Claude noreply@anthropic.com
@soulgalore soulgalore merged commit 2c6a638 into main May 17, 2026
3 checks passed
@soulgalore soulgalore deleted the migrate-tests-to-ava branch May 17, 2026 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant