Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mock-mediawiki

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mock-mediawiki

MediaWiki JS interface mocking in Node.js

  • 1.0.0
  • npm
  • Socket score

Version published
Weekly downloads
296
increased by428.57%
Maintainers
1
Weekly downloads
 
Created
Source

mock-mediawiki

Honest MediaWiki JS interface mocking in Node.js.

No unnecessary changes to the original source files. Directly copied from MediaWiki core with bare minimum modifications.

Licensed under the Lesser General Public License. Can be used from any repository regardless of license. (Note that on the other hand, MW source code copied directly may only be pasted into repos with GPL-compatible licenses).

How to use

Use with Jest

If you're using Jest's default test environment jest-environment-jsdom, just tweak your jest.config.js to include:

    "setupFilesAfterEnv": ["mock-mediawiki"] 

Done! All your Jest tests will now have access to mw and $ as globals. This setup works with both CommonJS module format and ESM.

Jest exposes globally most browser-only globals available via jsdom. So if your gadget code includes references to HTMLSpanElement or XMLDocument et al, they'll just work!

Use with other test runners

Other test runners don't usually have jsdom integrated. You need to install jsdom separately (npm i -D jsdom) and then include the following in your test files:

CommonJS:

require('mock-mediawiki/with-jsdom');

ESM:

import 'mock-mediawiki/with-jsdom';

It is assumed that ESM tests undergo transformation to CommonJS as part of some build step. Use of this package with native Node.js ESM packages is not supported because of its internal reliance on require().


If your tests are in TypeScript, you'll need to additionally have types-mediawiki. However, note that types-mediawiki covers type definitions for more modules, so TypeScript-based IntelliSense can be misleading.

TODO

[ PRs Welcome ]

  • Add mw.Uri
  • Add mw.language maybe?

Keywords

FAQs

Package last updated on 24 Feb 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc