Skip to content

☂️ Move Astro tests to node:test  #9873

@ematipico

Description

@ematipico

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:

  1. 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
  2. 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

Core

astro

After #10002 is merged, we can progressively start migrating tests.

Instructions:

  • rename a *.test.js file 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:node to 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.

External adapters

withastro/adapters#144

Metadata

Metadata

Assignees

No one assigned

    Labels

    - P1: choreDoesn't change code behavior (priority)good first issueGood for newcomers. If you need additional guidance, feel free to post in #contribute on Discord

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions