Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
docs: globalThis
  • Loading branch information
maxbeatty committed Mar 12, 2023
1 parent 2148f98 commit 578a4b4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
4 changes: 1 addition & 3 deletions README.md
Expand Up @@ -37,7 +37,7 @@ convenience to the shorthand `td`:
import * as td from 'testdouble'

// CommonJS modules (e.g. Node.js)
global.td = require('testdouble')
globalThis.td = require('testdouble')

// Global set in our browser distribution
window.td
Expand Down Expand Up @@ -583,5 +583,3 @@ directory:
* [td.matchers](/docs/5-stubbing-results.md#loosening-stubbings-with-argument-matchers)
and [custom matchers](/docs/8-custom-matchers.md#custom-argument-matchers) for
configuring more advanced stubbings and verifications


4 changes: 2 additions & 2 deletions docs/1-installation.md
Expand Up @@ -15,7 +15,7 @@ test suite and to name that global something brief. We've been accustomed to
using `td`, so in a test helper loaded before your tests:

```
global.td = require('testdouble')
globalThis.td = require('testdouble')
```

All examples in these documents will assume `testdouble` is available as `td`.
Expand Down Expand Up @@ -64,7 +64,7 @@ without any test library at all.

Our browser distribution sets the library on a global variable named `window.td`.
In Node.js, the library is loaded via `require('testdouble')`, as you might
expect (though we recommend assigning it to `global.td` in a test helper, for
expect (though we recommend assigning it to `globalThis.td` in a test helper, for
terseness sake).

You're welcome to address testdouble.js or any of its functions however you prefer,
Expand Down
6 changes: 2 additions & 4 deletions script/repl
Expand Up @@ -4,8 +4,6 @@ require('ts-node/register')
var repl = require('repl')

console.log('💚 Let\'s play with testdouble.js! 💚')
global.td = require('../src')
global.l = require('lodash')
globalThis.td = require('../src')
globalThis.l = require('lodash')
repl.start({prompt: 'td > ', useGlobal: true})


0 comments on commit 578a4b4

Please sign in to comment.