diff --git a/test/production/emit-decorator-metadata/app/pages/api/[[...params]].js b/test/production/emit-decorator-metadata/app/pages/api/[[...params]].js index 16b931125b8d2..a0151a722e044 100644 --- a/test/production/emit-decorator-metadata/app/pages/api/[[...params]].js +++ b/test/production/emit-decorator-metadata/app/pages/api/[[...params]].js @@ -1,14 +1,15 @@ -import { createHandler, Get, Param } from 'next-api-decorators' +import 'reflect-metadata' +import { container, singleton } from 'tsyringe' -class HelloHandler { - @Get('/:myParam') - // This fails due to library looking for Reflect.getMetadata("design:paramtypes", ...). - // Design:paramtypes is never emitted due to missing SWC flag. - async get(@Param('myParam') myParam) { - return { - myParam, - } +@singleton() +class HelloService { + getHello() { + return 'Hello, world!' } } -export default createHandler(HelloHandler) +const helloService = container.resolve(HelloService) + +export default function handler(req, res) { + res.status(200).json({ message: helloService.getHello() }) +} diff --git a/test/production/emit-decorator-metadata/index.test.ts b/test/production/emit-decorator-metadata/index.test.ts index baa91044e825a..30b3edc6adb53 100644 --- a/test/production/emit-decorator-metadata/index.test.ts +++ b/test/production/emit-decorator-metadata/index.test.ts @@ -1,6 +1,6 @@ import { join } from 'path' import webdriver, { BrowserInterface } from 'next-webdriver' -import { createNext, FileRef } from 'e2e-utils' +import { createNext } from 'e2e-utils' import { NextInstance } from 'e2e-utils' import { fetchViaHTTP } from 'next-test-utils' @@ -9,12 +9,8 @@ describe('emitDecoratorMetadata SWC option', () => { beforeAll(async () => { next = await createNext({ - files: { - 'jsconfig.json': new FileRef(join(__dirname, 'app/jsconfig.json')), - pages: new FileRef(join(__dirname, 'app/pages')), - }, + files: join(__dirname, 'app'), dependencies: { - 'next-api-decorators': '2.0.0', 'reflect-metadata': '0.1.13', 'path-to-regexp': '6.2.0', tsyringe: '4.6.0', @@ -41,6 +37,6 @@ describe('emitDecoratorMetadata SWC option', () => { it('should compile with emitDecoratorMetadata enabled for API', async () => { const res = await fetchViaHTTP(next.url, '/api/something') expect(res.status).toBe(200) - expect(await res.json()).toEqual({ myParam: 'something' }) + expect(await res.json()).toEqual({ message: 'Hello, world!' }) }) }) diff --git a/test/turbopack-build-tests-manifest.json b/test/turbopack-build-tests-manifest.json index 331ff5d51c3e8..16318941fd22b 100644 --- a/test/turbopack-build-tests-manifest.json +++ b/test/turbopack-build-tests-manifest.json @@ -17967,11 +17967,10 @@ }, "test/production/emit-decorator-metadata/index.test.ts": { "passed": [ - "emitDecoratorMetadata SWC option should compile with emitDecoratorMetadata enabled" - ], - "failed": [ + "emitDecoratorMetadata SWC option should compile with emitDecoratorMetadata enabled", "emitDecoratorMetadata SWC option should compile with emitDecoratorMetadata enabled for API" ], + "failed": [], "pending": [], "flakey": [], "runtimeError": false