import { test } from 'magnitude-test';

test('Descriptive test title', async (agent) => {
  // Test logic using agent
});

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

import { test } from 'magnitude-test';

test('Descriptive test title', async (agent) => {
  // Test logic using agent
});

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
(agent) => Promise<void>
required

An asynchronous function containing the test logic. It receives an agent 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 (agent) => {
    await agent.check("Login form is visible");
  });

  test('should allow login with valid credentials', async (agent) => {
    await agent.act("Log in with valid credentials");
    await agent.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.