Home > Software engineering >  Getting 'Could not find test files' Error when attempting to run TestCafe tests
Getting 'Could not find test files' Error when attempting to run TestCafe tests

Time:10-21

I'm trying to run some TestCafe tests from our build server, but getting the following error...

"Could not find test files at the following location: "C:\Testing\TestCafe". Check patterns for errors:

tests/my-test.ts

or launch TestCafe from a different directory."

I did have them running or able to be found on this machine previously, but others have taken over the test coding and changed the structure a bit when moving it to a Git repository. Now when I grab the tests from Git and try to run, the problem presents itself. I'm not sure if there is something in a config file that needs adjustment but don't know where to start looking.

The intention is to have it part of our CI process, but the problem is also seen when I attempt to run the tests from the command line. The build process does install TestCafe, but there is something strange around this as well.

When the build failes with the can't find tests error, if I try to run the following command in the proper location...

tescafe chrome tests/my-test.ts

... I get, 'testcafe' is not recognized as an internal or external command, operable program or batch file.

Just can't understand why I can't get these tests running. TestCafe setup was pretty much easy previously.

ADDENDUM: I've added a screenshot of the working directory where I cd to and run the testcafe command as well as the tests subdirectory containing the test I'm trying to run.

Working Folder

Tests Folder

Any help is appreciated!!

CodePudding user response:

testcafe chrome tests/my-test.ts is just a template; it isn't a real path to your tests. This error means that the path that you set in CLI is wrong, and there aren't any tests. You need to:

  1. Find out where you start CLI. Please attach a screenshot to your question.
  2. Define an absolute path to tests or a path relative to the place where CLI was started. Please share a screenshot of your project tree where the directory with tests is open.

Also, you missed t in the tescafe chrome tests/my-test.ts command. It should be tesTcafe chrome tests/my-test.ts. That is why you get the "'tescafe' is not recognized as an internal or external command" error.

CodePudding user response:

I was able to get things working by starting from scratch. I uninstalled TestCafe and cleaned the working folder. During next build it was fine. I'm sure I've tried this several times, but it just started working.

One positive that came out of it was that I discovered a typo in a test file name, which was also causing issues finding the test I was using to check testing setup.

Thanks for helping!!

  • Related