Tests: fix weird failure in Edge 16 CSS
[jquery.git] / Gruntfile.js
blob431e87557748c7d12ba5a208e1d56c04e7c88e68
1 module.exports = function( grunt ) {
2 "use strict";
4 function readOptionalJSON( filepath ) {
5 var stripJSONComments = require( "strip-json-comments" ),
6 data = {};
7 try {
8 data = JSON.parse( stripJSONComments(
9 fs.readFileSync( filepath, { encoding: "utf8" } )
10 ) );
11 } catch ( e ) {}
12 return data;
15 var fs = require( "fs" ),
16 gzip = require( "gzip-js" );
18 if ( !grunt.option( "filename" ) ) {
19 grunt.option( "filename", "jquery.js" );
22 grunt.initConfig( {
23 pkg: grunt.file.readJSON( "package.json" ),
24 dst: readOptionalJSON( "dist/.destination.json" ),
25 "compare_size": {
26 files: [ "dist/jquery.js", "dist/jquery.min.js" ],
27 options: {
28 compress: {
29 gz: function( contents ) {
30 return gzip.zip( contents, {} ).length;
33 cache: "build/.sizecache.json"
36 babel: {
37 options: {
38 sourceMap: "inline",
39 retainLines: true,
40 plugins: [ "transform-es2015-for-of" ]
42 nodeSmokeTests: {
43 files: {
44 "test/node_smoke_tests/lib/ensure_iterability.js":
45 "test/node_smoke_tests/lib/ensure_iterability_es6.js"
49 build: {
50 all: {
51 dest: "dist/jquery.js",
52 minimum: [
53 "core",
54 "selector"
57 // Exclude specified modules if the module matching the key is removed
58 removeWith: {
59 ajax: [ "manipulation/_evalUrl", "event/ajax" ],
60 callbacks: [ "deferred" ],
61 css: [ "effects", "dimensions", "offset" ],
62 "css/showHide": [ "effects" ],
63 deferred: {
64 remove: [ "ajax", "effects", "queue", "core/ready" ],
65 include: [ "core/ready-no-deferred" ]
67 sizzle: [ "css/hiddenVisibleSelectors", "effects/animatedSelector" ]
71 npmcopy: {
72 all: {
73 options: {
74 destPrefix: "external"
76 files: {
77 "sizzle/dist": "sizzle/dist",
78 "sizzle/LICENSE.txt": "sizzle/LICENSE.txt",
80 "npo/npo.js": "native-promise-only/npo.js",
82 "qunit/qunit.js": "qunitjs/qunit/qunit.js",
83 "qunit/qunit.css": "qunitjs/qunit/qunit.css",
84 "qunit/LICENSE.txt": "qunitjs/LICENSE.txt",
86 "qunit-assert-step/qunit-assert-step.js":
87 "qunit-assert-step/qunit-assert-step.js",
88 "qunit-assert-step/MIT-LICENSE.txt":
89 "qunit-assert-step/MIT-LICENSE.txt",
91 "requirejs/require.js": "requirejs/require.js",
93 "sinon/sinon.js": "sinon/pkg/sinon.js",
94 "sinon/LICENSE.txt": "sinon/LICENSE"
98 jsonlint: {
99 pkg: {
100 src: [ "package.json" ]
103 eslint: {
104 options: {
106 // See https://github.com/sindresorhus/grunt-eslint/issues/119
107 quiet: true
110 // We have to explicitly declare "src" property otherwise "newer"
111 // task wouldn't work properly :/
112 dist: {
113 src: "dist/jquery.js"
115 dev: {
116 src: [ "src/**/*.js", "Gruntfile.js", "test/**/*.js", "build/**/*.js" ]
119 testswarm: {
120 tests: [
122 // A special module with basic tests, meant for
123 // not fully supported environments like Android 2.3,
124 // jsdom or PhantomJS. We run it everywhere, though,
125 // to make sure tests are not broken.
126 "basic",
128 "ajax",
129 "animation",
130 "attributes",
131 "callbacks",
132 "core",
133 "css",
134 "data",
135 "deferred",
136 "deprecated",
137 "dimensions",
138 "effects",
139 "event",
140 "manipulation",
141 "offset",
142 "queue",
143 "selector",
144 "serialize",
145 "support",
146 "traversing",
147 "tween"
150 karma: {
151 options: {
152 customContextFile: "test/karma.context.html",
153 customDebugFile: "test/karma.debug.html",
154 frameworks: [ "qunit" ],
155 middleware: [ "mockserver" ],
156 plugins: [
157 "karma-*",
159 "middleware:mockserver": [
160 "factory",
161 require( "./test/middleware-mockserver.js" )
165 files: [
166 "test/data/jquery-1.9.1.js",
167 "external/qunit-assert-step/qunit-assert-step.js",
168 "external/sinon/sinon.js",
169 "external/npo/npo.js",
170 "external/requirejs/require.js",
171 "test/data/testinit.js",
173 "dist/jquery.min.js",
175 // Replacement for testinit.js#loadTests()
176 "test/data/testrunner.js",
177 "test/unit/basic.js",
178 "test/unit/core.js",
179 "test/unit/callbacks.js",
180 "test/unit/deferred.js",
181 "test/unit/deprecated.js",
182 "test/unit/support.js",
183 "test/unit/data.js",
184 "test/unit/queue.js",
185 "test/unit/attributes.js",
186 "test/unit/event.js",
187 "test/unit/selector.js",
188 "test/unit/traversing.js",
189 "test/unit/manipulation.js",
190 "test/unit/wrap.js",
191 "test/unit/css.js",
192 "test/unit/serialize.js",
193 "test/unit/ajax.js",
194 "test/unit/effects.js",
195 "test/unit/offset.js",
196 "test/unit/dimensions.js",
197 "test/unit/animation.js",
198 "test/unit/tween.js",
199 "test/unit/ready.js",
201 { pattern: "dist/jquery.js", included: false, served: true },
202 { pattern: "dist/*.map", included: false, served: true },
203 { pattern: "external/qunit/qunit.css", included: false, served: true },
205 pattern: "test/**/*.@(js|css|jpg|html|xml)",
206 included: false,
207 served: true
210 reporters: [ "dots" ],
211 autoWatch: false,
212 concurrency: 3,
213 captureTimeout: 20 * 1000,
215 // To debug tests with Karma:
216 // - Run 'grunt karma:chrome' or 'grunt karma:firefox'
217 // (any karma subtask that has singleRun=false)
218 // - Press "Debug" in the opened browser window.
219 singleRun: false
221 main: {
222 browsers: [ "ChromeHeadless" ],
223 singleRun: true
225 chrome: {
226 browsers: [ "Chrome" ]
228 firefox: {
229 browsers: [ "Firefox" ]
232 watch: {
233 files: [ "<%= eslint.dev.src %>" ],
234 tasks: [ "dev" ]
236 uglify: {
237 all: {
238 files: {
239 "dist/<%= grunt.option('filename').replace('.js', '.min.js') %>":
240 "dist/<%= grunt.option('filename') %>"
242 options: {
243 preserveComments: false,
244 sourceMap: true,
245 sourceMapName:
246 "dist/<%= grunt.option('filename').replace('.js', '.min.map') %>",
247 report: "min",
248 output: {
249 "ascii_only": true,
251 // Support: Android 4.0 only
252 // UglifyJS 3 breaks Android 4.0 if this option is not enabled.
253 // This is in lieu of setting ie8 for all of mangle, compress, and output
254 "ie8": true
256 banner: "/*! jQuery v<%= pkg.version %> | " +
257 "(c) JS Foundation and other contributors | jquery.org/license */",
258 compress: {
259 "hoist_funs": false,
260 loops: false,
261 unused: false,
263 // Support: IE <11
264 // typeofs transformation is unsafe for IE9-10
265 // See https://github.com/mishoo/UglifyJS2/issues/2198
266 typeofs: false
271 } );
273 // Load grunt tasks from NPM packages
274 require( "load-grunt-tasks" )( grunt );
276 // Integrate jQuery specific tasks
277 grunt.loadTasks( "build/tasks" );
279 grunt.registerTask( "lint", [
280 "jsonlint",
282 // Running the full eslint task without breaking it down to targets
283 // would run the dist target first which would point to errors in the built
284 // file, making it harder to fix them. We want to check the built file only
285 // if we already know the source files pass the linter.
286 "eslint:dev",
287 "eslint:dist"
288 ] );
290 grunt.registerTask( "lint:newer", [
291 "newer:jsonlint",
293 // Don't replace it with just the task; see the above comment.
294 "newer:eslint:dev",
295 "newer:eslint:dist"
296 ] );
298 grunt.registerTask( "test:fast", "node_smoke_tests" );
299 grunt.registerTask( "test:slow", "promises_aplus_tests" );
301 grunt.registerTask( "test", [
302 "test:fast",
303 "test:slow"
304 ] );
306 grunt.registerTask( "dev", [
307 "build:*:*",
308 "newer:eslint:dev",
309 "newer:uglify",
310 "remove_map_comment",
311 "dist:*",
312 "qunit_fixture",
313 "compare_size"
314 ] );
316 grunt.registerTask( "default", [
317 "eslint:dev",
318 "build:*:*",
319 "uglify",
320 "remove_map_comment",
321 "dist:*",
322 "qunit_fixture",
323 "eslint:dist",
324 "test:fast",
325 "compare_size"
326 ] );