电影剧本- Javascript:如何通过NPX命令运行功能

f4t66c6m  于 2022-12-10  发布在  Java
关注(0)|答案(1)|浏览(152)

嗨:我想通过npx命令运行Cucumber特性,但是我不能。
下面是我使用的命令:npx playwright tests:chrome --grep @POC
以下是Playwright配置文件

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;

这是我的package.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'

有人能帮我吗?

9udxz4iz

9udxz4iz1#

您是否尝试在正在使用的命令之前添加?例如:
PWDEBUG=1 npm运行测试: cucumber -- --tags“@MyTag”
我对这个问题的解决也很感兴趣,也很热衷于收集痕迹进行测试
还有一个问题(甚至是社区请求)是关于bdd的本地支持,以便能够使用带有上述选项https://github.com/microsoft/playwright/issues/11975的playwright runner。
或者查看此处的package.json -〉脚本部分以获得可用选项https://github.com/Tallyb/cucumber-playwright

相关问题