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
TypeOrm listeners not executed during e2e testing #3243
Comments
Please, use our Discord channel (support) for such questions. We are using GitHub to track bugs, feature requests, and potential improvements. |
This is not a question. I believe there is a bug when it comes to e2e testing with databases using typeorm. The behavior when running my Nest app normally and when it is run using the test framework from @nestjs/testing is different from one another. I can not find any working examples/tests that documents this odd behavior. |
Do you have a repository that is mimicking this behavior? It seems strange that it would work in a normal start up and not in the e2e context, as nothing changes there. Could this be an issue with TypeORM directly? |
I have made a repository that tests this behavior: |
The problem was assumed to be caused by the jest environment not having access to the entity class fully causing it to not have the TypeOrm listeners and therefore not executing them.
to
|
Found the same here. Thank you @igern for the workaround 😄 👍 Can use something like this for both testing and running the application server (quick and dirty solution, probably you want to use different ormconfig files)
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Bug Report
Current behavior
The issue manifests when running e2e test with typeorm and you try to save something to the the database. The corresponsing typeorm listerners are not being executed. These are shown in the code below.
The issue does not manifest when the application is ran normally.
Input Code
Individual.entity.ts
e2e.spec.ts
Expected behavior
I expect the behavior in the two listeners in the code to be executed before they are inserted into the database.
Possible Solution
Environment
The text was updated successfully, but these errors were encountered: