Code Monkey home page Code Monkey logo

jest-without-globals's Introduction

jest-without-globals

package-json releases commits
dt dy dm dw
typings build status code coverage
NPM

Explicitly import Jest globals.

Installation

npm i -D jest-without-globals

(note that jest is a peer dependency)

Usage

import { describe, it, expect } from 'jest-without-globals'

describe('describe should create a section', () => {
  it('it should checkmark', () => {
    expect('').toBe('')
  })
})

All of the functions available in Jest's API, as well as jest and expect, can be imported from jest-without-globals.

Examples

Can take a look at the tests for usage of more of the globals, but basically you can now just import any Jest global.

How it works

Basically just takes Jest's globals and exports them. The source code is currently shorter than this README, so take a look under the hood! :)

Credits

Some inspiration came from this workaround to avoid globals, which I had been using in projects previously. I wanted a package I could re-use in all my projects' tests instead of constantly having to create a helper file and map its name, and so jest-without-globals was born!

Can also see my PR for implementing this directly in Jest. It also adds a noJestGlobals configuration option that would prevent these globals from being inserted into your environment as well (which is something that isn't possible with a simple user-land library like this).

jest-without-globals's People

Contributors

agilgur5 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.