Describe the bug
Adding a decorator from AsyncApi results in the wrong call stack line number for failing tests
To Reproduce
Steps to reproduce the behavior:
- Create a new Nest project (
npx @nestjs/cli@latest new test-call-stack-bug)
- Install nestjs-asyncapi (
npm i -D nestjs-asyncapi)
- Add
@AsyncApi() to AppService class
- Add a failing test to app.controller.spec.ts:
describe('root', () => {
it('should return "Hello World!"', () => {
expect(appController.getHello()).toBe('Hello World!')
})
it('should fail', () => {
expect(5).toBe(6)
})
})
- Run the tests (
npm test) and notice how the wrong line is marked as the failing one:
● AppController › root › should fail
expect(received).toBe(expected) // Object.is equality
Expected: 6
Received: 5
18 | describe('root', () => {
19 | it('should return "Hello World!"', () => {
> 20 | expect(appController.getHello()).toBe('Hello World!')
| ^
21 | })
22 |
23 | it('should fail', () => {
at Object.<anonymous> (app.controller.spec.ts:20:23)
Expected behavior
The failing row is shown correctly (which happens if I remove @AsyncApi() decorator from AppService class):
● AppController › root › should fail
expect(received).toBe(expected) // Object.is equality
Expected: 6
Received: 5
22 |
23 | it('should fail', () => {
> 24 | expect(5).toBe(6)
| ^
25 | })
26 | })
27 | })
at Object.<anonymous> (app.controller.spec.ts:24:17)
Environment
- Nest version: 10.2.7
- Node version: 18.18.2
- Platform: Windows, Linux
Additional context
Same thing happens if I add @AsyncApiPub decorator to a method in AppService:
@Injectable()
export class AppService {
@AsyncApiPub({ channel: 'test', message: { name: 'test', payload: 'test' } })
getHello(): string {
return 'Hello World!'
}
}
Describe the bug
Adding a decorator from AsyncApi results in the wrong call stack line number for failing tests
To Reproduce
Steps to reproduce the behavior:
npx @nestjs/cli@latest new test-call-stack-bug)npm i -D nestjs-asyncapi)@AsyncApi()toAppServiceclassnpm test) and notice how the wrong line is marked as the failing one:Expected behavior
The failing row is shown correctly (which happens if I remove
@AsyncApi()decorator fromAppServiceclass):Environment
Additional context
Same thing happens if I add
@AsyncApiPubdecorator to a method inAppService: