首页 > 解决方案 > 量角器 - Cucumber 配置查询

问题描述

我的查询是当我们说例如 config.js 时将如何调用..“npm run test”这将根据 config.js 中定义的配置运行测试

例如我的 package.json 包含

"scripts" : {
"test" : "Env=ST CukeTags=regression testrunner -s functional"
}

我遇到的另一个问题是,我在哪里可以找到有关这些配置文件、挂钩文件如何相互关联的详细信息?在量角器测试运行期间如何调用这些?

标签: protractorcucumberjs

解决方案


您应该在 package.json 中设置测试脚本

该测试脚本将告诉命令运行量角器并给出配置文件的路径。

 "scripts":{"test": "protractor typeScript/config/config.js"}

在这里,测试命令将使用 typescript/config 文件夹中的配置文件运行量角器。

量角器和黄瓜的示例配置文件

    import * as path from "path";
import { browser, Config } from "protractor";
import { Reporter } from "../support/reporter";
const jsonReports = process.cwd() + "/reports/json";

export const config: Config = {

    seleniumAddress: "http://127.0.0.1:4444/wd/hub",

    SELENIUM_PROMISE_MANAGER: false,

    baseUrl: "https://www.google.com",

    capabilities: {
        browserName: "chrome",
    },

    framework: "custom",
    frameworkPath: require.resolve("protractor-cucumber-framework"),

    specs: [
        "../../features/*.feature",
    ],

    onPrepare: () => {
        browser.ignoreSynchronization = true;
        browser.manage().window().maximize();
        Reporter.createDirectory(jsonReports);
    },

    cucumberOpts: {
        compiler: "ts:ts-node/register",
        format: "json:./reports/json/cucumber_report.json",
        require: ["../../typeScript/stepdefinitions/*.js", "../../typeScript/support/*.js"],
        strict: true,
        tags: "@CucumberScenario or @ProtractorScenario or @TypeScriptScenario or @OutlineScenario",
    },

    onComplete: () => {
        Reporter.createHTMLReport();
    },
};

推荐阅读