This brings Jest to MW Core so that Vue components can more easily be tested. Packages ending with 'icons.json' are auto-mapped to the @wikimedia/codex-icons package, establishing a new convention. Jest is needed for testing Vue, but can be used for general JS testing as well. Documentation to come at https://www.mediawiki.org/wiki/Jest Usage: to run the tests, run "npx jest" or "npm run jest" in the root folder. This could be aliased to a "test:unit" script in package.json if desired. In order to make a Vue component testable, it is required to follow the `module.exports = exports` pattern. See: https://nodejs.org/api/modules.html#exports-shortcut A default jest.setup.js is added that mocks Core's mw global object, as well as providing the $i18n Vue plugin. This is based on Extension:GrowthExperiments (GPL-3.0-or-later). See https://w.wiki/B9vM An initial test for mediawiki.special.block is added, exemplifying how to mock calls to mw.config.get(). NOTE: The "overrides" added to package.json is a temporary measure to get around a current issue with caniuse-lite and the stylelint plugin that relies on it. See: https://github.com/RJWadley/stylelint-no-unsupported-browser-features/issues/299 Bug: T251790 Change-Id: I1af15e038d17b0f1c645fc5debf9db5846f6215c
23 lines
398 B
JSON
23 lines
398 B
JSON
{
|
|
"root": true,
|
|
"extends": [
|
|
"wikimedia/client-common",
|
|
"wikimedia/language/es2020",
|
|
"wikimedia/jquery",
|
|
"wikimedia/mediawiki"
|
|
],
|
|
"parserOptions": {
|
|
"sourceType": "module"
|
|
},
|
|
"env": {
|
|
"browser": true,
|
|
"jest": true
|
|
},
|
|
"globals": {
|
|
"global": "writable"
|
|
},
|
|
"rules": {
|
|
"compat/compat": [ "error", "last 2 chrome versions, last 2 firefox versions" ],
|
|
"max-len": "off"
|
|
}
|
|
}
|