manda putra
Is there any way to postgres notify and listen with kysley?
I want to use
pg.on
but I would create a new instance connection just for that. It would be much better if I can use kysley for pg_notify listener? Could I build a plugin with the current plugin systems? is it possible? or I can already use raw sql query?1 replies
Question : How do you write integration test, and avoid flakynees?
Everytime I wrote test for the backend, I always do integration test that include real database call. I dont really like creating a mock. But the downside is, having a lot of test that have dependence on many table would create a flaky test sometimes. So we apply some rule to write integration test :
1. Always clean the data after the test run
2. Don't manipulate database seeder
3. Create a data seeder for test
4. Make a daily CI to run all test to detect flaky tests
That is enough, but sometimes we still got some flaky test, and I found this library https://www.npmjs.com/package/pg-promise-sandbox, its seems promising that we can isolate and make out test suite as a whole transaction. But I'm still not sure how to apply that in kysley.
My question is :
1. Is there any rules that I should know on writing integration test especially for database call? Is there anything that you guys might add?
2. Can we integrate kysley with
pg-promise-sandbox
so we can make all of the database call as a transaction, so we wont have many conflicting data accross test?
Thanks in advance! Waiting for your opinion guys! :))7 replies