1.0.92 • Published 11 days ago

@checksum-ai/runtime v1.0.92

Weekly downloads
-
License
ISC
Repository
github
Last release
11 days ago

Checksum.ai Tests

Quick Start

  1. Run npm install -D checksumai.
  2. Navigate to the directory where you want to add Checksum tests and run npx checksumai init.
  3. Run npx playwright install --with-deps to install Playwright dependencies.
  4. Edit checksum.config.ts to include necessary configurations such as:
    • apiKey
    • baseURL
    • username
    • password
  5. Update login.ts with your login function using Playwright. See the Login Function section below for guidance.
  6. Run npx checksumai test to execute the example test and verify successful login.
  7. If you haven't already, visit app.checksum.ai to complete the configuration and generate a test. Then, wait for the pull request (PR) to be created and approve it.

Login Function

  1. This function is executed at the start of each test.
  2. We recommend using a consistent seeded user for every test. For example, before each test, call a webhook that creates a user, seeds it with data, and returns the username and password. This approach ensures test reliability and allows parallel test execution. Configure this webhook in your project for consistent test generation.
  3. After logging in, assert that the login was successful. Playwright waits for assertions to be correct, ensuring that the page is ready for interaction before proceeding.
  4. To reuse authentication states between tests, refer to the Playwright guide on authentication. At the start of the login function, check if the user is already authenticated and return if so.

Checksum AI Magic

The tests generated by Checksum are based on Playwright. When executed using the Checksum CLI with an API key, Checksum enhances Playwright's functionality, improving test reliability and automatically maintaining tests.

Autonomous Test Agent

Checksum runs your Playwright tests regularly, but we added a few extra features to make tests more reliable. All of the features can be turned on/off through checksum.config.ts

Smart Selectors When generating tests, Checksum stores extensive metadata for each action (see the test-data folder). If a traditional selector fails, this metadata is used for correction. For example, if a test identifies an element by its ID but the ID changes, Checksum utilizes other data points (e.g., element class, text, parents) to locate the element. Use the checksumSelector("<id>") method to link an action to its metadata. Do not alter the IDs.

Checksum AI If Smart Selectors also fail, Checksum's custom-trained model can regenerate the failed section of the test. In such cases, the model might add, remove, or alter actions to achieve the same objectives, without changing the assertions. The assumption is that as long as the assertions pass, the model has successfully fixed the test. Use the .checksumAI("<natural language description of the test>") method to guide the model in fixing the test.

You can modify the description as needed for our model. Additionally, you can include steps with only ChecksumAI descriptions, prompting our model to generate the Playwright code. For example, await page.checksumAI("Click on 'New Task' button") without the actual action will have our model generate the necessary Playwright code. You can even author entire tests in this manner.

Run Modes

Checksum offers three run modes:

  1. Normal - Tests are executed using the Autonomous Test Agent as defined in the config file.
  2. Heal - If the Autonomous Test Agent corrects a test, a new test file with the fix is created. By default, this file is created locally, but you can also configure the Agent to open a PR to your GitHub repository by setting autoHealPRs to true.
  3. Refactor (Work in Progress) - The Autonomous Test Agent runs the test and, for each action, regenerates a regular Playwright selector, a Smart Selector, and a Checksum AI description.

Mock Data

When generating tests, Checksum records all backend responses, allowing tests to run in the same backend context. This is particularly useful for debugging or initial test runs, especially if your testing database/context differs from that used for test generation. Note that if your backend response format changes, the mocked data may not work as expected.

CLI Commands

  1. init - Initialize the Checksum directory and configurations.
  2. test - Run Checksum tests. Accepts all Playwright command line flags. To override checksum.config.ts, pass full or partial JSON as a string, e.g., --checksum-config='{"baseURL": "https://example.com"}'.

Running with GitHub Actions

See the example file github-actions.example.yml.

Troubleshooting

Q: I'm seeing various exceptions when I run "npx checksumai test", even before the test starts.

A: If you had a pre-installed version of Playwright, it might not be compatible with Checksum. Remove both Playwright and Checksum libraries, delete the relevant folder from node_modules, and run npm install -D checksumai.

1.0.91

11 days ago

1.0.92

11 days ago

1.0.89

16 days ago

1.0.88

19 days ago

1.0.87

20 days ago

1.0.86

27 days ago

1.0.85

1 month ago

1.0.84

1 month ago

1.0.83

2 months ago

1.0.82

2 months ago

1.0.81

2 months ago

1.0.80

2 months ago

1.0.79

3 months ago

1.0.77

3 months ago

1.0.76

3 months ago

1.0.75

3 months ago

1.0.78

3 months ago

1.0.73

3 months ago

1.0.72

3 months ago

1.0.74

3 months ago

1.0.71

3 months ago

1.0.69

3 months ago

1.0.68

3 months ago

1.0.70

3 months ago

1.0.66

3 months ago

1.0.67

3 months ago

1.0.65

3 months ago

1.0.64

3 months ago

1.0.63

3 months ago

1.0.62

3 months ago

1.0.61

3 months ago

1.0.60

3 months ago

1.0.59

4 months ago

1.0.58

4 months ago

1.0.57

4 months ago

1.0.56

4 months ago

1.0.49

4 months ago

1.0.51

4 months ago

1.0.50

4 months ago

1.0.55

4 months ago

1.0.54

4 months ago

1.0.53

4 months ago

1.0.52

4 months ago

1.0.48

4 months ago

1.0.47

4 months ago

1.0.46

4 months ago

1.0.44

4 months ago

1.0.45

4 months ago

1.0.43

4 months ago

1.0.39

5 months ago

1.0.38

5 months ago

1.0.40

5 months ago

1.0.42

5 months ago

1.0.41

5 months ago

1.0.37

5 months ago

1.0.36

5 months ago

1.0.35

5 months ago

1.0.34

5 months ago

1.0.33

5 months ago

1.0.32

5 months ago

1.0.31

5 months ago

1.0.29

5 months ago

1.0.30

5 months ago

1.0.28

5 months ago

1.0.27

5 months ago

1.0.26

5 months ago

1.0.25

5 months ago

1.0.24

5 months ago

1.0.23

5 months ago

1.0.22

5 months ago

1.0.21

5 months ago

1.0.20

5 months ago

1.0.19

5 months ago

1.0.18

5 months ago

1.0.17

5 months ago

1.0.16

5 months ago

1.0.9

5 months ago

1.0.8

5 months ago

1.0.7

5 months ago

1.0.11

5 months ago

1.0.10

5 months ago

1.0.15

5 months ago

1.0.14

5 months ago

1.0.13

5 months ago

1.0.12

5 months ago

1.0.6

6 months ago

1.0.5

6 months ago

1.0.4

6 months ago

1.0.3

6 months ago

1.0.2

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago