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

Nestjs lifecycle events are not finished as expected with await app.init in before hooks #52

Closed
hantsy opened this issue Jul 3, 2020 · 2 comments
Labels
bug Something isn't working help wanted Extra attention is needed no-issue-activity

Comments

@hantsy
Copy link
Owner

hantsy commented Jul 3, 2020

Described on stackoverflow.

https://stackoverflow.com/questions/62699348/nestjs-lifecycle-events-some-time-is-not-executed-as-expected-in-e2e-tests

In the e2e testing codes, app.init did not ensure the execution OnModuleInit.

Sometimes the sample data is filled, sometimes not.

It caused the following tests failed sometime.

it('/posts (GET)', async () => {
      const res = await request(app.getHttpServer()).get('/posts').send();
      expect(res.status).toBe(200);
      expect(res.body.length).toEqual(3);
    });
@hantsy hantsy added bug Something isn't working help wanted Extra attention is needed labels Jul 3, 2020
@hantsy hantsy closed this as completed Jul 14, 2020
@hantsy hantsy reopened this Jul 22, 2020
@hantsy
Copy link
Owner Author

hantsy commented Jul 22, 2020

From the CI build results, this test still failed sometimes even I changed to async/await instead of Rxjs Observable.

@github-actions
Copy link
Contributor

Marked as stale

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed no-issue-activity
Projects
None yet
Development

No branches or pull requests

1 participant