Browse Source

Create register.js (#79)

master
Dmitry Yv 5 years ago
committed by Luke Childs
parent
commit
e8584f6563
  1. 6
      README.md
  2. 4
      register.js
  3. 11
      test/register-entry-must-preload-env.js

6
README.md

@ -83,6 +83,12 @@ import browserEnv from 'browser-env';
browserEnv();
```
`browser-env` can also be preloaded at node startup as:
```sh
node -r browser-env/register test.js
```
## Related
- [`window`](https://github.com/lukechilds/window) - Exports a jsdom window object

4
register.js

@ -0,0 +1,4 @@
'use strict';
const browserEnv = require('.');
browserEnv();

11
test/register-entry-must-preload-env.js

@ -0,0 +1,11 @@
import { spawnSync } from 'child_process';
import test from 'ava';
test(t => {
const { stdout } = spawnSync('node', [
'-r', '../register',
'--eval', 'console.log(typeof window)'
]);
t.not(stdout.toString(), 'undefined');
});
Loading…
Cancel
Save