Get started

Annotations and test control

Introduction

CSTesting lets you focus or skip tests and suites so you can run a subset of tests or temporarily disable some. Skipped tests are counted and shown in the HTML report.

This page describes what is supported. Features like custom annotations, conditional skip, or "expected to fail" are not implemented in the current version; the table at the end summarizes supported vs not supported. Tag-based running is supported; see Tags.

You will learn

  • How to focus tests (run only certain tests)
  • How to skip tests or suites
  • How to run by tag (see Tags)
  • What is not yet supported (custom annotations, conditional skip, etc.)

Focus a test or suite

When you mark tests or suites with only, only those run. All others are skipped. Use this to quickly run one test or one group while developing.

Run only one test

const { describe, it, expect, createBrowser, beforeAll, afterAll } = require('cstesting');

describe('My suite', () => {
  it('this test runs', async () => {
    expect(1).toBe(1);
  });

  it.only('only this test runs', async () => {
    expect(2).toBe(2);
  });

  it('this test is skipped', async () => {
    expect(3).toBe(3);
  });
});

When you use it.only, only that test runs in the whole project (across all loaded files). The other tests in the same suite are skipped.

Run only one suite

describe('this suite runs', () => {
  it('test one', () => {});
  it('test two', () => {});
});

describe.only('only this suite runs', () => {
  it('test a', () => {});
  it('test b', () => {});
});

describe('this suite is skipped', () => {
  it('test x', () => {});
});

When you use describe.only, only that suite's tests run. All other suites (and their tests) are skipped.

You can combine describe.only and it.only: if any suite or test has only, only the ones marked with only run.


Skip a test or suite

Mark a test or suite as skip so it is not run. Skipped tests are still counted and appear in the terminal summary and in the HTML report under "Skipped".

Skip one test

it.skip('skip this test', async () => {
  // This test is not run.
});

Skip a whole suite

describe.skip('skip this suite', () => {
  it('test one', () => {});
  it('test two', () => {});
});

Use skip when a test is broken, not applicable yet, or you want to disable it without deleting it.


Report

  • Focus (only): Tests/suites without only are skipped when any only is present. They appear in the report as Skipped.
  • Skip: Tests/suites marked with skip are not run and appear as Skipped in the report.

The HTML report has a "Skipped" section listing all skipped tests (both from only and from skip). The terminal output shows: Passed: X Failed: Y Skipped: Z Total: N.


What is not supported (current version)

The following are not implemented in CSTesting. Use the workarounds below if you need similar behavior.

FeatureSupported?Workaround
Focus (it.only, describe.only)Yes
Skip (it.skip, describe.skip)Yes
Expected to fail (run test and expect it to fail)NoRun the test normally; if it fails, that's the outcome. No "must fail" annotation.
Fixme (skip because broken/slow, with message)NoUse it.skip('message') to skip; the message is in the test name only.
Slow (e.g. triple timeout)NoNo per-test timeout or "slow" annotation. Use a longer global timeout or split slow tests.
Tags (e.g. @fast, @slow in title or options)NoTag-based running is supported; see Tags. For annotation-style tags in title, put keywords in the test/suite name and run by file or folder (e.g. npx cstesting tests/fast/). No --grep by tag.
Custom annotations (type + description, e.g. issue URL)NoNo annotation API; report does not show custom annotations. Add context in the test name or in step() text.
Conditional skip (e.g. skip if browser is Firefox)NoCSTesting runs one browser (Chrome). Use a normal if and return early, or skip the whole suite with describe.skip if needed.
Runtime annotations (add annotation during test)NoNo test.info() or similar. Use step('description') to add steps that appear in the report.
Filter by tag from CLI (--grep, --grep-invert)NoFilter by path/pattern only: npx cstesting path/to/file.test.js or npx cstesting tests/smoke/.

Summary

ActionSyntaxEffect
Focus one testit.only('name', fn)Only this test runs (others skipped).
Focus one suitedescribe.only('name', fn)Only tests in this suite run.
Skip one testit.skip('name', fn)This test is not run (reported as skipped).
Skip one suitedescribe.skip('name', fn)No tests in this suite run (all reported as skipped).

Skipped tests (from only or skip) are included in the total count and listed in the HTML report under "Skipped". Tags, custom annotations, conditional skip, and grep by tag are not available in the current version.