-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
☂️ Move Astro tests to node:test #9873
Description
Description
Internally, the team decided to move our testing infrastructure to use node:test instead of Mocha.
While Mocha is good, it has its own quirks. Also, we believe that the Node.js test runner will improve with time.
This is an excellent opportunity to contribute to Astro and help us with the migration because you don't need to understand Astro logic. So if you have been looking for an opportunity to contribute to Astro, this is the perfect chance for you!
Plan
Comment here which integration/adapter you want to migrate first. Failing to comment might nullify your contribution if someone else did the work and commented on the issue. This will help us to avoid having multiple people working on the same thing.
The plan should be as follows:
- Migrate tests of our
@astrojs/*packages. This can be done in one PR, because we only have a few tests inside our integrations/adapters. You can use this PR as a blueprint of what we're looking for: chore(@astrojs/node): use Node.js for testing #9758 - Progressively migrate the tests we have in core, starting with the unit tests, then integrations tests. This means that we need to have two scripts, one that will run the tests using Mocha, and one that will run the tests using Node.js
Integrations/adapters
List of the integrations/adapters
- Migrate tests of
@astrojs/vue - Migrate tests of
@astrojs/alpinejs - Migrate tests of
@astrojs/lit@xMohamd - Migrate tests of
@astrojs/markdoc - Migrate tests of
@astrojs/mdx - Migrate tests of
@astrojs/partytown - Migrate tests of
@astrojs/preact - Migrate tests of
@astrojs/react - Migrate tests of
@astrojs/sitemap - Migrate tests of
@astrojs/solid - Migrate tests of
@astrojs/svelte - Migrate tests of
@astrojs/tailwind - Migrate tests of
@astrojs/vercel@mingjunlu
Core
- Migrate tests of @astrojs/rss
- Migrate tests of @astrojs/internal-helpers
- Migrate tests of telemetry @VoxelMC
- Migrate tests of @astrojs/underscore-redirects
- Migrate tests of @astrojs/upgrade
astro
After #10002 is merged, we can progressively start migrating tests.
Instructions:
- rename a
*.test.jsfile to*.nodetest.js, e.g.api.test.js->api.nodetest.js - migrate the content of the test to use Node.js test runner
- use the command
pnpm test:nodeto run only the files that use Node.js test runner
Warning
Node.js test runner doesn't handler deep nested describe, so it's possible your test could hang and timeout. If that happens, lift the describe function.
- Migrate tests of astro