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
I'm currently working on a project that has a lot of duplicate code supporting the tests accross the monorepo. Naturally we opted for creating a test-utils lib exporting all the necessary utils from there. As this lib contains no code for production environment, we chose not to make it buildable, which led to a lint failure for violating the Dep checks rule.
In order to avoid this issue, we just recreated the test-utils "project" as a simple folder in the root folder. The downside of this decision is not only that future changes to this folder are not picked up as "affecting" the project graph, but also that we can't use vitest's extension mechanism with typescript:
// test-utils/index.tsimport{HttpResponse,typePath}from'msw';declare module 'vitest'{exportinterfaceTestContext{mockServerError?: (path: Path,
...response: Parameters<typeofHttpResponse.json>)=>void;}}// libs/feature/src/lib/feature.spec.tsit('should render successfully',async({mockServerError})=>{// pass});// ^^^ Property 'mockServerError' does not exist on type 'TaskContext<Test<{}>> & TestContext'.ts(2339)
So what is the way to go about this? Should we recreate it as a buildable project? Is there something else about sharing test-utils that I've missed?
edit:
Found out the cool Shared Global Inputs option in the meantime, which should help resolve the first obtacle, but what about the type definition not being picked up by the other projects in the workspace?
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'm currently working on a project that has a lot of duplicate code supporting the tests accross the monorepo. Naturally we opted for creating a
test-utils
lib exporting all the necessary utils from there. As this lib contains no code for production environment, we chose not to make it buildable, which led to a lint failure for violating the Dep checks rule.In order to avoid this issue, we just recreated the
test-utils
"project" as a simple folder in the root folder. The downside of this decision is not only that future changes to this folder are not picked up as "affecting" the project graph, but also that we can't use vitest's extension mechanism with typescript:So what is the way to go about this? Should we recreate it as a buildable project? Is there something else about sharing test-utils that I've missed?
edit:
Found out the cool Shared Global Inputs option in the meantime, which should help resolve the first obtacle, but what about the type definition not being picked up by the other projects in the workspace?
Beta Was this translation helpful? Give feedback.
All reactions