Replies: 1 comment 3 replies
-
Whether we create a new package or not, we still need to expose these internals. Can you provided the suggested signatures and exports of what you'd like to see exposed? For example, |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Body
Summary
This proposal suggests a new
@astrojs/test-utils
package (name TBD) containing first-party tools for library, adapter and integration authors to test their packages reliably. Such a package would enable authors to maintain their own projects without breaking package isolation nor having to replicate parts of Astro implementation on their own test suite.Background & Motivation
There are docs around testing an Astro site but, currently, Astro lacks official tooling for testing integrations and libraries. There has been questions regarding this on GH and on Discord, for example:
Sometimes we point the users to the adapters repo as a source for them to copy into their own projects, but even within the adapters repo there has been problems.
This lack of test tooling also affects official Astro projects outside of the
astro
package. Issues and discussions about providing a test package having beeing going on for a while.Goals
Examples
Astro Core tests
astro
has atest-utils
module that defines a great set of utilities for testing.A fixture is loaded and a collection of method to work with that fixture are provided. The API usability follows this style:
This is a good starting point, but has some problems:
Third party implementation
I ported the utilities from core into an external package to use for my own tests,
@inox-tools/astro-tests
.Here is an example of it being used.
It mostly resolves the problem with the module from
astro
's tests, but it still has some disadvantages that can be resolved from Astro core:mergeConfig
that combines inline configuration with configuration loaded from an Astro config file is not exported. This function is similar to a function of the same name from Vite, but Vite's function is exported. Ideally this function could be exported from Astro so it would not have to be copied into the package.validateConfig
that fills default values and apply transformations on the configuration is also not exported. This is required to resolve a value from the configuration that is not directly set on the test but used for the test tolling, like theoutDir
andsrcDir
.build
function hides the option to re-use the instantiated WASM module from the compiler. This causes a performance degradation on tests building projects.Beta Was this translation helpful? Give feedback.
All reactions