Skip to content

Feature Request: Make this plugin work with bun #1431

@TkDodo

Description

@TkDodo

bun had a 1.0 release recently, and a lot of things from its test runner work like jest. Mostly, it's a drop-in replacement to do:

- import { describe, expect, it } from '@jest/globals'
+ import { describe, expect, it } from 'bun:test'

however, changing the import like that makes the eslint-plugin-jest no longer work, because the rules only apply to imports from '@jest/globals', as we can see here:

// the identifier is imported from @jest/globals,
// so return the original import name
if (maybeImport.source === '@jest/globals') {

We are currently patching this plugin to also detect bun imports by extending this if statement:

if (maybeImport.source === '@jest/globals' || maybeImport.source === 'bun:test') { 

I'd be happy to hear your thoughts on making this work either out of the box, or making it configurable. I'm also up for contributing a PR.

Thanks 🙏

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions