【问题标题】:Playwright - Cucumber - Javascript: How to run features through NPX command剧作家 - Cucumber - Javascript:如何通过 NPX 命令运行功能
【发布时间】:2022-12-11 08:19:09
【问题描述】:

嗨:我想通过 npx 命令运行 C​​ucumber 功能,但我不能。

这是我使用的命令:npx playwright tests:chrome --grep @POC

这里的编剧配置文件:

const config = { 
    timeout: 3000,
    actionTimeout: 1500,
    //workers: 2, //for parallel testing
    retries: 2,
    testDir: 'features/**/*.feature', 
    use: {
        headless: false, //true
        viewport: { width: 1920, height: 1080 }, //1280x720
        launchOptions: {
            slowMo: 1000,
        },
        video:"off",
        screenshot: 'only-on-failure',
    },
    projects: [
        {
            name: 'Chromium',
            use: { browserName: 'chromium'},
        },
        {
            name: 'Firefox',
            use: { browserName: 'firefox'},
        },
        {
            name: 'Webkit',
            use: { browserName: 'webkit'},
        },
    ],
};

module.exports = config;

这是我的包.json文件:

{
  "name": "automation-testing",
  "version": "1.0.0",
  "description": "Testing Automation Framework with Playwright and CucumberJs.",
  "main": "config.js",
  "scripts": {
    "tests:chrome": "playwright test --config=playwright.config.js --project=Chromium",
    "tests:firefox": "playwright test --config=playwright.config.js --project=Firefox",
    "tests:webkit": "playwright test --config=playwright.config.js --project=Webkit",
    "tests:cucumber": "./node_modules/.bin/cucumber-js --require cucumber.js --require step-definitions/**/*.js --require features/**/*.js -f json:cucumber_report.json",
    "report": "node reporter.js"
  },
  "author": "NN",
  "license": "ISC",
  "homepage": "https://bitbucket.org/maritzmotivation/rpp-automation-testing#readme",
  "dependencies": {
    "@cucumber/cucumber": "^8.8.0",
    "@playwright/test": "^1.27.1",
    "chai": "^4.3.7",
    "cucumber-html-reporter": "^5.5.0",
    "playwright": "^1.27.1",
    "prettier": "^2.8.0"
  },
  "devDependencies": {
    "playwright-expect": "^0.1.2"
  }
}

当我彻底运行 Cucumber 时它可以工作 (npm run tests:cucumber -- --tags "@MyTag"),但是当我尝试使用 npx (npx playwright tests:chrome --grep @MyTag) 运行它时它显示错误:

error: unknown command 'tests:chrome'

有人可以帮我吗?

【问题讨论】:

    标签: javascript playwright cucumberjs


    【解决方案1】:

    您是否尝试在适合您的命令之前添加?例如

    PWDEBUG=1 npm run tests:cucumber -- --tags "@MyTag"

    我也对这个问题的解决方案感兴趣,也很热收集测试的痕迹

    还有一个问题(甚至是社区请求)关于 bdd 的本机支持,以便能够将 playwright runner 与上述选项一起使用 https://github.com/microsoft/playwright/issues/11975

    或在此处查看 package.json -> scripts 部分以获取可用选项 https://github.com/Tallyb/cucumber-playwright

    【讨论】:

      猜你喜欢
      • 2023-03-13
      • 2018-06-22
      • 1970-01-01
      • 1970-01-01
      • 2022-12-10
      • 2017-07-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多