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

No tests found on 'ng test' with dot in the path to the root directory #615

Open
MaKCbIMKo opened this issue Nov 14, 2019 · 19 comments
Open

Comments

@MaKCbIMKo
Copy link

MaKCbIMKo commented Nov 14, 2019

Describe the bug
When I do ng test - it doesn't find any single test.

Firstly, I tried that on existing project (which is using jest but via jest cli and I know tests exist) -> 0 tests discovered.
Then, I tried new project (via ng new) -> 0 tests discovered.
At last, I downloaded simple-app example -> 0 tests discovered.

And I have no idea what I am doing wrong or haven't configured properly.

Any ideas what's the reason?

Ask for more information -> will provide information that might help.

To Reproduce
(for instance, new project)

  1. ng new jest-app
  2. npm i -D jest @types/jest @angular-builders/jest
  3. adjust angular.json to use new builder
  4. npm run test -> ng test

Expected behavior
All tests are discovered

Builder:

  • @angular-builders/jest
  • 8.2.0

Libraries

  • angular-devkit/build-angular: from 0.802.2 to 0.803.19

Additional context

  • node.js: 12.13.0
@arturovt
Copy link
Collaborator

I've never had this problem. Could you provide a reproduction?

@MaKCbIMKo
Copy link
Author

What do you want me to provide?

Is 'steps to reproduce' not enough?

@arturovt
Copy link
Collaborator

No, not enough. I ran through them and don't see such errors.

@arturovt
Copy link
Collaborator

Issues without reproductions should be closed as well as on the StackOverflow:

When asking a question, people will be better able to provide help if you provide code that they can easily understand and use to reproduce the problem. This is referred to by community members as creating a minimal, reproducible example (reprex), a minimal, complete and verifiable example (mcve), or a minimal, workable example (mwe).

What's the problem to make a working example thus everyone who has a look at this issue is able to reproduce it, debug and prolly provide a fix?

@MaKCbIMKo
Copy link
Author

I just re-checked with simple-app example:

  • download example
  • install packages
  • run tests

image

I did change nothing, and if I will create another repro-repo - it will be the same as example.

No, not enough. I ran through them and don't see such errors.

That's why I guess it might be related to environment (different nodejs versions etc)...

@MaKCbIMKo
Copy link
Author

MaKCbIMKo commented Dec 3, 2019

I've investigated the issue I have.

And I found the problem: root path to project contains dot character, e.g. D:\my\path\.with\dot\.

Further investigation showed some interesting things:
In all cases I have rootDir path WITH dot (in jest config)

  1. if I use full path (with dot) in testMatch config section -> no tests found
  2. if I use <rootDir> variable in testMatch config section -> no tests found
  3. if I use default testMatch without specifying full path (e.g. just "**/+(*.)+(spec|test).+(ts|js)?(x)") -> all tests found

As I workaround for that I have specified testMatch without full path:

{
    ........
    testMatch: ["**/+(*.)+(spec|test).+(ts|js)?(x)"],
    ........
}

It overrides generated testMatch path provided by jest builder and as a results it finds all tests.

It's weird because the rootDir still contains folder starts with dot, but it works.

Seems like it's not a problem with jest builder but the problem with jest itself. I will close this issue.

Hovewer, @just-jeb - Do you think I need to open another issue/suggestion to handle such case by jest builder (e.g. do not use full paths in testMatch generation)?

I've created issue in jest repo but I have no idea how fast they will proceed that...

At least for now I have a workaround without changing project path or renaming folders

@just-jeb
Copy link
Owner

just-jeb commented Dec 3, 2019

Hi @MaKCbIMKo thanks for the effort.
I'll reopen it until we confirm it's not an issue with the builder (it might be the builder, because it effectively generates the matches per project so probably it doesn't work well with dots).
Might be also issue with Angular core, since we use their utilities to resolve the paths.

@just-jeb just-jeb reopened this Dec 3, 2019
@MaKCbIMKo
Copy link
Author

Hi @just-jeb - Ok, so I will wait for updates from you - I'm curios what you will find.

@mcaden
Copy link

mcaden commented Jan 16, 2020

Tests ran fine locally but I encountered this exact issue in Azure Devops CI. I can also confirm the workaround.

@just-jeb
Copy link
Owner

@mcaden Can you confirm that the path also has dots in it?

@mcaden
Copy link

mcaden commented Jan 20, 2020

Yes, my repo name and one of the parent project folders both have one/more dots in them. Repo name is {Dept}.{Project} and the sub-project inside the repo is {Dept}.{Project}.Web. Strange it doesn't affect local runs and is only happening on CI as I'm pretty sure all the versions match judging from yarn.lock, using same node version, using same yarn version, etc. The build box path is (because Azure Devops) d:\build\9\s\Code\{Dept}.{Project}.Web\ClientApp

@just-jeb
Copy link
Owner

Maybe OS? What's your local system and what system are you using in CI?

@mcaden
Copy link

mcaden commented Jan 20, 2020

Local is Windows 10. Build box is Windows Server 2016.

@jonathanlie
Copy link

jonathanlie commented Jan 30, 2020

I'm having this issue with the latest Jest version installed (25.1.0), it was fine when I was using Jest 24.9.0. These are 1 release away from each other Releases

angular-builders/jest version is 8.3.2.

Running:

ng test base-lib

Results in:

  testMatch: /Users/user/Documents/angular-app/projects/base-lib/**/+(*.)+(spec|test).+(ts|js)?(x) - 0 matches
  testPathIgnorePatterns: /node_modules/ - 2796 matches
  testRegex:  - 0 matches

@just-jeb
Copy link
Owner

@jonathanlie No dots in path? Does specifying absolute path help?

@it-ias
Copy link

it-ias commented Jan 30, 2020

I had the same issue as above, after updating 24.9.0 to 25.1.0

Seems that testMatch should be adjusted as follow: **/*(*.)@(spec|test).[tj]s?(x)

p.s. The related jest discussion can be found here: testMatch on Windows

@just-jeb
Copy link
Owner

@it-ias thanks for the update. I'm gonna take this out into a separate issue as it seems to be unrelated to the one that started this thread.

@just-jeb just-jeb changed the title No tests found on 'ng test' No tests found on 'ng test' with dot in the path to the root directory Jan 30, 2020
@just-jeb
Copy link
Owner

All, please track #673 for Jest 25 related issue.

@just-jeb just-jeb pinned this issue Feb 1, 2020
@paddotk
Copy link

paddotk commented Jun 3, 2022

I had the same issue, but it turns out that when a test fails, the test runner claims there were no tests found. In other words, the wrong error is given.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants