Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding AsyncApi decorators results in wrong call stack line number for failing tests #516

Open
bakasmarius opened this issue Oct 30, 2023 · 1 comment

Comments

@bakasmarius
Copy link

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:

  1. Create a new Nest project (npx @nestjs/cli@latest new test-call-stack-bug)
  2. Install nestjs-asyncapi (npm i -D nestjs-asyncapi)
  3. Add @AsyncApi() to AppService class
  4. 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)
    })
  })
  1. 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!'
  }
}
@github-actions
Copy link

Hello! Thank you for filing an issue.

If this is a bug report, please include relevant logs to help us debug the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant