2.0.54 • Published 1 month ago

@shellygo/cypress-test-utils v2.0.54

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

cypress-test-utils

cypress-test-utils

Cypress helpers to control your UI components that work in all test levels. From component tests, through integration tests to e2e tests, for all frameworks: angular, lit, react. Making TDD fun in the modular UI area.

CypressHelper makes it saner to write UI testing. It enables creating component drivers that will work on all testing levels (component, integration, e2e).

Cypress Helpers can help you develop tests faster CypressHelper is designed to be used in any test level, and holds common methods used in Cypress tests image

CypressComponent helpers are designed to be used in component tests and are NOT framework agnostic, their sole purpose is to mount components into the browser.

Component Drivers

Testing UI is hard. There are many reasons for that, but a big one relies in the fact that unlike functions or services, where the API is clearly defined, when dealing with graphical user interfaces, it's up for the developer to transform it into an "API" for testing purposes. Back in the days, PageObjects helped mitigate this fact, but once the world moved to modular components, our test code quality degraded and became bloated with repetition and lack of abstraction.
Component drivers are just like page objects, but for your components. Just like page objects, this is merely a pattern, and is not coupled to a specific implementation. However, using CypressHelper as the basis for your component drivers will help you leverage years of trial and error and be able to fully re-use your drivers across testing levels. This allows you to confidently write tests that use your actual implementation and keep focusing on the "what" and not the "how"

image

Component Drivers can be used as building blocks for integration and E2E test driver, using Driver Composition image

Philosophy

CypressHelper aims to provide a framework agnostic (angular, lit, react) API for what a manual tester can do. This means that the API will not focus on implementation, but on the actual action a user would take. For example, a user doesn't mouseUp, he/she hovers.

Markdown Documentation

CypressTestHelper

Assertable

CypressAngularComponentHelper

CypressReactComponentHelper

CypressLitComponentHelper

HTML Documentation

Examples

In the examples repo you can find 3 small apps; an angular app, a lit app and a react app. Each app contains a driver that uses helpers, component tests, integration tests and e2e tests. As you can see, all test levels use the same driver, meaning that if the feature's implementation changes, you'll need to change the driver alone, not the tests.

Framework Spesific Information

Using Shadow DOM

When using elements with shadow dom, some things may not be where you expect them, fo example the text of this button is not directly inside the slot containing it. image CypressHelper will look for the assignedNode to retrieve the text, given that the selector of the slot has a '-slot' suffix. You may change this behaviour by overriding the default values when creating CypressHelper.

Angular

When mounting an angular component, autoSpyOutputs is set to true, meaning all event emitters are automatically spied on and may be accessed during a test using helper.get.spy("<EventEmitterName>")

Usage

This library provides an API to interact with UI elements - CypressHelper that combines the common features. To add it to your repo use

npm i -D @shellygo/cypress-test-utils

or

yarn add -D @shellygo/cypress-test-utils

Developing

  1. Set up the repo - yarn
  2. Build the project - npm run build
  3. Running tests - npm run cy:run
2.0.54

1 month ago

2.0.53

1 month ago

2.0.51

1 month ago

2.0.52

1 month ago

2.0.49

2 months ago

2.0.50

2 months ago

2.0.48

2 months ago

2.0.47

2 months ago

2.0.46

2 months ago

2.0.45

2 months ago

2.0.44

3 months ago

2.0.42

3 months ago

2.0.43

3 months ago

2.0.41

3 months ago

2.0.40

3 months ago

2.0.38

3 months ago

2.0.39

3 months ago

2.0.37

3 months ago

2.0.35

3 months ago

2.0.36

3 months ago

2.0.33

3 months ago

2.0.34

3 months ago

2.0.32

3 months ago

2.0.31

3 months ago

2.0.30

3 months ago

2.0.29

4 months ago

2.0.28

4 months ago

2.0.27

4 months ago

2.0.26

4 months ago

2.0.25

4 months ago

2.0.19

4 months ago

2.0.24

4 months ago

2.0.22

4 months ago

2.0.23

4 months ago

2.0.20

4 months ago

2.0.21

4 months ago

2.0.16

4 months ago

2.0.17

4 months ago

2.0.18

4 months ago

2.0.15

4 months ago

2.0.13

4 months ago

2.0.14

4 months ago

2.0.11

4 months ago

2.0.12

4 months ago

2.0.10

4 months ago

2.0.9

5 months ago

2.0.7

5 months ago

2.0.8

5 months ago

2.0.5

6 months ago

2.0.4

6 months ago

2.0.3

6 months ago

2.0.2

6 months ago

2.0.1

6 months ago

2.0.0

6 months ago

1.0.47

7 months ago

1.0.46

7 months ago

1.0.45

7 months ago

1.0.44

7 months ago

1.0.41

7 months ago

1.0.40

7 months ago

1.0.39

7 months ago

1.0.38

7 months ago

1.0.37

7 months ago

1.0.36

7 months ago

1.0.35

7 months ago

1.0.34

7 months ago

1.0.33

7 months ago

1.0.32

8 months ago

1.0.31

9 months ago

1.0.30

9 months ago

1.0.29

9 months ago

1.0.28

9 months ago

1.0.27

9 months ago

1.0.26

9 months ago

1.0.25

9 months ago

1.0.24

9 months ago

1.0.23

9 months ago

1.0.22

10 months ago

1.0.21

10 months ago

1.0.20

10 months ago

1.0.19

10 months ago

1.0.18

10 months ago

1.0.17

10 months ago

1.0.16

10 months ago

1.0.15

10 months ago

1.0.14

10 months ago

1.0.13

10 months ago

1.0.12

10 months ago

1.0.11

10 months ago

1.0.10

10 months ago

1.0.9

10 months ago

1.0.8

10 months ago

1.0.7

10 months ago

1.0.6

10 months ago

1.0.5

10 months ago

1.0.4

10 months ago

1.0.3

10 months ago