如何在Windows上使用Docker Desktop在devcontainer中以交互模式运行Cypress?

huangapple go评论64阅读模式
英文:

How to run Cypress in interactive mode in a devcontainer on Windows with Docker Desktop?

问题

I am working on a Windows desktop. I am trying to run Cypress in a devcontainer which runs in my local Docker Desktop. I am using VcXsrv as a local X Server to enable the GUI. Actually, it works fine with one exception: the watchFileChanges is not working. When I modify a test file, it is not detected, and I must restart Cypress so that it uses the latest version of the files. Has anyone tried something similar and managed to get the watchFileChanges to work? Not sure whether this is relevant, but I am also using cypress-cucumber-preprocessor and cypress-ntlm in my test project.

{
    "name": "Cypress",
    "build": {
        "dockerfile": "dockerfile"
    },
    "customizations": {
        // Configure properties specific to VS Code.
        "vscode": {
            // Set *default* container-specific settings.json values on container create.
            "settings": {
                "cucumber.glue": [
                    "**/common/*.js"
                ]
            },
            "extensions": [
                "CucumberOpen.cucumber-official"
            ]
        }
    }
}

And here is the related Dockerfile:

FROM cypress/included:12.14.0
ENV CYPRESS_INSTALL_BINARY=0
ENV HOST_IP host.docker.internal
ENV DISPLAY ${HOST_IP}:0.0
英文:

I am working on a Windows desktop. I am trying to run Cypress in a devcontainer which runs in my local Docker Desktop. I am using VcXsrv as local X Server to enable the GUI. Actually it works fine with one exception: the watchFileChanges is not working. When I modify a test file, it is not detected and I must restart Cypress so that it uses the latest version of the files. Has anyone tried something similar and managed to get the watchFileChanges to work? Not sure whether this is relevant but I am also using cypress-cucumber-preprocessor and cypress-ntlm in my test project.

{
    "name": "Cypress",
    "build": {
        "dockerfile": "dockerfile"
    },
    "customizations": {
		// Configure properties specific to VS Code.
		"vscode": {
			// Set *default* container specific settings.json values on container create.
			"settings": {
        "cucumber.glue": [
          "**/common/*.js"
        ]
      },
			"extensions": [
        "CucumberOpen.cucumber-official"
      ]
		}       
  }
}

And here is the related Dockerfile

FROM cypress/included:12.14.0
ENV CYPRESS_INSTALL_BINARY=0
ENV HOST_IP host.docker.internal
ENV DISPLAY ${HOST_IP}:0.0

答案1

得分: 2

我已向Cypress团队提出了这个问题。解决方案是添加一个环境变量CHOKIDAR_USEPOLLING=true。Chokidar是用于监视文件更改的Node.js模块。

英文:

I have raised the issue to the Cypress team. The solution was to add an environment variable CHOKIDAR_USEPOLLING=true. Chokidar being the nodejs module used for monitoring file changes.

huangapple
  • 本文由 发表于 2023年6月26日 18:33:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/76555858.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定