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

Changes expect().resolves.toThrow behaviour to more closely match jest #14936

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

pfgithub
Copy link
Contributor

@pfgithub pfgithub commented Nov 1, 2024

What does this PR do?

Fixes #14076

toThrow is for functions, like expect(() => {throw ...}).toThrow(), but jest also allows it to be used with resolves/rejects if the value is an error: expect(Promise.resolve(new Error("abc"))).resolves.toThrow("abc").

Previously, bun's implementation allowed any result to count as throwing, for example expect(Promise.resolve("abc")).resolves.toThrow("abc"). This updates bun:test to match jest and only count an Error result throwing.

  • Documentation or TypeScript types (it's okay to leave the rest blank in this case)
  • Code changes

How did you verify your code works?

  • I checked the lifetime of memory allocated to verify it's (1) freed and (2) only freed when it should be
  • I included a test for the new code, or an existing test covers it
  • N/A JSValue used outside outside of the stack is either wrapped in a JSC.Strong or is JSValueProtect'ed
  • I wrote TypeScript/JavaScript tests and they pass locally (bun-debug test test-file-name.test)

@robobun
Copy link

robobun commented Nov 1, 2024

@pfgithub, your commit aef5c45 has 7 failures in #5545:

  • test/js/web/fetch/fetch-preconnect.test.ts - 1 failing on 🍎 aarch64
  • test/js/node/test/parallel/crypto-webcrypto-aes-decrypt-tag-too-small.test.js - 1 failing on 🍎 aarch64
  • test/js/node/test/parallel/crypto-webcrypto-aes-decrypt-tag-too-small.test.js - 1 failing on 🍎 aarch64
  • test/js/node/test/parallel/crypto-webcrypto-aes-decrypt-tag-too-small.test.js - 1 failing on 🪟 x64
  • test/js/node/test/parallel/crypto-webcrypto-aes-decrypt-tag-too-small.test.js - 1 failing on 🪟 x64-baseline
  • test/js/node/test/parallel/crypto-webcrypto-aes-decrypt-tag-too-small.test.js - 1 failing on 🐧 x64
  • test/js/node/test/parallel/crypto-webcrypto-aes-decrypt-tag-too-small.test.js - 1 failing on 🐧 x64-baseline
  • test/js/node/test/parallel/crypto-webcrypto-aes-decrypt-tag-too-small.test.js - 1 failing on 🐧 x64
  • test/js/node/test/parallel/crypto-webcrypto-aes-decrypt-tag-too-small.test.js - 1 failing on 🐧 x64
  • test/js/node/test/parallel/crypto-webcrypto-aes-decrypt-tag-too-small.test.js - 1 failing on 🐧 x64-baseline
  • test/js/node/test/parallel/crypto-webcrypto-aes-decrypt-tag-too-small.test.js - 1 failing on 🐧 x64-baseline
  • test/js/node/test/parallel/crypto-webcrypto-aes-decrypt-tag-too-small.test.js - 1 failing on 🪟 x64
  • test/js/node/test/parallel/crypto-webcrypto-aes-decrypt-tag-too-small.test.js - 1 failing on 🍎 x64
  • test/js/node/test/parallel/crypto-webcrypto-aes-decrypt-tag-too-small.test.js - 1 failing on 🐧 aarch64
  • test/js/node/test/parallel/crypto-webcrypto-aes-decrypt-tag-too-small.test.js - 1 failing on 🐧 aarch64
  • test/js/node/test/parallel/crypto-webcrypto-aes-decrypt-tag-too-small.test.js - 1 failing on 🐧 aarch64
  • test/js/node/test/parallel/crypto-webcrypto-aes-decrypt-tag-too-small.test.js - 1 failing on 🪟 x64-baseline
  • test/js/node/test/parallel/crypto-webcrypto-aes-decrypt-tag-too-small.test.js - 1 failing on 🍎 x64
  • test/js/web/fetch/client-fetch.test.ts - 1 failing on 🪟 x64-baseline
  • test/js/web/fetch/client-fetch.test.ts - 1 failing on 🪟 x64
  • test/js/web/fetch/client-fetch.test.ts - 1 failing on 🍎 aarch64
  • test/js/web/fetch/client-fetch.test.ts - 1 failing on 🍎 aarch64
  • test/js/web/fetch/client-fetch.test.ts - 1 failing on 🐧 x64
  • test/js/web/fetch/client-fetch.test.ts - 1 failing on 🐧 x64-baseline
  • test/js/web/fetch/client-fetch.test.ts - 1 failing on 🐧 x64
  • test/js/web/fetch/client-fetch.test.ts - 1 failing on 🐧 x64
  • test/js/web/fetch/client-fetch.test.ts - 1 failing on 🐧 x64-baseline
  • test/js/web/fetch/client-fetch.test.ts - 1 failing on 🐧 x64-baseline
  • test/js/web/fetch/client-fetch.test.ts - 1 failing on 🪟 x64-baseline
  • test/js/web/fetch/client-fetch.test.ts - 1 failing on 🪟 x64
  • test/js/web/fetch/client-fetch.test.ts - 1 failing on 🐧 aarch64
  • test/js/web/fetch/client-fetch.test.ts - 1 failing on 🐧 aarch64
  • test/js/web/fetch/client-fetch.test.ts - 1 failing on 🐧 aarch64
  • test/js/web/fetch/client-fetch.test.ts - 1 failing on 🍎 x64
  • test/js/web/fetch/client-fetch.test.ts - 1 failing on 🍎 x64
  • test/cli/hot/hot.test.ts - 1 failing on 🪟 x64
  • test/cli/run/require-cache.test.ts - 1 failing on 🪟 x64-baseline
  • test/js/bun/resolve/resolve.test.ts - 1 failing on 🪟 x64-baseline
  • test/js/bun/resolve/resolve.test.ts - 1 failing on 🪟 x64
  • test/js/bun/resolve/resolve.test.ts - 1 failing on 🪟 x64-baseline
  • test/js/bun/resolve/resolve.test.ts - 1 failing on 🪟 x64
  • test/cli/install/bun-patch.test.ts - 1 failing on 🍎 aarch64
  • 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.

    false-negative test failure when using expect().resolves.not.toThrow()
    2 participants