You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
And later in end user code base so he can populates MyInterface like so
// in the library user code basedeclare module 'my-lib/MyInterface'{interfaceMyInterface{user-property: unknown// some type here}}
I need to test types in the library that uses Myinterface, and to do so i might need to test some keys and values associated to that key that are not relevant toward the lib but need some tests
I know I can define an interface _TestMyInterface which extends MyInterface and is not exported by the library but I will also have to redefine all the tests using MyInterface to use the _TestMyInterface interface instead and this will require me to do so duplicate the entire codebase. For example :
import{MyInterface}from'./MyInterface'import{_TestMyInterface}from'./_TestMyInterface'exporttypeTypeThatUseMyInterface<KextendskeyofMyInterface>=K// do something with Ktype_TestTypeThatUseMyInterface<Kextendskeyof_TestMyInterface>=K// do something with K to allow testing for specific values that are not relevant to the library but might be relevant to the end user.
Is they're a better way to achieve this and mock MyInterface for testing purposes only?
I am using vitest for my testing environment so i do post it here as well
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I did ask this question on StackOverflow but did not get any answers so i try to post it here as i did in typescript repo
I would like to have an interface populated only for test environment.
Let say i have this interface in the lib code base
And later in end user code base so he can populates MyInterface like so
I need to test types in the library that uses
Myinterface
, and to do so i might need to test some keys and values associated to that key that are not relevant toward the lib but need some testsI know I can define an interface
_TestMyInterface
which extendsMyInterface
and is not exported by the library but I will also have to redefine all the tests usingMyInterface
to use the_TestMyInterface
interface instead and this will require me to do so duplicate the entire codebase. For example :Is they're a better way to achieve this and mock
MyInterface
for testing purposes only?I am using
vitest
for my testing environment so i do post it here as wellBeta Was this translation helpful? Give feedback.
All reactions