Skip to content

Inline Tests

Write expect() assertions in your code and see pass/fail results inline.

Write expect() assertions directly in your code and ParrotJS reports pass/fail right at the assertion line — no test framework, no config, no test runner.

Writing Assertions

const sum = add(5, 7);
expect(sum).toBe(12);  // ✓ pass
expect(sum).toBe(13);  // ✗ expected 12 to be 13

Passing assertions show a green ✓ at the line; failures show ✗ with the actual-vs-expected mismatch.

Supported Matchers

Matcher Checks
toBe(value) Strict equality (===)
toEqual(value) Deep equality
toStrictEqual(value) Deep equality with strict type/undefined handling
toContain(item) Array/string membership
toThrow() That the call throws
toBeTruthy() Truthy value
toBeFalsy() Falsy value
toBeNull() null
toBeUndefined() undefined
toBeGreaterThan(n) Value is greater than n
toBeGreaterThanOrEqual(n) Value is greater than or equal to n
.not Negates any of the above

More Examples

const items = [1, 2, 3];
expect(items).toContain(3);      // ✓ pass
expect(items).toContain(99);     // ✗ expected [1,2,3] to contain 99
expect(items).not.toContain(99); // ✓ pass

const risky = () => { throw new Error('boom'); };
expect(risky).toThrow();         // ✓ pass

How Results Display

  • Inline — passing assertions show a green ✓ at the line; failures show ✗ with the actual-vs-expected mismatch.
  • Status bar — at-a-glance pass/fail counts (e.g. 4 ✓ 2 ✗).
  • Output panel — each result is logged with its file.

Free vs PRO

Inline pass/fail assertion decorations and the status bar counts are available on the free tier.

The test results panel (a dedicated summary view of all assertions) is a PRO feature — see Free vs PRO.