-
Notifications
You must be signed in to change notification settings - Fork 182
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
trying to create same table twice while running tests with same mock email and password #15
Comments
I get the same error, I'm on lesson number 10, and after setting global config for jest I cannot test anything cause I'm on Windows and I cannot use process.env.TEST_HOST = ".....". Anyway as a temporary workaround I hardcoded 127.0.0.1://0 in the resolvers.test.ts, but every time the beforeAll is called I see the same error as above... So I removed the beforeAll but I cannot execute the first test |
I think the solution is to set
And to drop the database before all the tests run |
I tried, but with this setting I receive another error |
Ben I tried something else to overcome this issue but I'm not sure if its the ideal solution. let me know if I'm doing it wrong. What I did was I removed the dropSchema from ormconfig. After that the tests were running but the database was not getting cleared and the next subsequent test would throw error of email Id already exist.. so fir this I created a deleteSchema.ts in utils in which I clear all the entries from the schema passed as parameter and call this function in afterAll event of tests (before closing the connection) this is something I came up with as a workaround |
@AkashRajpurohit I think that's a good workaround |
I have the same issues. I think because we use async method in beforeAll() . I should be |
I was trying from lesson 14. Fixing Connection Error,
while following along with you i found that my test cases were failing when i re run the test with same mock email and password in register.test.ts
I tried logging the queries from postgres and found this line
So I guess it is trying to create the users table twice and throwing error while creating it second time and thereby failing my subsequent tests.
It works if i manually change the email and password before every test but i see you don't change the email every time you test yet it works. Can't figure out why it isn't in my case
The text was updated successfully, but these errors were encountered: