diff --git a/.editorconfig b/.editorconfig index f5d573b..4403be2 100644 --- a/.editorconfig +++ b/.editorconfig @@ -22,3 +22,6 @@ indent_size = 2 [*.{yaml,yml}] indent_size = 2 + +[vendor/grunt-template-jasmine-requirejs/**/*] +indent_size = 2 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1f0e22e..927e8f8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: - name: Install Node.js uses: actions/setup-node@v4 with: - node-version: 10 + node-version: 20 cache: npm cache-dependency-path: 'package.json' @@ -37,7 +37,7 @@ jobs: - name: Install Node.js uses: actions/setup-node@v4 with: - node-version: 10 + node-version: 20 cache: npm cache-dependency-path: 'package.json' @@ -51,9 +51,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - # Ideally we'd also test on [12, 14, 16, 18, 20], but the current - # tooling does not support them. - node_version: [6, 8, 10] + node_version: [8, 10, 12, 14, 16, 18, 20] steps: - uses: actions/checkout@v4 @@ -80,7 +78,7 @@ jobs: - name: Install Node.js uses: actions/setup-node@v4 with: - node-version: 8 + node-version: 20 cache: npm cache-dependency-path: 'package.json' @@ -99,7 +97,7 @@ jobs: - name: Install Node.js uses: actions/setup-node@v4 with: - node-version: 10 + node-version: 20 cache: npm cache-dependency-path: 'package.json' diff --git a/Gruntfile.js b/Gruntfile.js index 5b3234b..21c44a7 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,5 +1,7 @@ 'use strict'; +var Jasmine = require('jasmine'); + module.exports = function (grunt) { var jasmineRequireJsOptions = { specs: 'test/*-test.js', @@ -54,45 +56,11 @@ module.exports = function (grunt) { options: { specs: 'test/global-integration-with-new-context.js', } - }, - // Wraps the `requirejs` configuration above with Instanbul code - // coverage tracking. - withCoverage: { - src: 'lib/**/*.js', - options: { - specs: jasmineRequireJsOptions.specs, - helpers: jasmineRequireJsOptions.helpers, - template: require('grunt-template-jasmine-istanbul'), - templateOptions: { - coverage: 'coverage/coverage.json', - report: [ - { - type: 'html', - options: { - dir: 'coverage' - } - }, - { - type: 'lcov', - options: { - dir: 'coverage' - } - } - ], - - template: require('./vendor/grunt-template-jasmine-requirejs') - } - } } }, - "jasmine_node": { - test: { - options: { - match: "node-integration.", - matchall: true, - projectRoot: "./test", - useHelpers: false - } + jasmine_node: { + options: { + specs: ['test/node-integration.js'] } }, open: { @@ -155,7 +123,6 @@ module.exports = function (grunt) { grunt.loadNpmTasks('grunt-contrib-concat'); grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-jasmine'); - grunt.loadNpmTasks('grunt-jasmine-node'); grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-contrib-watch'); @@ -164,13 +131,29 @@ module.exports = function (grunt) { grunt.loadNpmTasks('grunt-preprocess'); grunt.loadNpmTasks('grunt-contrib-clean'); + // Run Jasmine with Node.js tests (as opposed to browser tests). + // + // NOTE: This is designed for Jasmine 2.4, which matches the version used + // in `grunt-contrib-jasmine`. If that package is updated, this should also + // be updated to match. + grunt.registerTask('jasmine_node', 'Run Jasmine in Node.js', function() { + var done = this.async(); + + var jasmine = new Jasmine({ projectBaseDir: __dirname }); + jasmine.onComplete(function(success) { + done(success); + }); + + jasmine.execute(this.options().specs); + }); + // Build a distributable release grunt.registerTask('dist', ['test', 'dist-build']); grunt.registerTask('dist-build', ['concat', 'uglify']); // Check everything is good grunt.registerTask('test', ['jshint', 'test-browser', 'test-node']); - grunt.registerTask('test-browser', ['jasmine:global', 'preprocess', 'jasmine:context', 'clean:test', 'jasmine:withCoverage']); + grunt.registerTask('test-browser', ['jasmine:global', 'preprocess', 'jasmine:context', 'clean:test', 'jasmine:requirejs']); grunt.registerTask('test-node', ['jasmine_node']); // Test with a live server and an actual browser @@ -178,5 +161,4 @@ module.exports = function (grunt) { // Default task. grunt.registerTask('default', 'test'); - }; diff --git a/package.json b/package.json index 6cdf894..aa4308e 100644 --- a/package.json +++ b/package.json @@ -44,14 +44,13 @@ "grunt-contrib-clean": "^1.1.0", "grunt-contrib-concat": "~0.5.0", "grunt-contrib-connect": "^1.0.2", - "grunt-contrib-jasmine": "~1.0.3", + "grunt-contrib-jasmine": "^4.0.0", "grunt-contrib-jshint": "^1.1.0", "grunt-contrib-uglify": "^3.4.0", "grunt-contrib-watch": "^1.1.0", - "grunt-jasmine-node": "~0.2.1", "grunt-open": "~0.2.3", "grunt-preprocess": "^5.1.0", - "grunt-template-jasmine-istanbul": "~0.4.0", + "jasmine": "^2.4.1", "typescript": "^3.5.1" }, "keywords": [ diff --git a/test/test-helpers.js b/test/test-helpers.js index 42b57e4..f517d01 100644 --- a/test/test-helpers.js +++ b/test/test-helpers.js @@ -48,7 +48,7 @@ define(function () { }; self.isCookieStorageAvailable = function isCookieStorageAvailable() { - if (window && window.document && window.document.cookie) { + if (window && window.document && window.document.cookie != null) { // We need to check not just that the cookie objects are available, but that they work, because // if we run from file:// URLs they appear present but are non-functional window.document.cookie = "test=hi;"; diff --git a/vendor/grunt-template-jasmine-requirejs/src/template-jasmine-requirejs.js b/vendor/grunt-template-jasmine-requirejs/src/template-jasmine-requirejs.js index 93f803f..5e67ea7 100644 --- a/vendor/grunt-template-jasmine-requirejs/src/template-jasmine-requirejs.js +++ b/vendor/grunt-template-jasmine-requirejs/src/template-jasmine-requirejs.js @@ -58,7 +58,8 @@ function resolvePath(filepath) { return path.resolve(filepath); } -function moveRequireJs(grunt, task, versionOrPath) { +// LOGLEVEL-FORK: copying tempfiles now requires info from the `context` object. +function moveRequireJs(grunt, task, context, versionOrPath) { var pathToRequireJS, versionReg = /^(\d\.?)*$/; @@ -74,8 +75,10 @@ function moveRequireJs(grunt, task, versionOrPath) { throw new Error('local file path of requirejs [' + versionOrPath + '] was not found'); } } - task.copyTempFile(pathToRequireJS,'require.js'); + task.copyTempFile(pathToRequireJS, path.join(context.temp, 'require.js')); } +// END LOGLEVEL-FORK + exports.process = function(grunt, task, context) { @@ -149,7 +152,9 @@ exports.process = function(grunt, task, context) { }); } - moveRequireJs(grunt, task, version); + // LOGLEVEL-FORK: this function now requires context info + moveRequireJs(grunt, task, context, version); + // END LOGLEVEL-FORK context.serializeRequireConfig = function(requireConfig) { var funcCounter = 0; diff --git a/vendor/grunt-template-jasmine-requirejs/src/templates/jasmine-requirejs.html b/vendor/grunt-template-jasmine-requirejs/src/templates/jasmine-requirejs.html index 2f6e9f0..991d58b 100644 --- a/vendor/grunt-template-jasmine-requirejs/src/templates/jasmine-requirejs.html +++ b/vendor/grunt-template-jasmine-requirejs/src/templates/jasmine-requirejs.html @@ -17,9 +17,11 @@ <% with (scripts) { %> - <% [].concat(jasmine, boot, helpers).forEach(function(script){ %> + <% /* LOGLEVEL-FORK: Include new script types used by grunt-contrib-jasmine v4 */ %> + <% [].concat(polyfills, jasmine, boot, boot2, helpers).forEach(function(script){ %> <% }) %> + <% /* END LOGLEVEL-FORK */ %> <% }; %>