Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: withastro/astro
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: @astrojs/sitemap@3.1.5
Choose a base ref
...
head repository: withastro/astro
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: @astrojs/sitemap@3.1.6
Choose a head ref

Commits on May 22, 2024

  1. Copy the full SHA
    05ef10c View commit details
  2. [ci] format

    ematipico authored and astrobot-houston committed May 22, 2024
    Copy the full SHA
    e1884ea View commit details
  3. Copy the full SHA
    6988f1d View commit details
  4. [ci] format

    ematipico authored and astrobot-houston committed May 22, 2024
    Copy the full SHA
    a3675e5 View commit details
  5. feat: make i18n domains stable (#11022)

    * feat: make i18n domains stable
    
    * update tst
    
    * Update .changeset/five-crabs-rhyme.md
    
    Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
    
    * fix regression
    
    ---------
    
    Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
    ematipico and sarah11918 authored May 22, 2024
    Copy the full SHA
    be68ab4 View commit details
  6. [ci] format

    ematipico authored and astrobot-houston committed May 22, 2024
    Copy the full SHA
    c30a415 View commit details
  7. feat: make CSRF protection stable (#11021)

    * feat: make CSRF protection stable
    
    * revert change
    
    * Apply suggestions from code review
    
    Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
    
    * Update packages/astro/src/@types/astro.ts
    
    Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
    
    * Update packages/astro/src/@types/astro.ts
    
    Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
    
    * beef up changeset
    
    * Update .changeset/chatty-experts-smell.md
    
    Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
    
    * Update .changeset/chatty-experts-smell.md
    
    Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
    
    * move section
    
    * Apply suggestions from code review
    
    Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
    
    ---------
    
    Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
    ematipico and sarah11918 authored May 22, 2024
    Copy the full SHA
    2d4c8fa View commit details
  8. feat: prefer using x-forwarded-for as clientAddress (#11101)

    * feat: change node clientAddress use x-forwarded-for
    
    when
    
    ```
    adapter: node({
        mode: 'standalone',
      })
    ```
    
    * feat: prefer using x-forwarded-for as clientAddress
    
    * Update .changeset/healthy-planets-dream.md
    
    Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
    
    * Update .changeset/healthy-planets-dream.md
    
    Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
    
    * Apply suggestions from code review
    
    ---------
    
    Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
    linguofeng and ematipico authored May 22, 2024
    Copy the full SHA
    a6916e4 View commit details
  9. feat: container APIs (#11051)

    * feat: container APIs
    
    * chore: handle runtime mode
    
    * chore: render slots
    
    * more prototyping
    
    * Adding a changeset
    
    * fix some weirdness around types
    
    * feat: allow to inject the manifest
    
    * feat: accept a manifest
    
    * more APIs
    
    * add `route` to the options
    
    * chore
    
    * fix component instance
    
    * chore: document stuff
    
    * remove commented code
    
    * chore: add test for renderers and fixed its types
    
    * fix: update name of the example
    
    * fix regression inside tests
    
    * use `experimental_`
    
    * remove errors
    
    * need to understand the types here
    
    * remove some options that I don't deem necessary for this phase
    
    * remove superfluous comments
    
    * chore: remove useless `@ts-ignore` directive
    
    * chore: address feedback
    
    * fix regression and remove astro config
    
    * chore: fix regression
    
    * Apply suggestions from code review
    
    Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
    
    * ooops
    
    * restore changes
    
    ---------
    
    Co-authored-by: Matthew Phillips <matthew@skypack.dev>
    Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
    3 people authored May 22, 2024
    Copy the full SHA
    12a1bcc View commit details
  10. [ci] format

    ematipico authored and astrobot-houston committed May 22, 2024
    Copy the full SHA
    b15949f View commit details
  11. Actions: restore api context param (#11112)

    * feat: expose APIContext from the second handler param
    
    * refactor: use second param from test
    
    * chore: changeset
    
    * edit: minor -> patch
    
    * edit: apiContext -> context
    
    Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>
    
    * refactor: apiContext -> context
    
    Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>
    
    * refactor: apiContext -> context
    
    Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>
    
    ---------
    
    Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>
    bholmesdev and florian-lefebvre authored May 22, 2024
    Copy the full SHA
    29a8650 View commit details
  12. [ci] format

    bholmesdev authored and astrobot-houston committed May 22, 2024
    Copy the full SHA
    a687a17 View commit details
  13. feat(vue): add support vue devtools options (#11055)

    Co-authored-by: Erika <3019731+Princesseuh@users.noreply.github.com>
    Co-authored-by: Jan-Niklas Wortmann <jan-niklas.wortmann@jetbrains.com>
    Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>
    4 people authored May 22, 2024
    Copy the full SHA
    b92de22 View commit details
  14. [ci] format

    florian-lefebvre authored and astrobot-houston committed May 22, 2024
    Copy the full SHA
    3dd57f6 View commit details
  15. Actions: React 19 progressive enhancement support (#11071)

    * deps: react 19
    
    * feat: react progressive enhancement with useActionState
    
    * refactor: revert old action state implementation
    
    * feat(test): react 19 action with useFormStatus
    
    * fix: remove unused context arg
    
    * fix: wrote actions to wrong test fixture!
    
    * deps: revert react 19 beta to 18 for actions-blog fixture
    
    * chore: remove unused overrides
    
    * chore: remove unused actions export
    
    * chore: spaces vs tabs ugh
    
    * chore: fix conflicting fixture names
    
    * chore: changeset
    
    * chore: bump changeset to minor
    
    * Actions: support React 19 `useActionState()` with progressive enhancement (#11074)
    
    * feat(ex): Like with useActionState
    
    * feat: useActionState progressive enhancement!
    
    * feat: getActionState utility
    
    * chore: revert actions-blog fixture experimentation
    
    * fix: add back actions.ts export
    
    * feat(test): Like with use action state test
    
    * fix: stub form state client-side to avoid hydration error
    
    * fix: bad .safe chaining
    
    * fix: update actionState for client call
    
    * fix: correctly resume form state client side
    
    * refactor: unify and document reactServerActionResult
    
    * feat(test): useActionState assertions
    
    * feat(docs): explain my mess
    
    * refactor: add experimental_ prefix
    
    * refactor: move all react internals to integration
    
    * chore: remove unused getIslandProps
    
    * chore: remove unused imports
    
    * chore: undo format changes
    
    * refactor: get actionResult from middleware directly
    
    * refactor: remove bad result type
    
    * fix: like button disabled timeout
    
    * chore: changeset
    
    * refactor: remove request cloning
    
    * Update .changeset/gentle-windows-enjoy.md
    
    Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
    
    * changeset grammar tense
    
    ---------
    
    Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
    Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
    3 people authored May 22, 2024
    Copy the full SHA
    8ca7c73 View commit details
  16. [ci] format

    ematipico authored and astrobot-houston committed May 22, 2024
    Copy the full SHA
    7be7b1a View commit details
  17. Copy the full SHA
    5cb68d8 View commit details
  18. [ci] format

    ematipico authored and astrobot-houston committed May 22, 2024
    Copy the full SHA
    ae42bf3 View commit details
  19. Copy the full SHA
    c7386ef View commit details
  20. [ci] format

    sarah11918 authored and astrobot-houston committed May 22, 2024
    Copy the full SHA
    7bfe8aa View commit details
  21. Copy the full SHA
    e71348e View commit details
  22. Actions: Allow actions to be called on the server (#11088)

    * wip: consume async local storage from `defineAction()`
    
    * fix: move async local storage to middleware. It works!
    
    * refactor: remove content-type check on JSON. Not needed
    
    * chore: remove test
    
    * feat: support server action calls
    
    * refactor: parse path keys within getAction
    
    * feat(test): server-side action call
    
    * chore: changeset
    
    * fix: reapply context on detected rewrite
    
    * feat(test): action from server with rewrite
    
    * chore: stray import change
    
    * feat(docs): add endpoints to changeset
    
    * chore: minor -> patch
    
    * fix: move rewrite check to start of middleware
    
    * fix: bad getApiContext() import
    
    ---------
    
    Co-authored-by: bholmesdev <bholmesdev@gmail.com>
    bholmesdev and bholmesdev authored May 22, 2024
    Copy the full SHA
    9566fa0 View commit details

Commits on May 23, 2024

  1. Copy the full SHA
    9a0e94b View commit details
  2. [ci] release (#11116)

    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
    astrobot-houston and github-actions[bot] authored May 23, 2024
    Copy the full SHA
    5077592 View commit details
  3. Copy the full SHA
    4bb9269 View commit details
  4. [ci] release (#11132)

    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
    astrobot-houston and github-actions[bot] authored May 23, 2024
    Copy the full SHA
    4c7949d View commit details

Commits on May 24, 2024

  1. Copy the full SHA
    aaf0635 View commit details
  2. Copy the full SHA
    98e0372 View commit details
  3. [ci] format

    ematipico authored and astrobot-houston committed May 24, 2024
    Copy the full SHA
    5af99dc View commit details
  4. Copy the full SHA
    33902e7 View commit details

Commits on May 27, 2024

  1. [ci] release (#11140)

    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
    astrobot-houston and github-actions[bot] authored May 27, 2024
    Copy the full SHA
    cdf89a1 View commit details
  2. fix(assets): ensure valid mime types in picture component (#11147)

    * test: Add test for Picture MIME types
    
    * fix(assets): Fix MIME type generation in Picture component
    
    * chore: changeset
    
    * fix: Trust mrmime to handle an undefined lookup argument
    
    * fix: Use image.src as fallback argument to mrmime
    
    ---------
    
    Co-authored-by: Erika <3019731+Princesseuh@users.noreply.github.com>
    kitschpatrol and Princesseuh authored May 27, 2024
    Copy the full SHA
    2d93902 View commit details

Commits on May 28, 2024

  1. Changelog: Fix typo (#11162)

    tordans authored May 28, 2024
    Copy the full SHA
    fdd4f92 View commit details
  2. Changelog: Fix link (#11163)

    tordans authored May 28, 2024
    Copy the full SHA
    6b97634 View commit details

Commits on May 29, 2024

  1. fix(runtime): check head+content component before throwing an error (#…

    …11141)
    
    * fix(runtime): check head+content component before throwing an error
    
    * add test
    ematipico authored May 29, 2024
    Copy the full SHA
    19df89f View commit details
  2. [ci] format

    ematipico authored and astrobot-houston committed May 29, 2024
    Copy the full SHA
    369069a View commit details
  3. 🐛 removed deprecated items from lit integration (#11164)

    * 🐛 removed deprecated items from lit integration
    
    * 🚀 update minified
    
    * 🐛 need `Document`
    scottnath authored May 29, 2024
    Copy the full SHA
    cf9b2ff View commit details
  4. [ci] format

    matthewp authored and astrobot-houston committed May 29, 2024
    Copy the full SHA
    6a93b53 View commit details

Commits on May 30, 2024

  1. fix(deps): update all non-major dependencies (#11151)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    Co-authored-by: bluwy <bjornlu.dev@gmail.com>
    renovate[bot] and bluwy authored May 30, 2024
    Copy the full SHA
    464b0a1 View commit details

Commits on May 31, 2024

  1. fix: guard asset global usage (#11171)

    * fix: guard global usage
    
    * chore: changeset
    Princesseuh authored May 31, 2024
    Copy the full SHA
    ff8004f View commit details

Commits on Jun 4, 2024

  1. Retain client scripts in content cache (#11170)

    * Retain client scripts in content cache
    
    * Add test
    matthewp authored Jun 4, 2024
    Copy the full SHA
    ba20c71 View commit details
  2. [ci] format

    matthewp authored and astrobot-houston committed Jun 4, 2024
    Copy the full SHA
    bf013cb View commit details
  3. Update install-package.ts (#11183)

    pnpx was removed in pnpm v7 and replaced by pnpm exec and pnpm dlx.
    
    pnpm dlx works the same as yarn dlx.
    66Leo66 authored Jun 4, 2024
    Copy the full SHA
    3cfa2ac View commit details

Commits on Jun 5, 2024

  1. Copy the full SHA
    1734c49 View commit details
  2. [ci] format

    bluwy authored and astrobot-houston committed Jun 5, 2024
    Copy the full SHA
    13c0010 View commit details
  3. [ci] release (#11158)

    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
    astrobot-houston and github-actions[bot] authored Jun 5, 2024
    Copy the full SHA
    587e75f View commit details
  4. feat(container): provide a virtual module to load renderers (#11144)

    * feat(container): provide a virtual module to load renderers
    
    * address feedback
    
    * chore: restore some default to allow to have PHP prototype working
    
    * Thread through renderers and manifest
    
    * Pass manifest too
    
    * update changeset
    
    * add diff
    
    * Apply suggestions from code review
    
    Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
    
    * fix diff
    
    * rebase and update lock
    
    ---------
    
    Co-authored-by: Matthew Phillips <matthew@skypack.dev>
    Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
    3 people authored Jun 5, 2024
    Copy the full SHA
    803dd80 View commit details
  5. feat(astro): experimental astro:env (#10974)

    * feat(env): add schema, types and envField (#10805)
    
    * feat(env): add validators (#10827)
    
    * feat(env): add vite plugin (#10829)
    
    * feat(env): client/public variables (#10848)
    
    Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
    Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
    
    * feat(env): server/public variables (#10881)
    
    Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
    Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
    
    * feat(env): server/secret variables (#10954)
    
    Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
    Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
    
    * fix: import
    
    * fix: test
    
    * feat: work on jsdoc
    
    * feat: more jsdoc
    
    * chore: remove todo
    
    * feat: fix test error and write changeset
    
    * feat: update config reference
    
    * feat: apply recommendations from review
    
    * feat: rework getEnv/setGetEnv
    
    * chore: move tests
    
    * fix: rename
    
    * fix: dev mode
    
    * chore: improve error
    
    * feat: add overrideProcessEnv helper
    
    * fix: make eslint happy
    
    * Update .changeset/poor-berries-occur.md
    
    Co-authored-by: Paul Valladares <85648028+dreyfus92@users.noreply.github.com>
    
    * Update .changeset/poor-berries-occur.md
    
    Co-authored-by: Paul Valladares <85648028+dreyfus92@users.noreply.github.com>
    
    * Update .changeset/poor-berries-occur.md
    
    Co-authored-by: Paul Valladares <85648028+dreyfus92@users.noreply.github.com>
    
    * Update .changeset/poor-berries-occur.md
    
    Co-authored-by: Paul Valladares <85648028+dreyfus92@users.noreply.github.com>
    
    * feat: fix build and address reviews
    
    * fix: container api
    
    * fix: tests
    
    * Apply suggestions from code review
    
    Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
    
    * Update packages/astro/src/@types/astro.ts
    
    Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
    
    * Apply suggestions from code review
    
    Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
    
    * Update packages/astro/src/@types/astro.ts
    
    * chore: update changeset
    
    * feat: address reviews
    
    * feat: address Ema's reviews
    
    * Update .changeset/poor-berries-occur.md
    
    Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
    
    ---------
    
    Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
    Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
    Co-authored-by: Paul Valladares <85648028+dreyfus92@users.noreply.github.com>
    Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
    5 people authored Jun 5, 2024
    Copy the full SHA
    2668ef9 View commit details
  6. [ci] format

    ematipico authored and astrobot-houston committed Jun 5, 2024
    Copy the full SHA
    b24838f View commit details
  7. fix(rewrite): copy body from the request (#11182)

    * fix(rewrite): copy body from the request
    
    * wip
    
    * chore: copy body without using it
    
    * chore: remove new file
    ematipico authored Jun 5, 2024
    Copy the full SHA
    40b0b4d View commit details
Showing 446 changed files with 17,492 additions and 14,145 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/---01-bug-report.yml
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ body:
Thank you for taking the time to file a bug report! Please fill out this form as completely as possible.
✅ I am using the **latest version of Astro** and all plugins.
✅ I am using a version of Node that Astro supports (`>=18.14.1`)
✅ I am using a version of Node that Astro supports (`v18.17.1` or `v20.3.0` or higher.)
- type: textarea
id: astro-info
attributes:
1 change: 1 addition & 0 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
],
"labels": ["dependencies"],
"rangeStrategy": "bump",
"postUpdateOptions": ["pnpmDedupe"],
"ignorePaths": ["**/node_modules/**"],
"ignoreDeps": [
// manually bumping deps
57 changes: 56 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -12,10 +12,12 @@ We welcome contributions of any size and skill level. As an open source project,

```shell
node: "^>=18.17.1"
pnpm: "^8.6.12"
pnpm: "^9.3.0"
# otherwise, your build will fail
```

We recommend using Corepack, [read PNPM docs](https://pnpm.io/installation#using-corepack).

### Setting up your local repo

Astro uses pnpm workspaces, so you should **always run `pnpm install` from the top-level project directory**. Running `pnpm install` in the top-level project root will install dependencies for `astro`, and every package in the repo.
@@ -109,6 +111,53 @@ pnpm run test -m "$STRING_MATCH"
node --test ./test/foo.test.js
```

#### Running a single test

Sometimes you want to run a single test case (`it` or `describe`) or a single test file. You can do so by using Node.js.

To run a single test file, for example `test/astro-basic.test.js`:

```shell
node --test test/astro-basic.test.js
```

If you wish to run a single test case, you have to postfix `it` and `describe` functions with `.only`:

```diff
// test/astro-basic.test.js
- describe("description", () => {
+ describe.only("description", () => {
- it("description", () => {
+ it.only("description", () => {})
})
```

Then, you have to pass the `--test-only` option to the Node.js:

```shell
node --test --test-only test/astro-basic.test.js
```

> [!WARNING]
>
> 1. If you have nested `describe`, all of them must postfix with `.only`
> 2. `--test-only` and `--test` must be placed **before** declaring the path to the file. Failing to do so will test all files
#### Debugging tests in CI

There might be occasions where some tests fail in certain CI runs due to some timeout issue. If this happens, it will be very difficult to understand which file cause the timeout. That's caused by come quirks of the Node.js test runner combined with our architecture.

To understand which file causes the issue, you can modify the `test` script inside the `package.json` by adding the `--parallel` option:

```diff
{
- "test": "astro-scripts test \"test/**/*.test.js\"",
+ "test": "astro-scripts test --parallel \"test/**/*.test.js\"",
}
```

Save the change and **push it** to your PR. This change will make the test CI slower, but it will allow to see which files causes the timeout. Once you fixed the issue **revert the change and push it**.

#### E2E tests

Certain features, like HMR and client hydration, need end-to-end tests to verify functionality in the dev server. [Playwright](https://playwright.dev/) is used to test against the dev server.
@@ -127,6 +176,12 @@ Any tests for `astro build` output should use the main `mocha` tests rather than

If a test needs to validate what happens on the page after it's loading in the browser, that's a perfect use for E2E dev server tests, i.e. to verify that hot-module reloading works in `astro dev` or that components were client hydrated and are interactive.

#### Creating tests

When creating new tests, it's best to reference other existing test files and replicate the same setup. Some other tips include:

- When re-using a fixture multiple times with different configurations, you should also configure unique `outDir`, `build.client`, and `build.server` values so the build output runtime isn't cached and shared by ESM between test runs.

### Other useful commands

```shell
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@

<div align="center">

![Build Status](https://github.com/withastro/astro/actions/workflows/ci.yml/badge.svg)
[![CI](https://github.com/withastro/astro/actions/workflows/ci.yml/badge.svg)](https://github.com/withastro/astro/actions/workflows/ci.yml)
[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/withastro/astro/blob/main/LICENSE)
[![npm version](https://badge.fury.io/js/astro.svg)](https://badge.fury.io/js/astro)

2 changes: 1 addition & 1 deletion examples/basics/package.json
Original file line number Diff line number Diff line change
@@ -11,6 +11,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^4.8.7"
"astro": "^4.10.3"
}
}
6 changes: 3 additions & 3 deletions examples/blog/package.json
Original file line number Diff line number Diff line change
@@ -11,9 +11,9 @@
"astro": "astro"
},
"dependencies": {
"@astrojs/mdx": "^3.0.1",
"@astrojs/mdx": "^3.1.1",
"@astrojs/rss": "^4.0.6",
"@astrojs/sitemap": "^3.1.5",
"astro": "^4.8.7"
"@astrojs/sitemap": "^3.1.6",
"astro": "^4.10.3"
}
}
2 changes: 1 addition & 1 deletion examples/component/package.json
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@
],
"scripts": {},
"devDependencies": {
"astro": "^4.8.7"
"astro": "^4.10.3"
},
"peerDependencies": {
"astro": "^4.0.0"
1 change: 1 addition & 0 deletions examples/container-with-vitest/.codesandbox/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM node:18-bullseye
24 changes: 24 additions & 0 deletions examples/container-with-vitest/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# build output
dist/
# generated types
.astro/

# dependencies
node_modules/

# logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*


# environment variables
.env
.env.production

# macOS-specific files
.DS_Store

# jetbrains setting folder
.idea/
11 changes: 11 additions & 0 deletions examples/container-with-vitest/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Astro + [Vitest](https://vitest.dev/) + Container API Example

```sh
npm create astro@latest -- --template container-with-vitest
```

[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/withastro/astro/tree/latest/examples/with-vitest)
[![Open with CodeSandbox](https://assets.codesandbox.io/github/button-edit-lime.svg)](https://codesandbox.io/p/sandbox/github/withastro/astro/tree/latest/examples/with-vitest)
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/withastro/astro?devcontainer_path=.devcontainer/with-vitest/devcontainer.json)

This example showcases Astro working with [Vitest](https://vitest.dev/) and how to test components using the Container API.
7 changes: 7 additions & 0 deletions examples/container-with-vitest/astro.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineConfig } from 'astro/config';
import react from "@astrojs/react"

// https://astro.build/config
export default defineConfig({
integrations: [react()]
});
25 changes: 25 additions & 0 deletions examples/container-with-vitest/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "@example/container-with-vitest",
"type": "module",
"version": "0.0.1",
"private": true,
"scripts": {
"dev": "astro dev",
"start": "astro dev",
"build": "astro build",
"preview": "astro preview",
"astro": "astro",
"test": "vitest run"
},
"dependencies": {
"astro": "^4.10.3",
"@astrojs/react": "^3.6.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"vitest": "^1.6.0"
},
"devDependencies": {
"@types/react-dom": "^18.3.0",
"@types/react": "^18.3.3"
}
}
9 changes: 9 additions & 0 deletions examples/container-with-vitest/public/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions examples/container-with-vitest/src/components/Card.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
---

<div>
This is a card
<slot />
</div>
14 changes: 14 additions & 0 deletions examples/container-with-vitest/src/components/Counter.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { useState } from 'react';

export default function({ initialCount }) {
const [count, setCount] = useState(initialCount || 0);
return (
<div className="rounded-t-lg overflow-hidden border-t border-l border-r border-gray-400 text-center p-4">
<h2 className="font-semibold text-lg">Counter</h2>
<h3 className="font-medium text-lg">Count: {count}</h3>
<button
className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded"
onClick={() => setCount(count + 1)}>Increment</button>
</div>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
import Counter from './Counter.jsx';
---

<Counter initialCount={5} />
20 changes: 20 additions & 0 deletions examples/container-with-vitest/src/pages/[locale].astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
export function getStaticPaths() {
return [{ params: { locale: 'en' } }];
}
const { locale } = Astro.params;
---

<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width" />
<meta name="generator" content={Astro.generator} />
<title>Astro</title>
</head>
<body>
<h1>Astro</h1>
<p>Locale: {locale}</p>
</body>
</html>
11 changes: 11 additions & 0 deletions examples/container-with-vitest/src/pages/api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export function GET() {
const json = {
foo: 'bar',
number: 1,
};
return new Response(JSON.stringify(json), {
headers: {
'content-type': 'application/json',
},
});
}
16 changes: 16 additions & 0 deletions examples/container-with-vitest/src/pages/index.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
---

<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width" />
<meta name="generator" content={Astro.generator} />
<title>Astro</title>
</head>
<body>
<h1>Astro</h1>
</body>
</html>
15 changes: 15 additions & 0 deletions examples/container-with-vitest/test/Card.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { experimental_AstroContainer as AstroContainer } from 'astro/container';
import { expect, test } from 'vitest';
import Card from '../src/components/Card.astro';

test('Card with slots', async () => {
const container = await AstroContainer.create();
const result = await container.renderToString(Card, {
slots: {
default: 'Card content',
},
});

expect(result).toContain('This is a card');
expect(result).toContain('Card content');
});
17 changes: 17 additions & 0 deletions examples/container-with-vitest/test/ReactWrapper.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { loadRenderers } from 'astro:container';
import { getContainerRenderer } from '@astrojs/react';
import { experimental_AstroContainer as AstroContainer } from 'astro/container';
import { expect, test } from 'vitest';
import ReactWrapper from '../src/components/ReactWrapper.astro';

const renderers = await loadRenderers([getContainerRenderer()]);
const container = await AstroContainer.create({
renderers,
});

test('ReactWrapper with react renderer', async () => {
const result = await container.renderToString(ReactWrapper);

expect(result).toContain('Counter');
expect(result).toContain('Count: <!-- -->5');
});
16 changes: 16 additions & 0 deletions examples/container-with-vitest/test/[locale].test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { experimental_AstroContainer as AstroContainer } from 'astro/container';
import { expect, test } from 'vitest';
import Locale from '../src/pages/[locale].astro';

test('Dynamic route', async () => {
const container = await AstroContainer.create();
// @ts-ignore
const result = await container.renderToString(Locale, {
params: {
locale: 'en',
},
request: new Request('http://example.com/en'),
});

expect(result).toContain('Locale: en');
});
3 changes: 3 additions & 0 deletions examples/container-with-vitest/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "astro/tsconfigs/base"
}
9 changes: 9 additions & 0 deletions examples/container-with-vitest/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/// <reference types="vitest" />
import { getViteConfig } from 'astro/config';

export default getViteConfig({
test: {
/* for example, use global to avoid globals imports (describe, test, expect): */
// globals: true,
},
});
4 changes: 2 additions & 2 deletions examples/framework-alpine/package.json
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@
"dependencies": {
"@astrojs/alpinejs": "^0.4.0",
"@types/alpinejs": "^3.13.10",
"alpinejs": "^3.13.10",
"astro": "^4.8.7"
"alpinejs": "^3.14.0",
"astro": "^4.10.3"
}
}
6 changes: 3 additions & 3 deletions examples/framework-lit/package.json
Original file line number Diff line number Diff line change
@@ -11,9 +11,9 @@
"astro": "astro"
},
"dependencies": {
"@astrojs/lit": "^4.0.1",
"@astrojs/lit": "^4.3.0",
"@webcomponents/template-shadowroot": "^0.2.1",
"astro": "^4.8.7",
"lit": "^3.1.3"
"astro": "^4.10.3",
"lit": "^3.1.4"
}
}
Loading