修改/更改'example-spec.js'时,赛普拉斯测试运行器无法立即运行 [英] Cypress test runner is not instantly running when the 'example-spec.js' is modified/changed

查看:115
本文介绍了修改/更改'example-spec.js'时,赛普拉斯测试运行器无法立即运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

修改/更改 example-spec.js后,赛普拉斯测试运行程序不会立即运行。测试运行器的版本是柏树中的Chrome 68和Electron 59。赛普拉斯的安装版本是3.1.0。还要使用atom.js编辑器。台式机是Windows 8.1 Pro

Cypress test runner is not instantly running when the 'example-spec.js' is modified/changed. The versions of test runners are Chrome 68 and Electron 59 in cypress. cypress installed version is 3.1.0. Also using the atom.js editor. The desktop machine is Windows 8.1 Pro

在命令提示符下,首先运行此命令转到该目录' cd C:\node_modules.bin '然后运行' cypress open '。

From the command prompt, first I run this command to go to this directory'cd C:\node_modules.bin ' Then run 'cypress open'. This will open the cypress app.

下面的文件夹目录并添加了屏幕截图

Folder directory below and screenshot added

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

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

在下面提供的应用程序设置>配置> json设置中

Inside the app Settings > Configuration > json settings given below

{
    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}

< a href = https://i.stack.imgur.com/iJvJ2.jpg rel = nofollow noreferrer>

推荐答案

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

It looks like you are modifying a test file within the Cypress installation. This is probably not what you meant to do.

赛普拉斯有两个重要组成部分:

There are two important components to Cypress:


  1. 赛普拉斯软件包安装。在您的情况下,它安装在 c:\node_modules\.bin\cypress

  2. 正在测试的项目中还有一些与赛普拉斯相关的文件,包括项目顶层目录中的 cypress.json 和位于中的测试文件。项目目录中的cypress 文件夹(除非您已告知Cypress使用其他目录)。

  1. The Cypress package installation. In your case this is installed at c:\node_modules\.bin\cypress
  2. The Project under test also has some Cypress related files, including cypress.json in the top level directory of the project, and the test files located in the cypress folder within the project directory (unless you have told Cypress to use a different directory).

在项目上运行赛普拉斯测试时,监视的测试文件是位于项目目录中的文件-而不是那些在赛普拉斯安装本身中。

When you run Cypress tests on a project, the test files which are watched are those that are located within the project directory - not those within the Cypress installation itself.

运行 cypress open 时,您可以手动选择要测试的项目的目录,例如它是 C:\MY_PROJECT 。如果没有 cypress.json 文件且未找到测试,则Cypress会在<$内自动创建 cypress.json 文件和 cypress 目录。 c $ c> C:\MY_PROJECT 。在 C:\MY_PROJECT\cypress\integration\ 目录中,将包含一些示例测试。当您使用 watchForFileChanges = true 在此目录中编辑测试并手动选择 C:\MY_PROJECT 进行测试时,它们将保存后自动重新运行。

When you run cypress open then you can manually select the directory of the project that you want to test, say it is C:\MY_PROJECT. If there is no cypress.json file and no tests found, Cypress will automatically create a cypress.json file and a cypress directory within C:\MY_PROJECT. Inside the C:\MY_PROJECT\cypress\integration\ directory will be some example tests. When you edit tests in this directory with watchForFileChanges=true and manually choosing C:\MY_PROJECT to test, they will automatically rerun when saved.

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

I have also tested running and modifying the tests in the example directory within the Cypress package within the node_modules directory. I can confirm that when files within that directory are edited, the tests do not rerun. However, it is a mistake to edit those files when you are trying to test one of your own projects.

HTH

这篇关于修改/更改'example-spec.js'时,赛普拉斯测试运行器无法立即运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆