Skip to content

Prefer capability sniffing to environment check? #161

@glebec

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.

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