javascript - 无法运行我的 testcafe 测试。代码和包 Json 看起来正确
问题描述
刚开始在 TestCafe 上培训新工作。
出于某种原因,我不断收到以下错误,我不知道为什么
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 %
这是代码和package.json。
代码:
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');
});
包.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"
}
}
解决方案
好吧,我知道我做错了什么。
json 包中“测试”的正确语法。我应该运行文件夹名称并删除'./'
“测试”:“testcafe chrome TestSpec”
在实际测试中,测试用例中有一个错字。我写错了打字稿。这应该是它的样子:
等待 t.typeText('#developer-name','mary')
运行此代码,它运行良好