Tests: Exclude tests based on compilation flags, not API presence

Introduces a new test API, `includesModule`. The method returns whether
a particular module like "ajax" or "deprecated" is included in the current
jQuery build; it handles the slim build as well. The util was created so that
we don't treat presence of particular APIs to decide whether to run a test as
then if we accidentally remove an API, the tests would still not fail.

Fixes gh-5069
Closes gh-5046
This commit is contained in:
Michał Gołębiowski-Owczarek
2022-06-28 12:39:01 +02:00
committed by GitHub
parent 52f452b2e8
commit fae5fee8b4
24 changed files with 157 additions and 59 deletions

View File

@@ -10,6 +10,7 @@ module.exports = function( grunt ) {
const fs = require( "fs" );
const path = require( "path" );
const rollup = require( "rollup" );
const slimBuildFlags = require( "./lib/slim-build-flags" );
const rollupFileOverrides = require( "./lib/rollup-plugin-file-overrides" );
const Insight = require( "insight" );
const pkg = require( "../../package.json" );
@@ -60,7 +61,6 @@ module.exports = function( grunt ) {
const done = this.async();
try {
const slimFlags = [ "-ajax", "-callbacks", "-deferred", "-effects", "-queue" ];
const flags = this.flags;
const optIn = flags[ "*" ];
let name = grunt.option( "filename" );
@@ -79,7 +79,7 @@ module.exports = function( grunt ) {
if ( flags.slim ) {
delete flags.slim;
for ( const flag of slimFlags ) {
for ( const flag of slimBuildFlags ) {
flags[ flag ] = true;
}
}

View File

@@ -0,0 +1,10 @@
"use strict";
// NOTE: keep it in sync with test/data/testinit.js
module.exports = [
"-ajax",
"-callbacks",
"-deferred",
"-effects",
"-queue"
];