Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bun:test] Implement beforeEachFile and afterEachFile hooks #11027

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Jarred-Sumner
Copy link
Collaborator

What does this PR do?

This adds support for adding a function to call before each test file runs and after each test file runs:

In a preload script:

import {beforeEachFile, afterEachFile} from 'bun:test';

beforeEachFile(() => {
  resetDatabase();
});

In a test:

import {test, expect} from 'bun:test';

test("signup user in database", async () => {
  doSomething();
});

When switching tobun:test from vitest or jest, there currently is no equivalent to setupFiles. This adds an alternative .

How did you verify your code works?

WIP. Needs automated tests.

Copy link

@Jarred-Sumner, your commit has failing tests :(

💪 2 failing tests Darwin AARCH64

💻 4 failing tests Darwin x64 baseline

💻 3 failing tests Darwin x64

🐧💪 2 failing tests Linux AARCH64

🐧🖥 1 failing tests Linux x64

🪟💻 11 failing tests Windows x64 baseline

🪟💻 11 failing tests Windows x64

View logs

Comment on lines +737 to +738
"beforeEachFile",
"beforeAll",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it intended that beforeEachFile runs before beforeAll?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants