jquery/build/tasks/node_smoke_tests.js
Michał Gołębiowski-Owczarek 9cb124ed00
Build: Update jsdom; migrate a test with Symbol polyfill to an iframe test
So far, we've been testing that jQuery element iteration works with polyfilled
Symbol & transpiled for-of via a Node test with jsdom with the Symbol global
removed. Unfortunately, jsdom now requires Symbol to be present for its internal
functionality so such a test is no longer possible. Instead, it's been migrated
to an iframe test with transpiled JavaScript.

This PR also enables us to use ECMAScript 2017 or newer in Node.js code.

Closes gh-4305
2019-03-04 18:30:51 +01:00

33 lines
1.1 KiB
JavaScript

module.exports = ( grunt ) => {
"use strict";
const fs = require( "fs" );
const spawnTest = require( "./lib/spawn_test.js" );
const testsDir = "./test/node_smoke_tests/";
const nodeSmokeTests = [ "babel:nodeSmokeTests" ];
// Fire up all tests defined in test/node_smoke_tests/*.js in spawned sub-processes.
// All the files under test/node_smoke_tests/*.js are supposed to exit with 0 code
// on success or another one on failure. Spawning in sub-processes is
// important so that the tests & the main process don't interfere with
// each other, e.g. so that they don't share the require cache.
fs.readdirSync( testsDir )
.filter( ( testFilePath ) =>
fs.statSync( testsDir + testFilePath ).isFile() &&
/\.js$/.test( testFilePath )
)
.forEach( ( testFilePath ) => {
const taskName = `node_${ testFilePath.replace( /\.js$/, "" ) }`;
grunt.registerTask( taskName, function() {
spawnTest( this.async(), `node "test/node_smoke_tests/${ testFilePath }"` );
} );
nodeSmokeTests.push( taskName );
} );
grunt.registerTask( "node_smoke_tests", nodeSmokeTests );
};