Skip to content

Commit 5e72c7d

Browse files
committed
Note issue on use with jsdom-global in node.js v14 and older
1 parent 7ecdc83 commit 5e72c7d

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Or even better, consider using [jsdom-global](https://www.npmjs.com/package/jsdo
4646

4747
```js
4848
require('jsdom-global')(undefined, { /*... jsdom config parameters ...*/ });
49+
global.performance = window.performance; // Required for node.js v14 and older, until https://github.com/rstacruz/jsdom-global/issues/59 is resolved
4950
require('mock-mediawiki');
5051
```
5152

tests/jest.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
describe('test', function () {
2+
describe('test with jest', function () {
33

44
test('mw.Title works with correct wgLegalTitleChars mocking', () => {
55
expect(new mw.Title('Template:Foo').getMainText()).toBe('Foo');
@@ -103,4 +103,4 @@ function sleep(ms) {
103103
resolve();
104104
}, ms);
105105
}));
106-
}
106+
}

tests/jsdom-global.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
const assert = require('assert');
22

33
require('jsdom-global')(undefined, { url: 'https://test.wikipedia.org', runScripts: 'dangerously' });
4+
global.performance = window.performance; // See readme
45
require('../index');
56

6-
describe('test with jsdom-global', function () {
7+
describe('test using jsdom-global and mocha', function () {
78

89
it('mw.Title works with correct wgLegalTitleChars mocking', () => {
910
assert.strictEqual(new mw.Title('Template:Foo').getMainText(), 'Foo');

tests/mocha.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const assert = require('assert');
22

33
require('../with-jsdom'); // jest's deps include jsdom, so we haven't explicitly put jsdom as a dev-dep!
44

5-
describe('test', function () {
5+
describe('test using bundled with-jsdom and mocha', function () {
66

77
it('mw.Title works with correct wgLegalTitleChars mocking', () => {
88
assert.strictEqual(new mw.Title('Template:Foo').getMainText(), 'Foo');
@@ -107,4 +107,4 @@ function sleep(ms) {
107107
resolve();
108108
}, ms);
109109
}));
110-
}
110+
}

0 commit comments

Comments
 (0)