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

Implement bun test --timeout #3040

Merged
merged 1 commit into from May 24, 2023
Merged

Implement bun test --timeout #3040

merged 1 commit into from May 24, 2023

Conversation

Electroid
Copy link
Contributor

You can now change the default per-test timeout in bun test with the --timeout flag.

bun test --timeout 10
Timeout: test "test" timed out after 10ms
✗ test [18.24ms]

However, this does not change the timeout when test(fn, timeout) is used, such as:

import { test } from "bun:test";
import { sleep } from "bun";

test("test", async () => {
  await sleep(10);
}, 5);

You can change the default per-test timeout in `bun test`:
 > bun test --timeout 10

The default timeout is 5000.
@Electroid Electroid added enhancement New feature or request jest Something related to the `bun test` runner labels May 23, 2023
@@ -360,8 +358,6 @@ pub const TestRunner = struct {
only: bool = false,
last_file: u64 = 0,

timeout_seconds: f64 = 5.0,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was unused.

@@ -35,8 +35,6 @@ const getAllocator = @import("../base.zig").getAllocator;
const JSPrivateDataPtr = @import("../base.zig").JSPrivateDataPtr;
const GetJSPrivateData = @import("../base.zig").GetJSPrivateData;

const default_timeout = std.time.ms_per_min * 5;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed from std.time.ms_per_min to std.time.ms_per_s. This appeared to be a bug, since the default should be 5 seconds, not 5 minutes.

Copy link
Collaborator

@Jarred-Sumner Jarred-Sumner left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Collaborator

@Jarred-Sumner Jarred-Sumner left a comment

Choose a reason for hiding this comment

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

LGTM!

@github-actions
Copy link

@Electroid 27 files with test failures on linux-x64:

  • test/bundler/api.test.ts
  • test/bundler/bundler_browser.test.ts
  • test/bundler/bundler_edgecase.test.ts
  • test/bundler/bundler_jsx.test.ts
  • test/bundler/bundler_naming.test.ts
  • test/bundler/bundler_plugin.test.ts
  • test/bundler/esbuild/dce.test.ts
  • test/bundler/esbuild/default.test.ts
  • test/bundler/esbuild/extra.test.ts
  • test/bundler/esbuild/importstar.test.ts
  • test/bundler/esbuild/loader.test.ts
  • test/bundler/esbuild/packagejson.test.ts
  • test/bundler/esbuild/splitting.test.ts
  • test/bundler/esbuild/ts.test.ts
  • test/bundler/esbuild/tsconfig.test.ts
  • test/cli/hot/hot.test.ts
  • test/cli/run/preload-test.test.js
  • test/cli/run/run-cjs.test.ts
  • test/js/bun/jsc/bun-jsc.test.ts
  • test/js/bun/plugin/plugins.test.ts
  • test/js/bun/resolve/png/test-png-import.test.js
  • test/js/bun/test/preload-test.test.js
  • test/js/bun/test/snapshot-tests/snapshots/more-snapshots/different-directory.test.ts
  • test/js/bun/test/snapshot-tests/snapshots/more.test.ts
  • test/js/bun/websocket/websocket-server.test.ts
  • test/js/node/child_process/child_process-node.test.js
  • test/transpiler/transpiler.test.js

View test output

#9382cf0586c5b8b9657ea9b698c57bfacfb32db7

@github-actions
Copy link

@Electroid 28 files with test failures on linux-x64-baseline:

  • test/bundler/api.test.ts
  • test/bundler/bundler_browser.test.ts
  • test/bundler/bundler_edgecase.test.ts
  • test/bundler/bundler_jsx.test.ts
  • test/bundler/bundler_naming.test.ts
  • test/bundler/bundler_plugin.test.ts
  • test/bundler/esbuild/dce.test.ts
  • test/bundler/esbuild/default.test.ts
  • test/bundler/esbuild/extra.test.ts
  • test/bundler/esbuild/importstar.test.ts
  • test/bundler/esbuild/loader.test.ts
  • test/bundler/esbuild/packagejson.test.ts
  • test/bundler/esbuild/splitting.test.ts
  • test/bundler/esbuild/ts.test.ts
  • test/bundler/esbuild/tsconfig.test.ts
  • test/cli/hot/hot.test.ts
  • test/cli/run/preload-test.test.js
  • test/cli/run/run-cjs.test.ts
  • test/js/bun/http/serve.test.ts
  • test/js/bun/jsc/bun-jsc.test.ts
  • test/js/bun/plugin/plugins.test.ts
  • test/js/bun/resolve/png/test-png-import.test.js
  • test/js/bun/test/preload-test.test.js
  • test/js/bun/test/snapshot-tests/snapshots/more-snapshots/different-directory.test.ts
  • test/js/bun/test/snapshot-tests/snapshots/more.test.ts
  • test/js/bun/websocket/websocket-server.test.ts
  • test/js/node/child_process/child_process-node.test.js
  • test/transpiler/transpiler.test.js

View test output

#9382cf0586c5b8b9657ea9b698c57bfacfb32db7

@github-actions
Copy link

@Electroid 28 files with test failures on bun-darwin-x64-baseline:

  • test/bundler/api.test.ts
  • test/bundler/bundler_browser.test.ts
  • test/bundler/bundler_edgecase.test.ts
  • test/bundler/bundler_jsx.test.ts
  • test/bundler/bundler_naming.test.ts
  • test/bundler/bundler_plugin.test.ts
  • test/bundler/esbuild/dce.test.ts
  • test/bundler/esbuild/default.test.ts
  • test/bundler/esbuild/extra.test.ts
  • test/bundler/esbuild/importstar.test.ts
  • test/bundler/esbuild/loader.test.ts
  • test/bundler/esbuild/packagejson.test.ts
  • test/bundler/esbuild/splitting.test.ts
  • test/bundler/esbuild/ts.test.ts
  • test/bundler/esbuild/tsconfig.test.ts
  • test/cli/run/preload-test.test.js
  • test/cli/run/run-cjs.test.ts
  • test/js/bun/jsc/bun-jsc.test.ts
  • test/js/bun/plugin/plugins.test.ts
  • test/js/bun/resolve/png/test-png-import.test.js
  • test/js/bun/spawn/spawn-streaming-stdin.test.ts
  • test/js/bun/sqlite/sqlite.test.js
  • test/js/bun/test/preload-test.test.js
  • test/js/bun/test/snapshot-tests/snapshots/more-snapshots/different-directory.test.ts
  • test/js/bun/test/snapshot-tests/snapshots/more.test.ts
  • test/js/bun/util/sleepSync.test.ts
  • test/js/web/timers/setTimeout.test.js
  • test/transpiler/transpiler.test.js

View test output

#9382cf0586c5b8b9657ea9b698c57bfacfb32db7

@Electroid
Copy link
Contributor Author

PASS - test/cli/test/bun-test.test.ts
  bun test v0.6.3 (9382cf05)
  
  bun-test.test.ts:
  ✓ bun test > --timeout > must provide a number timeout [7.81ms]
  ✓ bun test > --timeout > must provide non-negative timeout [4.90ms]
  ✓ bun test > --timeout > timeout can be set to 1ms [19.64ms]
  ✓ bun test > --timeout > timeout should default to 5000ms [5024.59ms]
  
   4 pass
   0 fail
   4 expect() calls
  Ran 4 tests across 1 files. 4 total [5.10s]

@Electroid Electroid merged commit c3d402c into main May 24, 2023
15 of 21 checks passed
@Electroid Electroid deleted the feat/cli-timeout branch May 24, 2023 05:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request jest Something related to the `bun test` runner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants