1

Just started training on TestCafe for new job.

For some reason I keep getting following error and I don't know why

ERROR The specified glob pattern does not match any file or the default test directories are empty.

Type "testcafe -h" for help.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! testcafe_training@1.0.0 test: `testcafe chrome ./test`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the testcafe_training@1.0.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/xx.xxx/.npm/_logs/2020-01-17T15_15_38_725Z-debug.log
xxx.xx@LPGxxx TestCafe_Training % 

Here is the code and the package.json.

Code:

Fixture`Getting started with Testcafe`
    .page`https://devexpress.github.io/testcafe/example/`;

Test('My first testcafe test', async t => {
    //Enter you testcase here
    await t.typetext('#developer-name', 'mary');
    await t.click('#submit-button');
});

package.json:

{
  "name": "testcafe_training",
  "version": "1.0.0",
  "description": "This is training",
  "main": "TestCafeTrain.js",
  "scripts": {
    "test": "testcafe chrome ./test"
  },
  "keywords": [
    "TestCafe",
    "Automation",
    "Testing"
  ],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "testcafe": "^1.7.1"
  }
}
Vladimir A.
  • 2,202
  • 2
  • 10
  • 28
fypnlp
  • 1,372
  • 4
  • 18
  • 41
  • If you read the error you'll see why it's not working. You have not told TestCafe where your tests are located. – Baruch Jan 17 '20 at 17:01
  • 1
    Does this answer your question? [The specified glob pattern does not match any file or the default test directories are empty. - testcafe](https://stackoverflow.com/questions/58808416/the-specified-glob-pattern-does-not-match-any-file-or-the-default-test-directori) – Baruch Jan 17 '20 at 17:01

1 Answers1

2

Ok, I know what i did wrong.

  1. The correct syntax for 'test' in package json. I should have run the folder name and removed './'

    "test": "testcafe chrome TestSpec"

  2. In the actual test there was a typo in the testcase. I wrote typetext incorrectly. This is what it should have looked like:

    await t.typeText('#developer-name','mary')

Ran this code and it worked perfectly

fypnlp
  • 1,372
  • 4
  • 18
  • 41