Skip to content

@std/expect - export symbols required for matcher definition #7105

@yannduperis

Description

@yannduperis

Is your feature request related to a problem? Please describe.

I am developing a small library containing testing utilities.
I would like this library to provide an extended expect(), as documented for expect.extend() (which is a great functionality BTW).
I would prefer defining my matchers in individual files and import them (exactly like @std/expect does).

The problem is that I cannot type the context argument because MatcherContext is not part of the package named exports.

Therefore, I cannot write a matcher like that:

export function toHaveSignature(context: MatcherContext, signatureExpr: string) {
   // ...
}

Describe the solution you'd like

I'd like to be able to import MatcherContext from one of the package's entrypoints.

import { MatcherContext  } from "@std/expect";

Or even, if you want to keep the symbol footprint minimal for entrypoint designed for most users, to have a specific entrypoint for users who also need extra symbols for extension:

import { MatcherContext  } from "@std/expect/extend";

or

import { MatcherContext  } from "@std/expect/types";

I guess I could make the necessary changes, this is not especially difficult once agreement has been reached.

Describe alternatives you've considered

  • Just write the matchers in a single file (which, honestly, would be fine for quite some time)
  • Recreate the missing types (i.e. curl https://raw.githubusercontent.com/denoland/std/refs/heads/main/expect/_types.ts > std_expect.types.ts) and keep them in sync when there is a change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions