Effection Logo
@effectionx/vitestv0.1.0thefrontside/effectionx
NPM Badge with published version
import { } from "@effectionx/vitest"

Vitest

Adapter to add an effection scope to the test suite to allow writing a function* () {} test function.

import {
  assert,
  beforeAll,
  beforeEach,
  describe,
  expect,
  it,
} from "@effectionx/vitest";

describe("suite name", () => {
  let connection: Connection;

  beforeAll(function* () {
    // Runs once before all tests in this suite
    connection = yield* connectToDatabase();
  });

  beforeEach(function* () {
    // Runs before each test
    yield* connection.clear();
  });

  it("foo", function* () {
    const thing = yield* otherThing();
    assert.equal(Math.sqrt(4), thing);
  });

  it("bar", function* () {
    const thing = yield* otherThing();
    expect(1 + 1).eq(thing);
  });

  it("snapshot", function* () {
    const thing = yield* otherThing();
    expect(thing).toMatchSnapshot();
  });
});

API Reference

const describe:

Type

function beforeAll(op: () => Operation<void>): void

Parameters

op: () => Operation<void>

Return Type

void

function beforeEach(op: () => Operation<void>): void

Parameters

op: () => Operation<void>

Return Type

void

const only: (desc: string, op?: () => Operation<void>, timeout?: number) => void

Type

(desc: string, opoptional: () => Operation<void>, timeoutoptional: number) => void

const skip: (desc: string, _op?: () => Operation<void>, _timeout?: number) => void

Type

(desc: string, _opoptional: () => Operation<void>, _timeoutoptional: number) => void

function it(desc: string, op?: () => Operation<void>, timeout?: number): void

Parameters

desc: string

opoptional: () => Operation<void>

timeoutoptional: number

Return Type

void

namespace it

Additional properties on the it function.

Variables

v it.only

No documentation available.

v it.skip

No documentation available.

function* captureError<T>(op: Operation<T>): Operation<Error>

Type Parameters

T

Parameters

op: Operation<T>

Return Type

Operation<Error>