Closed henrikvilhelmberglund closed 9 months ago
After using a custom routes.tsx
with "!/src/pages/**/[\\w[-]*.test.{jsx,tsx}"
in ROUTES it works again. 😊
I can't get it to work using the source
options though (don't really want a custom routes.tsx), is this supposed to replace the default routes?
generouted({
source: {
routes: [
"./src/pages/**/[\\w[-]*.{jsx,tsx}",
"!**/(_app|404).*",
"!./src/pages/**/[\\w[-]*.test.{jsx,tsx}",
],
modals: "./src/pages/**/[+]*.{jsx,tsx}",
},
}),
@henrikvilhelmberglund generouted
Vite plugin option are specific to the type generation at router.ts
. Also I checked your example and all seems to be working as expected.
@henrikvilhelmberglund
generouted
Vite plugin option are specific to the type generation atrouter.ts
. Also I checked your example and all seems to be working as expected.
Ah ok, I will just use the custom router file then.
What do you mean that it works as expected though? The repo above (specifically the colocate-tests branch) shouldn't display anything.
I mean the routing and type generation are both working as expecting with excluding the .test.tsx
files from routing while co-locating them at src/pages
.
I believe the problem with the tests has nothing to do with the routing or generouted
. Also for the vitest
config at include
option, it doesn't include tsx
files, after including them the tests ran for .tsx
files.
If it's not generouted
, what is making the file run in the browser then? Since both moving the test file out of /src and adding "!/src/pages/**/[\\w[-]*.test.{jsx,tsx}"
in ROUTES fixes it made me suspect generouted
. Interesting 😱
Thanks for clarifying, by default any .tsx
would be used by generouted
unless you exclude it as you just mentioned.
Excluding it works fine. Thanks for taking a look! 😊
Describe the Bug
I would like to colocate my test files with my components but upon doing so I get a Vitest error saying
it is not defined
or something. This is a reasonable error because I'm running Vitest withglobals: true
to not have to import everything everywhere. The problem is that the .test.tsx file is run in the DOM when it's really only there for Vitest.Is there a way to avoid running test files in the DOM somehow?
Generouted Version
v1.16.1
Your Example Website or App or Reproduction
https://stackblitz.com/github/henrikvilhelmberglund/react-vite-generouted-unocss-typescript-vitest-template/tree/colocate-tests?file=README.md
Steps to Reproduce the Bug or Issue
Expected Behavior
Expected: site works fine. After moving the .test.tsx file to /tests the site works again.
Screenshots or Videos
No response
Platform
Win 10 64bit with latest Chrome/Brave
Additional context
No response