定制 ubc-web-services/cypress-d10-test 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ubc-web-services/cypress-d10-test

Composer 安装命令:

composer require ubc-web-services/cypress-d10-test

包简介

A cypress test suite for UBC WS common components

README 文档

README

Below, you can find instructions on how to set up the Cypress D10 test suite for your project, and how to write tests in Cypress.

These instructions are also found on Confluence. However, these two documents are not kept in sync with each other, and this README should be considered the most up-to-date version.

Minimal setup:

  1. Run composer require ubc-web-services/cypress-d10-test
  2. Start up lando as per normal local development
  3. In project root, run npm install --save-dev cypress && npm install --save-dev cypress-real-events (should be version 13+, otherwise it should prompt for an update)
  4. To start Cypress, run npx cypress open
  5. If prompted, follow the migration steps by accepting all changes (this is if an older version of cypress was already installed)
  6. Overwrite the current cypress.config.js/cypress.json file that is in root with cp -f vendor/ubc-web-services/cypress-d10-test/cypress.config.js . 
  7. At this point, we don't need the cypress folder that is in root. Either delete the folder, or rename to cypress_custom so cypress.config.js sees the tests in there.
  8. Change cypress.config.js baseUrl to the URL of the lando site (e.g. https://exampleitubcca.lndo.site)

How to write Cypress tests

A good basic tutorial can be found here: https://docs.cypress.io/guides/end-to-end-testing/writing-your-first-end-to-end-test

Cypress has made example tests for reference: https://github.com/cypress-io/cypress-example-recipes

You can also use the tests in vendor/ubc-web-services/cypress-d10-test/e2e as a reference for your own test writing.

Here is a simple example of a .cy.js file:

describe("[Generic] Test Suite - tests related to XYZ", () => {
    beforeEach(() => {
        cy.doLogin();	// triggers login custom helper function, which uses lando drush uli to login
        cy.visit('/admin/reports/dblog');
    })

    it("Checks that the title loaded (fails if whitescreen)", () => {
        // cy.get uses CSS selectors 
        cy.get('#block-gin-page-title').should('contain', 'Recent log messages');

        // using .contains() or .find() are also great ways to "grab hold" of an element, especially if it has bad selector options
        // Alternative approach
        cy.contains("Recent log messages").should("exist");
    })
})

How to add your test as a custom test

Inside cypress.config.js, there is the option 'specPattern', which specifies where tests can be found.

A path for "cypress_custom" has already been added, meaning tests placed inside that folder will be recognized by Cypress (e.g. cypress_custom/test.cy.js or cypress_custom/test/hello.cy.js).

You can also append a path to 'specPattern' to a directory of your choice.

How to ignore a test

Similar to 'specPattern', inside cypress.config.js there is the option 'excludeSpecPattern', which ignores tests that match a particular path.

There is a path to a file containing helper functions already included, which can be used as reference.

How to write "good" tests

I don't know!!! However, there are some good resources:

https://cypress.tips/

https://docs.cypress.io/guides/core-concepts/introduction-to-cypress

In general, the docs are quite easy to read: https://docs.cypress.io/guides/

How to avoid committing sensitive parameters to the repository

See https://docs.cypress.io/guides/guides/environment-variables#Option-2-cypressenvjson on how to add environment variables.

Project links

Cypress smoke tests ("default" repo): https://github.com/ubc-web-services/cypress-d10-test

Repo from previous co-op student on testing with Cypress: https://github.com/ubc-web-services/cypress-test#introduction

Automation post-mortem: https://github.com/ubc-web-services/cypress-d10-test/blob/master/automation-post-mortem.md

ubc-web-services/cypress-d10-test 适用场景与选型建议

ubc-web-services/cypress-d10-test 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 224 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 03 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 ubc-web-services/cypress-d10-test 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 ubc-web-services/cypress-d10-test 我们能提供哪些服务?
定制开发 / 二次开发

基于 ubc-web-services/cypress-d10-test 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 224
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 19
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 1
  • 开发语言: JavaScript

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2024-03-08