checksumai 1.0.16 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "checksumai",
3
- "version": "1.0.16",
3
+ "version": "1.1.4",
4
4
  "description": "Checksum.ai runtime base package",
5
5
  "main": "./run.js",
6
6
  "type": "module",
@@ -11,7 +11,7 @@
11
11
  "checksumai": "run.js"
12
12
  },
13
13
  "dependencies": {
14
- "@checksum-ai/runtime": "^1.0.69",
14
+ "@checksum-ai/runtime": "1.1.4",
15
15
  "ts-node": "^10.9.1"
16
16
  },
17
17
  "repository": {
package/run.js CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  import cli from "@checksum-ai/runtime/cli.js";
4
4
 
5
- console.log("Running checksum..");
5
+ console.log("Running Checksum...");
@@ -1,65 +0,0 @@
1
- # Checksum.ai Tests
2
-
3
- ## Quick Start
4
-
5
- 1. Run `npm install -D checksumai`.
6
- 2. Navigate to the directory where you want to add Checksum tests and run `npx checksumai init`.
7
- 3. Run `npx playwright install --with-deps` to install Playwright dependencies.
8
- 4. Edit `checksum.config.ts` to include necessary configurations such as:
9
- - `apiKey`
10
- - `baseURL`
11
- - `username`
12
- - `password`
13
- 5. Update `login.ts` with your login function using Playwright. See the Login Function section below for guidance.
14
- 6. Run `npx checksumai test` to execute the example test and verify successful login.
15
- 7. If you haven't already, visit [app.checksum.ai](https://app.checksum.ai) to complete the configuration and generate a test. Then, wait for the pull request (PR) to be created and approve it.
16
-
17
- ## Login Function
18
-
19
- 1. This function is executed at the start of each test.
20
- 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](https://app.checksum.ai/#/settings/wizard) for consistent test generation.
21
- 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.
22
- 4. To reuse authentication states between tests, refer to the Playwright guide on [authentication](https://playwright.dev/docs/auth). At the start of the login function, check if the user is already authenticated and return if so.
23
-
24
- ## Checksum AI Magic
25
-
26
- 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.
27
-
28
- ### Autonomous Test Agent
29
-
30
- 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`
31
-
32
- **Smart Selectors**
33
- 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.
34
-
35
- **Checksum AI**
36
- 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.
37
-
38
- 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.
39
-
40
- ### Run Modes
41
-
42
- Checksum offers three run modes:
43
-
44
- 1. **Normal** - Tests are executed using the Autonomous Test Agent as defined in the config file.
45
- 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.
46
- 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.
47
-
48
- ### Mock Data
49
-
50
- 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.
51
-
52
- ### CLI Commands
53
-
54
- 1. `init` - Initialize the Checksum directory and configurations.
55
- 2. `test` - Run Checksum tests. Accepts all [Playwright command line flags](https://playwright.dev/docs/test-cli). To override `checksum.config.ts`, pass full or partial JSON as a string, e.g., `--checksum-config='{"baseURL": "https://example.com"}'`.
56
-
57
- ## Running with GitHub Actions
58
-
59
- See the example file `github-actions.example.yml`.
60
-
61
- ## Troubleshooting
62
-
63
- **Q: I'm seeing various exceptions when I run "npx checksumai test", even before the test starts.**
64
-
65
- A: If you had a pre-installed version of Playwright, it might not be compatible with Checksum. Uninstall the Playwright and Checksum libraries, delete the relevant folder from `node_modules`, and run `npm install -D checksumai`.
@@ -1,54 +0,0 @@
1
- import { RunMode, getChecksumConfig } from "@checksum-ai/runtime";
2
-
3
- export default getChecksumConfig({
4
- /**
5
- * Checksum Run mode. See Readme for more info
6
- */
7
- runMode: RunMode.Normal,
8
-
9
- /**
10
- * Insert here your Checksum API key. You can find it in https://app.checksum.ai/#/settings/
11
- */
12
- apiKey: "<API key>",
13
-
14
- /**
15
- * This is the base URL of the tested app. E.g. https://example.com. URLs in the tests will be relative to the base URL.
16
- */
17
- baseURL: "<base URL>",
18
-
19
- /**
20
- * Insert the account's username that will be used
21
- * to login into your testing environment
22
- */
23
- username: "<username>",
24
-
25
- /**
26
- * Insert the account's password that will be used
27
- * to login into your testing environment
28
- */
29
- password: "<password>",
30
-
31
- options: {
32
- /**
33
- * Whether to use Checksum Smart Selector when an action fails (see README)
34
- */
35
- useChecksumSelectors: true,
36
- /**
37
- * Whether to use Checksum AI when an action fails (see README)
38
- */
39
- useChecksumAI: true,
40
- /**
41
- * Whether to use mock API data when running your tests (see README)
42
- */
43
- useMockData: false,
44
- /**
45
- * Whether to Upload HTML test reports to app.checksum.ai so they can be viewed through the UI. Only relevant if Playwright reporter config is set to HTML
46
- * Reports will be saved locally either way (according to Playwright Configs) and can be viewed using the CLI command show-reports.
47
- */
48
- hostReports: !!process.env.CI,
49
- /**
50
- * Whether to create a PR with healed tests. Only relevant when in Heal mode.
51
- */
52
- autoHealPRs: !!process.env.CI,
53
- },
54
- });
@@ -1,18 +0,0 @@
1
- /* Checksum.ai autogenerated test */
2
- import { test as base, expect } from "@playwright/test";
3
- import { init, IChecksumPage } from "@checksum-ai/runtime";
4
-
5
- const { test, defineChecksumTest, login } = init(base);
6
-
7
- test.describe("Example test", () => {
8
- test.beforeEach(async ({ page }: { page: IChecksumPage }) => {
9
- await login(page);
10
- });
11
-
12
- test(
13
- defineChecksumTest("Navigate to home page", "GPzdp"),
14
- async ({ page }) => {
15
- await page.goto("/");
16
- }
17
- );
18
- });
package/checksum/login.ts DELETED
@@ -1,32 +0,0 @@
1
- import { ChecksumConfig, IChecksumPage } from "@checksum-ai/runtime";
2
- import { expect, request } from "@playwright/test";
3
-
4
- export default async function login(
5
- page: IChecksumPage,
6
- config: ChecksumConfig
7
- ) {
8
- /**
9
- * This code provides examples of how to write functions for different login scenarios.
10
- * See README for more details
11
- *
12
- * Example with Seed Function:
13
- */
14
- // const apiContext = await request.newContext();
15
- // const response = await apiContext.get("https://example.com/createseed");
16
- // const { username, password } = await response.json();
17
- // await page.goto("/login");
18
- // await page.getByPlaceholder("Email...").fill(process.env.username);
19
- // await page.getByPlaceholder("Password...").fill(process.env.password);
20
- // await page.getByText("Login").click();
21
- // await expect(page.getByText("Login Successful")).toBeVisible();
22
-
23
- /**
24
- * Example with Default Username and Password:
25
- * This example demonstrates how to log in to a page using a predefined username and password from a config file.
26
- */
27
- // await page.goto("/login");
28
- // await page.getByPlaceholder("Email...").fill(config.username);
29
- // await page.getByPlaceholder("Password...").fill(config.password);
30
- // await page.getByText("Login").click();
31
- // await expect(page.getByText("Login Successful")).toBeVisible();
32
- }
@@ -1,64 +0,0 @@
1
- import { defineConfig, devices } from "@playwright/test";
2
-
3
- /**
4
- * Read environment variables from file.
5
- * https://github.com/motdotla/dotenv
6
- */
7
- require("dotenv").config();
8
-
9
- /**
10
- * See https://playwright.dev/docs/test-configuration.
11
- */
12
- export default defineConfig({
13
- testDir: "..",
14
- /* Set test timeout to 10 minutes (relatively long) as Checksum implements its own timeout mechanism */
15
- timeout: 1000 * 60 * 10,
16
- /* Run tests in files in parallel */
17
- fullyParallel: false,
18
- /* Fail the build on CI if you accidentally left test.only in the source code. */
19
- forbidOnly: !!process.env.CI,
20
- /* Retry on CI only */
21
- retries: process.env.CI ? 2 : 0,
22
- /* Opt out of parallel tests on CI. */
23
- workers: process.env.CI ? 1 : 1,
24
- /* Reporter to use. See https://playwright.dev/docs/test-reporters */
25
- reporter: process.env.CI
26
- ? [["html", { open: "never", outputFolder: "test-results" }], ["line"]]
27
- : "html",
28
- /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
29
- use: {
30
- /* Base URL to use in actions like `await page.goto('/')`. */
31
- // baseURL: 'http://127.0.0.1:3000',
32
-
33
- /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
34
- trace: "on",
35
- video: "on",
36
- screenshot: "on",
37
- locale: "en-US",
38
- timezoneId: "America/Los_Angeles",
39
- permissions: ["clipboard-read"],
40
- actionTimeout: 1000 * 5, // set action timeout for 5 seconds. When an action times out, checksum's Autonomus Agent kicks in and attempts to fix the test.
41
- navigationTimeout: 1000 * 30,
42
-
43
- },
44
- expect: {
45
- toHaveScreenshot: { maxDiffPixelRatio: 0.05, maxDiffPixels: 200 },
46
- },
47
-
48
- /* Configure projects for major browsers */
49
- projects: [
50
- {
51
- name: "chromium",
52
- testMatch: /checksum.spec/,
53
- use: {
54
- ...devices["Desktop Chrome"],
55
- },
56
- },
57
- ],
58
- /* Run your local dev server before starting the tests */
59
- // webServer: {
60
- // command: 'npm run start',
61
- // url: 'http://127.0.0.1:3000',
62
- // reuseExistingServer: !process.env.CI,
63
- // },
64
- });