auto-globals

add browser globals on every test and remove when it is done

Usage no npm install needed!

<script type="module">
  import autoGlobals from 'https://cdn.skypack.dev/auto-globals';
</script>

README

auto globals NPM version Dependency Status Build Status Coverage Status

Add browser globals on every test, and remove when it is done.

Install

npm i auto-globals

Example

const autoGlobals = require('auto-globals');
const tape = autoGlobals(require('tape'));

const fn = () => {
    document.body.addEventListener('click', console.log);
};

test('lib: arguments', (t, {document}) => {
    fn();
    
    t.ok(document.body.calledWith('click', console.log), 'should call addEventListener');
    t.end();
});

Related

  • try-catch - functional try-catch wrapper.
  • try-to-catch - functional try-catch wrapper for promises.
  • try-to-tape - wrap tape async functions and show error on reject.

License

MIT