bun
bun copied to clipboard
[bun:test] Implement `beforeEachFile` and `afterEachFile` hooks
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.
❌ @Jarred-Sumner, your commit has failing tests :(
💪 2 failing tests Darwin AARCH64
test/cli/install/bun-install.test.ts1 failingtest/js/bun/http/serve.test.ts3 failing
💻 4 failing tests Darwin x64 baseline
test/cli/install/bun-create.test.ts2 failingtest/cli/install/registry/bun-install-registry.test.ts4 failingtest/js/bun/http/serve.test.ts1 failingtest/js/web/workers/worker.test.ts1 failing
💻 3 failing tests Darwin x64
test/cli/install/bun-create.test.ts2 failingtest/js/bun/http/serve.test.ts1 failingtest/js/web/workers/worker.test.ts1 failing
🐧💪 2 failing tests Linux AARCH64
test/cli/install/registry/bun-install-registry.test.ts1 failingtest/js/node/http2/node-http2.test.js1 failing
🐧🖥 1 failing tests Linux x64
test/cli/install/registry/bun-install-registry.test.ts1 failing
🪟💻 11 failing tests Windows x64 baseline
test/cli/install/bunx.test.ts1 failingtest/cli/install/migration/migrate.test.ts1 failingtest/integration/esbuild/esbuild.test.ts1 failingtest/integration/next-pages/test/dev-server-ssr-100.test.ts1 failingtest/integration/next-pages/test/dev-server.test.ts1 failingtest/integration/next-pages/test/next-build.test.ts1 failingtest/js/bun/shell/bunshell.test.ts1 failingtest/js/node/dns/node-dns.test.js2 failingtest/js/node/process/process.test.js2 failingtest/js/web/fetch/fetch.tls.test.ts1 failingtest/js/web/websocket/websocket.test.jsSTATUS_SEVERITY_ERROR
🪟💻 11 failing tests Windows x64
test/cli/install/bunx.test.ts1 failingtest/cli/install/migration/migrate.test.ts1 failingtest/cli/install/registry/bun-install-registry.test.ts5 failingtest/integration/next-pages/test/dev-server-ssr-100.test.ts1 failingtest/integration/next-pages/test/dev-server.test.ts1 failingtest/integration/next-pages/test/next-build.test.ts1 failingtest/js/bun/shell/bunshell.test.ts1 failingtest/js/node/child_process/child_process.test.ts1 failingtest/js/node/dns/node-dns.test.js2 failingtest/js/node/process/process.test.js2 failingtest/js/web/websocket/websocket.test.jsSTATUS_SEVERITY_ERROR
This pull request is stale and may be closed due to inactivity.
This is still needed to be able to port many test suites.