nosh :fosstodon: (ʘ‿ʘ) · @nosherwan
496 followers · 4852 posts · Server fosstodon.org

Unit Testing
Jest
Knex.js

I am looking for suggestions for testing knex.js functions in jest.
mocking knex via jest automock still leaves out knex.raw function.

How do you guys test your functions that utilise knex.js?




#db #knexjs #jest #mock

Last updated 1 year ago

nosh :fosstodon: (ʘ‿ʘ) · @nosherwan
444 followers · 3750 posts · Server fosstodon.org

@wiredprairie nice to know.

For some years I was using ORMs but in the end that were too much of a hassle.

I use knex.js now, it is a middle ground between having complete string based queries to have some type safety that does not get in one's way.

#knexjs

Last updated 2 years ago

nosh :fosstodon: · @nosherwan
401 followers · 2590 posts · Server fosstodon.org

@sirber sorry autocorrect screwed my comment.

I used to use orms but they caused more problems.

I was spending more time figuring out how to write a query in orm syntax where as I knew already how to do it in sql.

Query builders come to the rescue they are in between orms and plain typless sql in code.

They provide some type safety but you can use sql in your backend framework.

Knex.js is the one I use.




#knexjs #orm #sql #querybuilders

Last updated 2 years ago