Skip to content

Commit 578a4b4

Browse files
author
Max Beatty
committed
docs: globalThis
1 parent 2148f98 commit 578a4b4

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ convenience to the shorthand `td`:
3737
import * as td from 'testdouble'
3838

3939
// CommonJS modules (e.g. Node.js)
40-
global.td = require('testdouble')
40+
globalThis.td = require('testdouble')
4141

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

docs/1-installation.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ test suite and to name that global something brief. We've been accustomed to
1515
using `td`, so in a test helper loaded before your tests:
1616

1717
```
18-
global.td = require('testdouble')
18+
globalThis.td = require('testdouble')
1919
```
2020

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

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

7070
You're welcome to address testdouble.js or any of its functions however you prefer,

script/repl

+2-4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ require('ts-node/register')
44
var repl = require('repl')
55

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

0 commit comments

Comments
 (0)