Closed mnlbox closed 5 months ago
Nx will combine any executor from the project.json
with scripts on package.json.
In this case, you should be able to run nx test <project-name>,
which should work.
However, if you have the @nx/vite
plugin installed (using Crystal), you can remove the script, which should also work.
I remember adding it because it was not working with the official Nx executor, but I believe that might have changed with Crystal.
Hi @mnlbox, I swapped the tests to use the Vitest Crystal plugin. It should work a lot better now.
Everything is released in version 2.1.0 including the previous fixes.
Hey @mnlbox, if you have some time, could you please confirm if this and the other fixes are working for you? Thank you!
Hi @NachoVazquez ,
Sorry for the late reply. Sure I'll check everything in the new version today and update you here 😉
Hi @NachoVazquez ,
I tried to use the new test command but I'm getting this error:
pnpm nx run service-test:test
NX The externalDependency 'vitest' for 'service-test:test' could not be found
Pass --verbose to see the stacktrace.
service-test
is the name of my project. I also have the vitest
package installed as a devDependency. "vitest": "~1.4.0"
, should I install anything else?
Interesting. I will take a look at this. Did you use the flag --unitTestRunner=vitest when creating the application?
I could generate and run a new project correctly; this fix works only for newly generated projects. If you want to apply these changes to an existing project, use the Nx vite plugin.
No it wasn't an old project. I just updated my plugin and then created a totally new project called service-test
with the command below, and ran the test command:
pnpm nx generate @naxodev/nx-cloudflare:application --name service-test --template hono --directory services/test --port 4001 --projectNameAndRootFormat=as-provided
And this is the result of pnpm nx show project service-test --web
command:
I can retry with --unitTestRunner=vitest
flag but as far as I undrestand it's the default value.
Awesome! Yes I think it is lol
Current Behavior
Currently we need to move to the project directory and run the test command manually and as it's normal vitest commands it means there is no NX caching applied to the test command.
Expected Behavior
I think it can be a nice improvement to add a "test" executor to the project. In this case we don't need the code below in the
package.json
file:And we can use something like this:
GitHub Repo
No response
Steps to Reproduce
1.
Nx Report
Failure Logs
No response
Operating System
Additional Information
No response