Skip to content
This repository was archived by the owner on Feb 2, 2026. It is now read-only.
This repository was archived by the owner on Feb 2, 2026. It is now read-only.

Prefer capability sniffing to environment check? #161

Description

@glebec

As per #160, it is technically possible to run code with the environment set to test even if the code isn't actually being run by Mocha. This causes a reference error for code which attempts to use after.

While that isn't the way the codebase is intended to be used, one possible way of making the code more robust is to use capability sniffing:

-if (process.env.NODE_ENV === 'test') {
+if (typeof global.after === 'function') {
   after(...)
}

I'm not 100% sure I prefer this – it is safer, but perhaps less clear.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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