3 module.exports = function ( grunt ) {
5 var wgServer = process.env.MW_SERVER,
6 wgScriptPath = process.env.MW_SCRIPT_PATH,
9 grunt.loadNpmTasks( 'grunt-banana-checker' );
10 grunt.loadNpmTasks( 'grunt-contrib-copy' );
11 grunt.loadNpmTasks( 'grunt-contrib-watch' );
12 grunt.loadNpmTasks( 'grunt-eslint' );
13 grunt.loadNpmTasks( 'grunt-jsonlint' );
14 grunt.loadNpmTasks( 'grunt-karma' );
15 grunt.loadNpmTasks( 'grunt-stylelint' );
17 karmaProxy[ wgScriptPath ] = {
18 target: wgServer + wgScriptPath,
29 '!resources/src/jquery.tipsy/**',
30 '!resources/src/jquery/jquery.farbtastic.js',
31 '!resources/src/mediawiki.libs/**',
32 // Third-party code of PHPUnit coverage report
35 // Explicitly say "**/*.js" here in case of symlinks
36 '!extensions/**/*.js',
38 // Skip functions aren't even parseable
39 '!resources/src/dom-level2-skip.js',
40 '!resources/src/es5-skip.js',
41 '!resources/src/mediawiki.hidpi-skip.js'
47 '!{docs/js,extensions,node_modules,skins,vendor}/**'
52 disallowBlankTranslations: false
54 core: 'languages/i18n/',
55 api: 'includes/api/i18n/',
56 installer: 'includes/installer/i18n/'
62 src: '{resources/src,mw-config}/**/*.{css,less}'
66 '.{stylelintrc,eslintrc.json}',
68 '!{docs,extensions,node_modules,skins,vendor}/**'
76 pattern: wgServer + wgScriptPath + '/index.php?title=Special:JavaScriptTest/qunit/export',
82 frameworks: [ 'qunit' ],
83 reporters: [ 'progress' ],
86 // Some tests in extensions don't yield for more than the default 10s (T89075)
87 browserNoActivityTimeout: 60 * 1000
90 browsers: [ 'Chrome' ]
93 browsers: [ 'Chromium' ]
96 browsers: [ 'Chrome', 'Firefox' ]
101 src: 'resources/**/*',
102 dest: 'docs/js/modules',
104 rename: function ( dest, src ) {
105 return require( 'path' ).join( dest, src.replace( 'resources/', '' ) );
111 grunt.registerTask( 'assert-mw-env', function () {
112 if ( !process.env.MW_SERVER ) {
113 grunt.log.error( 'Environment variable MW_SERVER must be set.\n' +
114 'Set this like $wgServer, e.g. "http://localhost"'
117 if ( !process.env.MW_SCRIPT_PATH ) {
118 grunt.log.error( 'Environment variable MW_SCRIPT_PATH must be set.\n' +
119 'Set this like $wgScriptPath, e.g. "/w"' );
121 return !!( process.env.MW_SERVER && process.env.MW_SCRIPT_PATH );
124 grunt.registerTask( 'lint', [ 'eslint', 'banana', 'stylelint' ] );
125 grunt.registerTask( 'qunit', [ 'assert-mw-env', 'karma:main' ] );
127 grunt.registerTask( 'test', [ 'lint' ] );
128 grunt.registerTask( 'default', 'test' );