当 'example-spec.js' 为 modified/changed 时,赛普拉斯测试运行器不会立即 运行

Cypress test runner is not instantly running when the 'example-spec.js' is modified/changed

Cypress 测试 运行ner 在 'example-spec.js' 为 modified/changed 时不会立即 运行ning。测试运行ners的版本是cypress中的Chrome68和Electron 59。 cypress 的安装版本是 3.1.0。还使用 atom.js 编辑器。台式机是Windows 8.1 Pro

在命令提示符下,首先我运行这个命令转到这个目录'cd C:\node_modules.bin'然后运行 '赛普拉斯开放'。这将打开 cypress 应用程序。

下面的文件夹目录和截图添加

C:\node_modules.bin\cypress\integration\examples\example-spec.js

在应用内设置 > 配置 > json 下面给出的设置

{
    animationDistanceThreshold: 5,
    baseUrl: null,
    blacklistHosts: null,
    chromeWebSecurity: true,
    defaultCommandTimeout: 4000,
    env: {},
    execTimeout: 60000,
    fileServerFolder: '',
    fixturesFolder: 'cypress/fixtures',
    hosts: null,
    integrationFolder: 'cypress/integration',
    modifyObstructiveCode: true,
    numTestsKeptInMemory: 50,
    pageLoadTimeout: 60000,
    pluginsFile: 'cypress/plugins',
    port: null,
    reporter: 'spec',
    reporterOptions: null,
    requestTimeout: 5000,
    responseTimeout: 30000,
    screenshotsFolder: 'cypress/screenshots',
    supportFile: 'cypress/support',
    taskTimeout: 60000,
    testFiles: '**/*.*',
    trashAssetsBeforeRuns: true,
    userAgent: null,
    video: true,
    videoCompression: 32,
    videoUploadOnPasses: true,
    videosFolder: 'cypress/videos',
    viewportHeight: 660,
    viewportWidth: 1000,
    waitForAnimations: true,
    watchForFileChanges: true}

您似乎正在修改 Cypress 安装中的测试文件。这可能不是您的本意。

Cypress 有两个重要的组成部分:

  1. Cypress 包安装。在您的情况下,它安装在 c:\node_modules\.bin\cypress
  2. 正在测试的项目也有一些Cypress相关的文件,包括项目顶层目录下的cypress.json,测试文件位于cypress 项目目录中的文件夹(除非您告诉赛普拉斯使用不同的目录)。

当您 运行 Cypress 对项目进行测试时,被监视的测试文件是位于项目目录中的文件 - 而不是 Cypress 安装本身中的文件。

当你运行 cypress open那么你可以手动select你要测试的项目的目录,比如C:\MY_PROJECT。如果没有 cypress.json 文件并且没有找到测试,赛普拉斯将自动创建一个 cypress.json 文件和一个 [= C:\MY_PROJECT 中的 32=]cypress 目录。在 C:\MY_PROJECT\cypress\integration\ 目录中将有一些示例测试。当您使用 watchForFileChanges=true 编辑此目录中的测试并手动选择 C:\MY_PROJECT 进行测试时,它们将在保存时自动重新 运行。

我还测试了 运行 在 node_modules 目录中的 Cypress 包中的示例目录中修改测试。我可以确认,当编辑该目录中的文件时,测试不会重新 运行。但是,在您尝试测试您自己的项目之一时编辑这些文件是错误的。

HTH