Unverified Commit a90827be authored by Steven's avatar Steven Committed by GitHub

chore(test): update sharp api test (#82740)

Testing to see if sharp works with turbopack
parent 480a0e1d
......@@ -2,6 +2,6 @@
"private": true,
"packageManager": "npm@10.4.0",
"dependencies": {
"sharp": "latest"
"sharp": "^0.34.3"
}
}
import sharp from 'sharp'
export default function handler(req, res) {
res.json({ success: Boolean(sharp) })
export default async function handler(req, res) {
const roundedCorners = Buffer.from(
'<svg><rect x="0" y="0" width="200" height="200" rx="50" ry="50"/></svg>'
)
const buffer = await sharp(roundedCorners).resize(200, 200).png().toBuffer()
res.setHeader('content-type', 'image/png')
res.setHeader('content-length', buffer.byteLength)
res.end(buffer)
}
......@@ -12,11 +12,9 @@ import fs from 'fs-extra'
import { join } from 'path'
const appDir = join(__dirname, '../app')
let app,
appPort
let app, appPort
// Skip as Turbopack doesn't support `next build` yet
;(process.env.IS_TURBOPACK_TEST ? describe.skip : describe)('sharp api', () => {
describe('sharp api', () => {
beforeAll(async () => {
await execa('npm', ['install'], { cwd: appDir, stdio: 'inherit' })
await nextBuild(appDir)
......@@ -34,7 +32,8 @@ let app,
it('should handle custom sharp usage', async () => {
const res = await fetchViaHTTP(appPort, '/api/custom-sharp')
expect(res.status).toBe(200)
expect(await res.json()).toEqual({ success: true })
expect(res.headers.get('content-type')).toBe('image/png')
expect((await res.arrayBuffer()).byteLength).toBeGreaterThan(0)
const traceFile = await fs.readJson(
join(
appDir,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment