Skip to content
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

fix(vite): exit from test if no files found #27722

Merged
merged 1 commit into from
Sep 16, 2024

Conversation

AliYusuf95
Copy link
Contributor

Current Behavior

After running nx test project or nx run-many -t test with no test files with @nx/vite:test plugin, vitest process exit directly but nx reporter keep waiting for finish notification which cause to waiting indefinitely.

vitest reference:
https://github.com/vitest-dev/vitest/blob/main/packages/vitest/src/node/core.ts#L409-L413
https://github.com/vitest-dev/vitest/blob/main/packages/vitest/src/node/cli/cli-api.ts#L102-L116

console log example:

nx test project

> nx run project:test


 RUN  v2.0.5 /path/to/project

include: src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}
exclude:  **/node_modules/**, **/dist/**, **/cypress/**, **/.{idea,git,cache,output,temp}/**, **/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*
No test files found, exiting with code 0
nx run-many -t test --no-cache -p project

 NX   Running target test for project project

      With additional flags:
        --cache=false

   →  Executing 1/1 remaining tasks...

   ⠹  nx run project:test

Expected Behavior

nx test project should exit directly in case vitest process exit early.

Related Issue(s)

Fixes #

@AliYusuf95 AliYusuf95 requested a review from a team as a code owner August 31, 2024 01:45
@AliYusuf95 AliYusuf95 requested a review from JamesHenry August 31, 2024 01:45
Copy link

vercel bot commented Aug 31, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Updated (UTC)
nx-dev ⬜️ Ignored (Inspect) Visit Preview Aug 31, 2024 2:35am

@AliYusuf95 AliYusuf95 force-pushed the fix-vitest-no-file-found branch from 1838ac4 to fd1b9ea Compare August 31, 2024 02:29
@AliYusuf95 AliYusuf95 force-pushed the fix-vitest-no-file-found branch from fd1b9ea to daa3408 Compare August 31, 2024 02:31
@HashemKhalifa
Copy link

HashemKhalifa commented Sep 6, 2024

I'm facing the same problem, regardless of passing passWithNoTests: true in the project.json and vite.config.ts

checked out the branch and it solved the problem.

I am still getting into the console from Vitest the following, but not an issue for me

include: src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}
exclude:  **/node_modules/**, **/dist/**, **/cypress/**, **/.{idea,git,cache,output,temp}/**, **/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*
No test files found, exiting with code 0

@AliYusuf95
Copy link
Contributor Author

I'm facing the same problem, regardless of passing passWithNoTests: true in the project.json and vite.config.ts

checked out the branch and it solved the problem.

I am still getting into the console from Vitest the following, but not an issue for me

include: src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}
exclude:  **/node_modules/**, **/dist/**, **/cypress/**, **/.{idea,git,cache,output,temp}/**, **/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*
No test files found, exiting with code 0

exiting with code 0 means it finished successfully, I think it's fine to have it

@HashemKhalifa
Copy link

@AliYusuf95 understood, to clarify I have no problem with that at all, my main concern is that it has been stuck when no test is found

@Coly010 Coly010 merged commit 2546082 into nrwl:master Sep 16, 2024
6 checks passed
FrozenPandaz pushed a commit that referenced this pull request Sep 18, 2024
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
After running `nx test project` or `nx run-many -t test` with no test
files with `@nx/vite:test` plugin, vitest process exit directly but nx
reporter keep waiting for finish notification which cause to waiting
indefinitely.

vitest reference:

https://github.com/vitest-dev/vitest/blob/main/packages/vitest/src/node/core.ts#L409-L413

https://github.com/vitest-dev/vitest/blob/main/packages/vitest/src/node/cli/cli-api.ts#L102-L116

console log example:
```bash
nx test project

> nx run project:test

 RUN  v2.0.5 /path/to/project

include: src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}
exclude:  **/node_modules/**, **/dist/**, **/cypress/**, **/.{idea,git,cache,output,temp}/**, **/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*
No test files found, exiting with code 0
```

```bash
nx run-many -t test --no-cache -p project

 NX   Running target test for project project

      With additional flags:
        --cache=false

   →  Executing 1/1 remaining tasks...

   ⠹  nx run project:test
```

## Expected Behavior
`nx test project` should exit directly in case vitest process exit
early.

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #

(cherry picked from commit 2546082)
Copy link

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants