GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — "No test suite found in file" error when running Vitest · Issue #32252 · angular/angular-cli

"No test suite found in file" error when running Vitest #32252

New issue
Copy link
New issue
Copy link
Closed
Bug
Closed
"No test suite found in file" error when running Vitest#32252
Bug
Copy link
Labels
angular/build:unit-testarea: @angular/buildfreq1: lowOnly reported by a handful of users who observe it rarelyOnly reported by a handful of users who observe it rarely

Description

@NateRobinsonAA
NateRobinsonAA
opened on Jan 8, 2026
Issue body actions

Which @angular/* package(s) are the source of the bug?

Don't known / other

Is this a regression?

No

Description

I came across this error and the fix seemed to be to remove the export const statement from the spec, then export it from its own file.

I first reported this to Vitest, but they pointed out that running the test using npm run test fails while simple running with the command vitest passes. The maintainers suggested that it was an Angular bug.

I created a new StackBlitz from the Angular template, ensured that it was the latest version of Angular, installed vitest and jsdom, and added the minimum config to get it up and running.

Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/edit/stackblitz-starters-sj74ev3n?file=src%2Fabc.spec.ts

Please provide the exception or error you saw

❯ npm run test

> test
> ng test --no-watch

 RUN  v4.0.16 /home/projects/stackblitz-starters-sj74ev3n

 ✓  demo  src/abc.spec.ts > Main > should run 2ms
 ✓  demo  src/abc.spec.ts > Main > should run 0ms

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Failed Suites 1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

 FAIL   demo  src/main.spec.ts [ src/main.spec.ts ]
Error: No test suite found in file /home/projects/stackblitz-starters-sj74ev3n/src/main.spec.ts
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯


 Test Files  1 failed | 1 passed (2)
      Tests  2 passed (2)
   Start at  14:05:42
   Duration  3.52s (transform 91ms, setup 2.06s, import 51ms, tests 5ms, environment 620ms)

Please provide the environment you discovered this bug in (run ng version)

Angular CLI       : 21.0.2
Angular           : 21.0.3
Node.js           : 20.19.1
Package Manager   : npm 10.8.2
Operating System  : linux x64

┌───────────────────────────┬───────────────────┬───────────────────┐
│ Package                   │ Installed Version │ Requested Version │
├───────────────────────────┼───────────────────┼───────────────────┤
│ @angular/animations       │ 21.0.3            │ ^21.0.3           │
│ @angular/build            │ 21.0.2            │ ^21.0.2           │
│ @angular/cli              │ 21.0.2            │ ^21.0.2           │
│ @angular/common           │ 21.0.3            │ ^21.0.3           │
│ @angular/compiler         │ 21.0.3            │ ^21.0.3           │
│ @angular/compiler-cli     │ 21.0.3            │ ^21.0.3           │
│ @angular/core             │ 21.0.3            │ ^21.0.3           │
│ @angular/forms            │ 21.0.3            │ ^21.0.3           │
│ @angular/platform-browser │ 21.0.3            │ ^21.0.3           │
│ @angular/router           │ 21.0.3            │ ^21.0.3           │
│ rxjs                      │ 7.8.2             │ ^7.8.1            │
│ typescript                │ 5.9.3             │ ^5.9.3            │
│ vitest                    │ 4.0.16            │ ^4.0.15           │
│ zone.js                   │ 0.16.0            │ ^0.16.0           │
└───────────────────────────┴───────────────────┴───────────────────┘

Anything else?

Original issue report to Vitest: vitest-dev/vitest#9412 (comment)

Activity

  1. JeanMeche
    transferred this issue fromangular/angularon Jan 8, 2026
  2. clydin commented on Jan 8, 2026

    @clydin
    clydin
    on Jan 8, 2026
    Member
    More actions

    The output above shows that src/abc.spec.ts is running the tests from both of those files.
    With Vitest used directly, the tests in src/main.spec.ts are being run twice without direct indication that it is happening.
    Is that intentional?
    Running with ng test --no-watch --include src/abc.spec.ts executes all the tests in the project; as does ng test --no-watch --exclude src/main.spec.ts.

    The use of fileParallelism: false in the custom configuration seems to be triggering the behavior with the Angular CLI integration. Removing that line maintains Vitest's double execution of src/main.spec.ts. While the loading of a custom configuration is fully supported, the contents and their interactions are on a best-effort basis. For more information please see the documentation at https://angular.dev/guide/testing#advanced-vitest-configuration. However, in this case, other than fileParallelism it does not appear that any of the options used necessitate a custom configuration file.

    Reacted by rosenthalj
  3. clydin
    added
    area: @angular/build
    angular/build:unit-test
    on Jan 8, 2026
  4. clydin
    added the
    Bug
    issue type on Jan 8, 2026
  5. clydin
    added
    freq1: lowOnly reported by a handful of users who observe it rarelyOnly reported by a handful of users who observe it rarely
    on Jan 8, 2026
  6. SebastianStehle commented on Feb 7, 2026

    @SebastianStehle
    SebastianStehle
    on Feb 7, 2026
    More actions

    I have a strange problem that could be related to that. I am running a build in github action over docker. And I get random errors like

    #33 61.90  FAIL   squidex  src/app/shared/services/assets.service.spec.ts [ src/app/shared/services/assets.service.spec.ts ]
    #33 61.90 Error: No test suite found in file /build/src/app/shared/services/assets.service.spec.ts
    

    https://github.com/Squidex/squidex/actions/runs/21786191853/job/62857975805

    It is not always the same files. So far I have no idea how to reproduce it as it never happens locally.

    This is my dockerfile

    FROM squidex/frontend-build:22.19 AS frontend
    WORKDIR /build
    ENV CONTINUOUS_INTEGRATION=1
    COPY frontend/package*.json ./
    RUN npm install --loglevel=error --force
    COPY frontend .
    RUN npm run lint \
     && npm run test:coverage \
     && npm run build
    

    my build image is node:22.19.0-slim + chromium.

  7. rdamazio commented on Mar 11, 2026

    @rdamazio
    rdamazio
    on Mar 11, 2026
    More actions

    Also started seeing this after moving from Karma to vitest.

  8. air2 commented on Mar 11, 2026

    @air2
    air2
    on Mar 11, 2026
    More actions

    As far as I can tell this happens, when the file is imported by an other test BEFORE the tests in the file itself are executed, so the order of test executing is causing the randomness in this.

    I moved all my exports in *.spec.ts files to *.mock.ts files to work around this issue and I must say in the end I think the code is cleaner now. But yeah it's a nasty issue.

    Reacted by Dan Russell
  9. rdamazio commented on Mar 12, 2026

    @rdamazio
    rdamazio
    on Mar 12, 2026
    More actions

    Yes, ordering was it for mine too, but it wasn't obvious at all, and only happened in GitHub Actions, not on my Mac (thanks Antigravity for finding the root cause and fixing it! It'd have taken me a long time).

    This was the fix for me (at a first glance, nothing to do with the test suites): rdamazio/efis-editor@862fd9a

  10. clydin commented on Aug 13, 2026

    @clydin
    clydin
    on Aug 13, 2026
    Member
    More actions

    Resolved via #33729

  11. clydin
    closed this as completedon Aug 13, 2026
  12. angular-automatic-lock-bot commented on Oct 19, 2026

    @angular-automatic-lock-bot
    angular-automatic-lock-botBot
    on Oct 19, 2026
    More actions

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  13. angular-automatic-lock-bot
    locked and limited conversation to collaborators on Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    angular/build:unit-testarea: @angular/buildfreq1: lowOnly reported by a handful of users who observe it rarelyOnly reported by a handful of users who observe it rarely

    Type

    Bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.