0.2.0 • Published 9 months ago

@environment-safe/chai v0.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

environment-safe-chai

Ever since starting to run a single script I have to use an ugly compatibility block to import chai, something like:

import * as chaiModule from 'chai';
const chai = (
   typeof process === 'object' && 
   typeof process.versions === 'object' && 
   typeof process.versions.node !== 'undefined'
)?chaiModule:window.chai;

This works across native node modules, native browser modules and babel (for compatibility). It's also ugly (and potentially updatable in the future), so I'm masking it in this module.

import it with:

import { chai } from 'environment-safe-chai'; 

require it with (only supported in the browser via babel/webpack/browserify):

const { chai } = require( 'environment-safe-chai');