Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/406.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript TestCafe-TestController未定义_Javascript_Reactjs_Typescript_Testcafe_Cucumberjs - Fatal编程技术网

Javascript TestCafe-TestController未定义

Javascript TestCafe-TestController未定义,javascript,reactjs,typescript,testcafe,cucumberjs,Javascript,Reactjs,Typescript,Testcafe,Cucumberjs,我是TestCafe world的新手,正在尝试为TestCafe+CucumberJs实现一个框架。我不确定出了什么问题,但我得到了一个错误,testcontroller没有定义。我正在复制框架中显示e2e测试流路径的大多数文件。为量角器实现了类似的框架,因此希望继续以类似的方式设计e2e测试。如果需要更多信息,请告诉我。 TestCafe版本-2.2.0 功能文件: @documentManagementTest0 *Scenario: Search Document section

我是TestCafe world的新手,正在尝试为TestCafe+CucumberJs实现一个框架。我不确定出了什么问题,但我得到了一个错误,testcontroller没有定义。我正在复制框架中显示e2e测试流路径的大多数文件。为量角器实现了类似的框架,因此希望继续以类似的方式设计e2e测试。如果需要更多信息,请告诉我。 TestCafe版本-2.2.0

功能文件:

@documentManagementTest0
   *Scenario: Search Document section validate
    Given User is on Document Management Page*
import { Given, When, Then }  from "cucumber";
import page from '../page-objects/documentManagementPO'
import { t } from "testcafe";

Given('User is on Document Management Page', function () {
    page.DocumentManagementPO.login(t);
    page.DocumentManagementPO.get(t);

});
步骤定义:

@documentManagementTest0
   *Scenario: Search Document section validate
    Given User is on Document Management Page*
import { Given, When, Then }  from "cucumber";
import page from '../page-objects/documentManagementPO'
import { t } from "testcafe";

Given('User is on Document Management Page', function () {
    page.DocumentManagementPO.login(t);
    page.DocumentManagementPO.get(t);

});
PageObjectFile:

import { Selector, t, testcafe } from 'testcafe';
import { testData } from '../testData/data.json';
import {Base} from '../support/BasePO';


export default class DocumentManagementPO extends Utils{

    async login(t){
        await loginTo(t, "tstEnv");
    }

    async get(t){
        await loadApp(t, 'tstApp');
    }
UtilsClass

import { Selector, t, testcafe } from 'testcafe';
import { testData } from '../testData/data.json';
export class Base {

    async loadApp(t, app) {

        const dropdown = Selector("portal-.dropdown:not(.userProfile)");
        await t.click(dropdown);
        const appElement = Selector('ul > li'+ app);
        await t.click(appElement);

    }

    get loginForm() {
        return {
            get userId() {
                return Selector('[name="UID"]');
            },
            get password() {
                return Selector('[name="PASSWORD"]');
            },
            get loginButton() {
                return Selector('input[type="image"]');
            }
        };
    }


    async loginTo(t,testEnv) {
        var baseUrl;

        if(testEnv === 'tst1'){
            baseUrl = testData.tst1;
        }
        else if(testEnv === 'tst2'){
            baseUrl = testData.tst2;
        }
        else{
            baseUrl = testData.DevUrl;
        }
        await t.navigateTo(baseUrl);
        await t.typeText(this.loginForm.userId, testdata.userName);
        await t.typeText(this.loginForm.password, testData.password);
        await t.click(this.loginForm.loginButton);

    }

}

错误快照场景:“搜索文档部分验证#e2e\features\documentManagement.feature:5×Before#e2e\support\hooks.js:46 ReferenceError:testController未定义在***\e2e\support\world.js:16:27 at:null:null”您提供的信息不足以确定错误的原因问题请提供你的项目的完整代码。好的,我已经找出了我的痛点。在package.json中,我运行测试的脚本如下所示:“test”:“/node_modules/.bin/cucumber-js.cmd e2e/***.feature--require e2e/***.js--tags@tcpractice--require module@babel/register-f json:./reports/cucucumber-report.json--init delay 10000--页面加载超时10000--选择器超时10000--断言超时10000”,''此位导致上述脚本出现问题**''--需要模块@babel/register''**脚本的这一部分可以在TestCafe设置中的其他地方使用吗?@Wolvoine41,很抱歉响应太晚。请更新
package.json
文件中的脚本好吗?此命令引用了
e2e
目录,但您提供的存储库中没有这样的文件夹。如果现在不需要它,很抱歉,但我看到您使用:Given('用户位于文档管理页',函数(){});但您需要这样做:给定('用户位于文档管理页面',异步(t:TestController)=>{});实际上,您需要为测试控制器提供功能。错误快照场景:“搜索文档部分验证#e2e\features\documentManagement.feature:5×Before#e2e\support\hooks.js:46 ReferenceError:testController未在***\e2e\support\world.js:16:27处定义您提供的信息:null:null”不足以确定问题的原因。请提供你的项目的完整代码。好的,我已经找出了我的痛点。在package.json中,我运行测试的脚本如下所示:“test”:“/node_modules/.bin/cucumber-js.cmd e2e/***.feature--require e2e/***.js--tags@tcpractice--require module@babel/register-f json:./reports/cucucumber-report.json--init delay 10000--页面加载超时10000--选择器超时10000--断言超时10000”,''此位导致上述脚本出现问题**''--需要模块@babel/register''**脚本的这一部分可以在TestCafe设置中的其他地方使用吗?@Wolvoine41,很抱歉响应太晚。请更新
package.json
文件中的脚本好吗?此命令引用了
e2e
目录,但您提供的存储库中没有这样的文件夹。如果现在不需要它,很抱歉,但我看到您使用:Given('用户位于文档管理页',函数(){});但您需要这样做:给定('用户位于文档管理页面',异步(t:TestController)=>{});实际上,您需要给测试控制器赋予功能。