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

Support functions as the description for describe #17100

Open
dwjohnston opened this issue Feb 6, 2025 · 1 comment · May be fixed by #17218
Open

Support functions as the description for describe #17100

dwjohnston opened this issue Feb 6, 2025 · 1 comment · May be fixed by #17218
Labels
bun:test Something related to the `bun test` runner enhancement New feature or request good first issue Something that would be good for new contributors

Comments

@dwjohnston
Copy link

dwjohnston commented Feb 6, 2025

What is the problem this feature would solve?

In Jest and Vitest we can write tests like this:

import { describe, expect, test } from 'vitest'
import { myFunctionUnderTest } from './sum.js'

//                 👇 - direct reference to the function, not a string. 
describe(myFunctionUnderTest, () =>{
  test('adds 1 + 2 to equal 3', () => {
    expect(myFunctionUnderTest(1, 2)).toBe(3)    
  })
})

And this will output like this:

 ✓ src/sum.test.js (1 test) 1ms
   ✓ myFunctionUnderTest > adds 1 + 2 to equal 3

This is a nice bit of convenience for writing tests -

  1. Saves having to write a string ourselves
  2. If we rename the function, the test description will automatically be updated

What is the feature you are proposing to solve the problem?

Support passing functions as description parameter in the same manner.

What alternatives have you considered?

No response

@dwjohnston dwjohnston added the enhancement New feature or request label Feb 6, 2025
@RiskyMH RiskyMH added the bun:test Something related to the `bun test` runner label Feb 6, 2025
@paperclover paperclover added the good first issue Something that would be good for new contributors label Feb 6, 2025
@CountryHands
Copy link

Id like to take a swing at this issue, if its still open for the taking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bun:test Something related to the `bun test` runner enhancement New feature or request good first issue Something that would be good for new contributors
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants