Skip to content

Commit

Permalink
add timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
leonitousconforti committed Sep 25, 2024
1 parent 4fd9392 commit 082cee7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
12 changes: 8 additions & 4 deletions packages/vitest/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ export const addEqualityTesters: () => void = internal.addEqualityTesters
export const beforeAllEffect: <E>(
self: (
suite: Readonly<V.RunnerTestSuite | V.RunnerTestFile>
) => Effect.Effect<V.HookCleanupCallback | PromiseLike<V.HookCleanupCallback>, E, never>
) => Effect.Effect<V.HookCleanupCallback | PromiseLike<V.HookCleanupCallback>, E, never>,
timeout?: number
) => void = internal.beforeAll

/**
Expand All @@ -71,14 +72,16 @@ export const beforeEachEffect: <E>(
self: (
ctx: V.TaskContext<V.RunnerCustomCase<object> | V.RunnerTestCase<object>> & V.TestContext & object,
suite: V.RunnerTestSuite
) => Effect.Effect<V.HookCleanupCallback | PromiseLike<V.HookCleanupCallback>, E, never>
) => Effect.Effect<V.HookCleanupCallback | PromiseLike<V.HookCleanupCallback>, E, never>,
timeout?: number
) => void = internal.beforeEach

/**
* @since 1.1.0
*/
export const afterAllEffect: <E>(
self: (suite: Readonly<V.RunnerTestSuite | V.RunnerTestFile>) => Effect.Effect<void | PromiseLike<void>, E, never>
self: (suite: Readonly<V.RunnerTestSuite | V.RunnerTestFile>) => Effect.Effect<void | PromiseLike<void>, E, never>,
timeout?: number
) => void = internal.afterAll

/**
Expand All @@ -88,7 +91,8 @@ export const afterEachEffect: <E>(
self: (
ctx: V.TaskContext<V.RunnerCustomCase<object> | V.RunnerTestCase<object>> & V.TestContext & object,
suite: V.RunnerTestSuite
) => Effect.Effect<void | PromiseLike<void>, E, never>
) => Effect.Effect<void | PromiseLike<void>, E, never>,
timeout?: number
) => void = internal.afterEach

/**
Expand Down
20 changes: 12 additions & 8 deletions packages/vitest/src/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,29 +86,33 @@ export const addEqualityTesters = () => {
export const beforeAll = <E>(
self: (
suite: Readonly<V.RunnerTestSuite | V.RunnerTestFile>
) => Effect.Effect<V.HookCleanupCallback | PromiseLike<V.HookCleanupCallback>, E, never>
): void => V.beforeAll((suite) => runHook(self(suite)))
) => Effect.Effect<V.HookCleanupCallback | PromiseLike<V.HookCleanupCallback>, E, never>,
timeout?: number
): void => V.beforeAll((suite) => runHook(self(suite)), timeout)

/** @internal */
export const beforeEach = <E>(
self: (
ctx: V.TaskContext<V.RunnerCustomCase<object> | V.RunnerTestCase<object>> & V.TestContext & object,
suite: V.RunnerTestSuite
) => Effect.Effect<V.HookCleanupCallback | PromiseLike<V.HookCleanupCallback>, E, never>
): void => V.beforeEach((ctx, suite) => runHook(self(ctx, suite)))
) => Effect.Effect<V.HookCleanupCallback | PromiseLike<V.HookCleanupCallback>, E, never>,
timeout?: number
): void => V.beforeEach((ctx, suite) => runHook(self(ctx, suite)), timeout)

/** @internal */
export const afterAll = <E>(
self: (suite: Readonly<V.RunnerTestSuite | V.RunnerTestFile>) => Effect.Effect<void | PromiseLike<void>, E, never>
): void => V.afterAll((suite) => runHook(self(suite)))
self: (suite: Readonly<V.RunnerTestSuite | V.RunnerTestFile>) => Effect.Effect<void | PromiseLike<void>, E, never>,
timeout?: number
): void => V.afterAll((suite) => runHook(self(suite)), timeout)

/** @internal */
export const afterEach = <E>(
self: (
ctx: V.TaskContext<V.RunnerCustomCase<object> | V.RunnerTestCase<object>> & V.TestContext & object,
suite: V.RunnerTestSuite
) => Effect.Effect<void | PromiseLike<void>, E, never>
): void => V.afterEach((ctx, suite) => runHook(self(ctx, suite)))
) => Effect.Effect<void | PromiseLike<void>, E, never>,
timeout?: number
): void => V.afterEach((ctx, suite) => runHook(self(ctx, suite)), timeout)

/** @internal */
const makeTester = <R, E2 = never>(
Expand Down

0 comments on commit 082cee7

Please sign in to comment.