在vscode中的.feature文件上运行测试,返回终端中的奇数字符

发布于 2025-02-09 14:54:11 字数 2253 浏览 1 评论 0原文

目前,我正在测试应用程序的一些功能,并目前正在通过BDD接受测试过程。我的问题是要收到解释而不是答案。

我已经在.feature文件中使用GWT语法编写了我的方案。然后,我为此创建了一个.feature文件的测试文件,并在其中包含一个空的DefineFeature()函数时对其进行了测试,以便从终端中的Cucumber接收我的测试代码。

现在,在终端中已返回给我的代码中,我得到了一些奇怪的字符。在这种情况下,这些字符表示来自.feature文件的数字。我添加了两个屏幕截图供参考。

​我当前的解决方法是简单地重现GWT,以便我只收到简单的字母字符。

这是我的软件包。JSON:

{
  "name": "app name",
  "version": "0.1.0",
  "private": true,
  "homepage": "https://example.com",
  "dependencies": {
    "@testing-library/jest-dom": "^5.16.4",
    "@testing-library/react": "^13.3.0",
    "@testing-library/user-event": "^13.5.0",
    "axios": "^0.27.2",
    "nprogress": "^0.2.0",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-scripts": "5.0.1",
    "web-vitals": "^2.1.4",
    "workbox-background-sync": "^6.5.3",
    "workbox-broadcast-update": "^6.5.3",
    "workbox-cacheable-response": "^6.5.3",
    "workbox-core": "^6.5.3",
    "workbox-expiration": "^6.5.3",
    "workbox-google-analytics": "^6.5.3",
    "workbox-navigation-preload": "^6.5.3",
    "workbox-precaching": "^6.5.3",
    "workbox-range-requests": "^6.5.3",
    "workbox-routing": "^6.5.3",
    "workbox-strategies": "^6.5.3",
    "workbox-streams": "^6.5.3"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "predeploy": "npm run build",
    "deploy": "gh-pages -d build"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "@wojtekmaj/enzyme-adapter-react-17": "^0.6.7",
    "enzyme": "^3.11.0",
    "gh-pages": "^4.0.0",
    "jest-cucumber": "^3.0.1",
    "puppeteer": "^14.4.1"
  }
}

该语法的原因可能是什么?

I am currently testing a few features for an app and going through the BDD acceptance testing process at the moment. My questions is aiming to receive for an explanation rather than an answer.

I have written my scenarios using the GWT syntax in a .feature file. Then I created the test file for this .feature file and ran a test on it while it contained an empty defineFeature() function in order to receive the code for my tests from Cucumber in the terminal.

Now, in the code that has been returned to me in the terminal I get some odd characters. In this case those characters represent a number from the .feature file. I added two screenshots for reference.

enter image description here

enter image description here

I don`t have any Gherkin related extensions installed and have also checked all my setting but nothing is related to this syntax. My currenty workaround is to simply rephrase the GWT so that I receive plain letter characters only.

Here is my package.json:

{
  "name": "app name",
  "version": "0.1.0",
  "private": true,
  "homepage": "https://example.com",
  "dependencies": {
    "@testing-library/jest-dom": "^5.16.4",
    "@testing-library/react": "^13.3.0",
    "@testing-library/user-event": "^13.5.0",
    "axios": "^0.27.2",
    "nprogress": "^0.2.0",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-scripts": "5.0.1",
    "web-vitals": "^2.1.4",
    "workbox-background-sync": "^6.5.3",
    "workbox-broadcast-update": "^6.5.3",
    "workbox-cacheable-response": "^6.5.3",
    "workbox-core": "^6.5.3",
    "workbox-expiration": "^6.5.3",
    "workbox-google-analytics": "^6.5.3",
    "workbox-navigation-preload": "^6.5.3",
    "workbox-precaching": "^6.5.3",
    "workbox-range-requests": "^6.5.3",
    "workbox-routing": "^6.5.3",
    "workbox-strategies": "^6.5.3",
    "workbox-streams": "^6.5.3"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "predeploy": "npm run build",
    "deploy": "gh-pages -d build"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "@wojtekmaj/enzyme-adapter-react-17": "^0.6.7",
    "enzyme": "^3.11.0",
    "gh-pages": "^4.0.0",
    "jest-cucumber": "^3.0.1",
    "puppeteer": "^14.4.1"
  }
}

What might be the reason for this syntax?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

作死小能手 2025-02-16 14:54:11

Cucumber建议如何为步骤定义编写方法签名以匹配您的情况。

它正在使用Regex。

  • /^是行开头的正则
  • $/是行结尾的正则
  • (\ d+)是Regex要捕获一个数字,该数字将传递到arg0中,

您不必遵循Cucumbers的建议,只是试图有所帮助。

您可能需要更多地阅读Cucumber文档,并了解Regex的文档。

Cucumber is suggesting how to write the method signatures for step definitions to match what is in your scenario.

It is using regex's.

  • /^ is the regex for the beginning of a line
  • $/ is the regex for the end of a line
  • (\d+) is a regex to capture a number and that number will be passed into arg0

You don't have to follow cucumbers recommendation, its just trying to be helpful.

You probably need to read the cucumber docs a bit more and also learn about regex's.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文