-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@nx/vite:test does not output anything to console after upgrade to Nx 17.2.5 with vitest 1.04 #20804
Comments
I think this is is related to the "Update vite config" Migration Among other things, it adds Applying the changes to the lib's vite configs by hand re-added to test reports in the output for me. |
I have centrally managed base config: import { fileURLToPath } from "node:url";
import viteTsConfigPaths from "vite-tsconfig-paths";
import { UserConfig } from "vitest/config";
// import { pathToResources } from "@nx/nx-utils"; // TODO: figure out how to re-arrange imports
//@ts-expect-error doesn't matter, seems to work fine
const pathToResources = new URL("resources/", import.meta.url);
interface MyUserConfig extends UserConfig {
plugins: Required<UserConfig["plugins"]>;
test: Required<
Pick<
Exclude<Required<UserConfig["test"]>, undefined>,
"globals" | "restoreMocks" | "reporters"
> & {
setupFiles: Exclude<
Pick<
Exclude<Required<UserConfig["test"]>, undefined>,
"setupFiles"
>["setupFiles"],
string
>;
}
>;
}
export const myDefaultUserConfig: MyUserConfig = {
plugins: [viteTsConfigPaths()],
test: {
globals: true,
setupFiles: [
fileURLToPath(new URL("setupFiles/toEqual.ts", pathToResources)), // requires server.fs.strict to be false to work
],
restoreMocks: false, // TODO: enable this, but beware of issues with vi.mock tho (TypeError: Class constructor GoogleSheetsDownloader cannot be invoked without 'new')
reporters: ["default"],
},
server: {
fs: {
strict: false, // this will allow to load setup file from resources
},
},
}; And then use it like so: import { defineConfig } from "vite";
import merge from "ts-deepmerge";
import viteTsConfigPaths from "vite-tsconfig-paths";
// eslint-disable-next-line @nx/enforce-module-boundaries
import { myDefaultUserConfig } from "../../vite-stuff";
const userConfig = { ...myDefaultUserConfig };
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
userConfig.test.setupFiles.push("src/setupFiles/msw.ts");
export default defineConfig(
merge(userConfig, {
cacheDir: "../../node_modules/.vite/something",
plugins: [
viteTsConfigPaths({
root: "../../",
}),
],
test: {
cache: {
dir: "../../node_modules/.vitest",
},
environment: "node",
include: ["src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"],
},
}),
); So the migration failed for me, but as you can see above I just added |
Indeed adding Thanks for all the helpful replies! Happy holidays and a happy new year! |
Thanks everyone for logging this issue. Just curious why this output is the default behaviour now? I wouldn't expect this as the default coming into NX. Could we set a smarter default? |
@PowerSupply I don't mean to hijack the thread, just a quick question: am I reading this right that you are running Angular / Nx / Vitest together without @analogjs dependencies? Could you link any information on how to achieve this? |
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context. |
Current Behavior
After migration from Nx 17.0.2 with vitest 0.32.4 to Nx 17.2.5 with vitest 1.0.4 console output is empty when running tests with a target using @nx/vite:test as executor.
Expected Behavior
@nx/vite:test executor should output test result to terminal like before
GitHub Repo
No response
Steps to Reproduce
@nx/vite:test
as executor and make sure to have tests in the project.Nx Report
Failure Logs
No response
Package Manager Version
No response
Operating System
Additional Information
Versions in package.json:
Example vite config (unchanged since before migration):
The text was updated successfully, but these errors were encountered: