Skip to content

Commit

Permalink
Note issue on use with jsdom-global in node.js v14 and older
Browse files Browse the repository at this point in the history
  • Loading branch information
siddharthvp committed Oct 30, 2021
1 parent 7ecdc83 commit 5e72c7d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Or even better, consider using [jsdom-global](https://www.npmjs.com/package/jsdo

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

Expand Down
4 changes: 2 additions & 2 deletions tests/jest.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

describe('test', function () {
describe('test with jest', function () {

test('mw.Title works with correct wgLegalTitleChars mocking', () => {
expect(new mw.Title('Template:Foo').getMainText()).toBe('Foo');
Expand Down Expand Up @@ -103,4 +103,4 @@ function sleep(ms) {
resolve();
}, ms);
}));
}
}
3 changes: 2 additions & 1 deletion tests/jsdom-global.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
const assert = require('assert');

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

describe('test with jsdom-global', function () {
describe('test using jsdom-global and mocha', function () {

it('mw.Title works with correct wgLegalTitleChars mocking', () => {
assert.strictEqual(new mw.Title('Template:Foo').getMainText(), 'Foo');
Expand Down
4 changes: 2 additions & 2 deletions tests/mocha.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const assert = require('assert');

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

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

it('mw.Title works with correct wgLegalTitleChars mocking', () => {
assert.strictEqual(new mw.Title('Template:Foo').getMainText(), 'Foo');
Expand Down Expand Up @@ -107,4 +107,4 @@ function sleep(ms) {
resolve();
}, ms);
}));
}
}

0 comments on commit 5e72c7d

Please sign in to comment.