-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add test in the Node adapter for astro:assets (#7734)
- Loading branch information
1 parent
31c4031
commit d5f526b
Showing
8 changed files
with
82 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'astro': patch | ||
--- | ||
|
||
Fix some global state related to `astro:assets` not getting cleaned out properly in SSR with no pre-rendered pages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
packages/integrations/node/test/fixtures/image/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "@test/nodejs-image", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"astro": "workspace:*", | ||
"@astrojs/node": "workspace:*" | ||
}, | ||
"scripts": { | ||
"build": "astro build", | ||
"preview": "astro preview" | ||
} | ||
} |
Binary file added
BIN
+315 KB
packages/integrations/node/test/fixtures/image/src/assets/some_penguin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions
6
packages/integrations/node/test/fixtures/image/src/pages/index.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
import { Image } from "astro:assets"; | ||
import penguin from "../assets/some_penguin.png"; | ||
--- | ||
|
||
<Image src={penguin} alt="Penguins" width={50} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { expect } from 'chai'; | ||
import nodejs from '../dist/index.js'; | ||
import { loadFixture } from './test-utils.js'; | ||
|
||
describe('Image endpoint', () => { | ||
/** @type {import('./test-utils').Fixture} */ | ||
let fixture; | ||
let devPreview; | ||
|
||
before(async () => { | ||
fixture = await loadFixture({ | ||
root: './fixtures/image/', | ||
output: 'server', | ||
adapter: nodejs({ mode: 'standalone' }), | ||
experimental: { | ||
assets: true, | ||
}, | ||
}); | ||
await fixture.build(); | ||
devPreview = await fixture.preview(); | ||
}); | ||
|
||
after(async () => { | ||
await devPreview.stop(); | ||
}); | ||
|
||
it('it returns images', async () => { | ||
const res = await fixture.fetch('/'); | ||
expect(res.status).to.equal(200); | ||
|
||
const resImage = await fixture.fetch( | ||
'/_image?href=/_astro/some_penguin.97ef5f92.png&w=50&f=webp' | ||
); | ||
|
||
console.log(resImage); | ||
const content = resImage.text(); | ||
console.log(content); | ||
expect(resImage.status).to.equal(200); | ||
}); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.