angular-builders
angular-builders copied to clipboard
No tests found on 'ng test' with dot in the path to the root directory
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)
-
ng new jest-app
-
npm i -D jest @types/jest @angular-builders/jest
- adjust
angular.json
to use new builder -
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
I've never had this problem. Could you provide a reproduction?
What do you want me to provide?
Is 'steps to reproduce' not enough?
No, not enough. I ran through them and don't see such errors.
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?
I just re-checked with simple-app example:
- download example
- install packages
- run tests
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)...
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)
- if I use full path (with
dot
) intestMatch
config section -> no tests found - if I use
<rootDir>
variable intestMatch
config section -> no tests found - 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
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.
Hi @just-jeb - Ok, so I will wait for updates from you - I'm curios what you will find.
Tests ran fine locally but I encountered this exact issue in Azure Devops CI. I can also confirm the workaround.
@mcaden Can you confirm that the path also has dots in it?
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
Maybe OS? What's your local system and what system are you using in CI?
Local is Windows 10. Build box is Windows Server 2016.
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
@jonathanlie No dots in path? Does specifying absolute path help?
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
@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.
All, please track #673 for Jest 25 related issue.
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.