Comments (7)
I was wondering about building something like a mock supabase client for my tests, but it was an up-hill battle for me. I moved my database calls to a layer that just talks to the database. For example, I have a dbInsert method that I pass a table name and some records. This method is very simple and just does an insert. My business logic contains a call to dbInsert, and I can easily mock this call in my test.
from supabase-dart.
Hi @happy-san, postgrest-dart uses http
package so you can use MockClient
to write your unit test.
client.from('todos').select('task, status').execute()
will translate into https://supabase-url/todos?select=task,status
You can use MockClient
to return a json response for that url.
from supabase-dart.
Sorry for confusing you with the word MockClient
. I create an example here
from supabase-dart.
Hey, @phamhieu have you considered this?
from supabase-dart.
Thanks, I'll try it out.
@phamhieu If I'm following you correctly, you're referring to this, right?
But wouldn't mocking only work if the execute()
function accepted a client? Like,
Future<PostgrestResponse> execute({
bool head = false,
CountOption? count,
http.Client client,
})
from supabase-dart.
Thank you for creating an example. Didn't know that a MockServer
could be created, awesome!
from supabase-dart.
_instance._initialized': You must initialize the supabase instance before calling Supabase. how to solve this this error showing while unit test and we using supabase only for aythentication and access token
from supabase-dart.
Related Issues (20)
- Status 404 with returned public url HOT 2
- Resending OTP HOT 2
- Functions-dart repo is not public yet HOT 1
- Dart library rework HOT 1
- Token leaked in network tab HOT 3
- can not update phone number via auth.update() HOT 1
- getx +supabase HOT 4
- Implementation `Column is in an array` HOT 3
- Dart client unable utilize eq() or match() to retrieve a row from table
- RealtimeSubscription Unhandled Exception: type 'Null' is not a subtype of type 'List<dynamic>' in type cast HOT 10
- Int column turned to String in realtime listening (for one row) HOT 6
- Boolean values comes with null in realtime events HOT 2
- Bug: flags field is missing on RLS-Realtime HOT 13
- Kong Error : No Api key found in request HOT 7
- On Stream: The new updated value/row is always replacing the first element of return List of rows. HOT 1
- Can't use `StreamSubscription` with realtime streams HOT 1
- Supabase doesnot export gotrue_error.dart class HOT 1
- Kong Error : No Api key found in request HOT 2
- stream returns invalid response HOT 5
- Unhandled Exception with realtime rls HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from supabase-dart.