import { test } from 'magnitude-test';

test('Descriptive test title', async ({ ai, page, context }) => {
  // Test logic using ai, page, or context
});

Magnitude tests are defined using the globally available test function imported from magnitude-test.

import { test } from 'magnitude-test';

test('Descriptive test title', async ({ ai, page, context }) => {
  // Test logic using ai, page, or context
});

test(title, options?, testFn)

Defines a new test case.

title
string
required

A descriptive title for the test case. This title appears in test reports and logs.

options
object

Optional configuration specific to this test case.

testFn
({ ai, page, context }) => Promise<void>
required

An asynchronous function containing the test logic. It receives a context object with the properties described below.

test.group(id, options?, groupFn)

Defines a group of test cases, allowing shared options (like url) to be applied to all tests within the group.

import { test } from 'magnitude-test';

test.group('User Authentication Flow', { url: '/login' }, () => {
  test('should display login form', async ({ ai }) => {
    await ai.check("Login form is visible");
  });

  test('should allow login with valid credentials', async ({ ai }) => {
    await ai.step("Log in with valid credentials");
    await ai.check("User is redirected to dashboard");
  });
});
id
string
required

A descriptive identifier for the test group.

options
object

Optional configuration applied to all tests within this group. See properties below.

groupFn
() => void
required

A synchronous function that contains the test() declarations belonging to this group.