browserDisconnectTolerance: 2,
frameworks: ['qunit'],
files: [
- 'min/moment-with-locales.js',
- 'min/tests.js'
+ 'build/tests.js'
],
sauceLabs: {
startConnect: true,
// test tasks
grunt.registerTask('test', ['test:node']);
- grunt.registerTask('test:node', ['transpile', 'qtest']);
+ grunt.registerTask('test:node', ['rollup-tests', 'qtest']);
// TODO: For some weird reason karma doesn't like the files in
// build/umd/min/* but works with min/*, so update-index, then git checkout
- grunt.registerTask('test:server', ['transpile', 'update-index', 'karma:server']);
- grunt.registerTask('test:browser', ['transpile', 'update-index', 'karma:chrome', 'karma:firefox']);
- grunt.registerTask('test:sauce-browser', ['transpile', 'update-index', 'env:sauceLabs', 'karma:sauce']);
+ grunt.registerTask('test:server', ['rollup-tests', 'update-index', 'karma:server']);
+ grunt.registerTask('test:browser', ['rollup-tests', 'update-index', 'karma:chrome', 'karma:firefox']);
+ grunt.registerTask('test:sauce-browser', ['rollup-tests', 'update-index', 'env:sauceLabs', 'karma:sauce']);
grunt.registerTask('test:meteor', ['exec:meteor-init', 'exec:meteor-test', 'exec:meteor-cleanup']);
// travis build task
"karma-sauce-launcher": "latest",
"qunit": "^0.7.5",
"qunit-cli": "^0.1.4",
+ "rollup": "latest",
"rollup-plugin-babel": "latest",
+ "rollup-plugin-multi-entry": "latest",
"spacejam": "latest",
"coveralls": "^2.11.2",
"nyc": "^2.1.4"
+var testrunner = require('qunit');
+
+testrunner.options.log.assertions = false;
+testrunner.options.log.tests = false;
+testrunner.options.log.summary = false;
+testrunner.options.log.testing = false;
+testrunner.options.maxBlockDuration = 120000;
+
module.exports = function (grunt) {
grunt.task.registerTask('qtest', 'run tests locally', function () {
var done = this.async();
- var testrunner = require('qunit');
-
- testrunner.options.log.assertions = false;
- testrunner.options.log.tests = false;
- testrunner.options.log.summary = false;
- testrunner.options.log.testing = false;
- testrunner.options.maxBlockDuration = 120000;
-
- var tests;
-
- if (grunt.option('only') != null) {
- tests = grunt.file.expand.apply(null, grunt.option('only').split(',').map(function (file) {
- if (file === 'moment') {
- return 'build/cjs/test/moment/*.js';
- } else if (file === 'locale') {
- return 'build/cjs/test/locale/*.js';
- } else {
- return 'build/cjs/test/' + file + '.js';
- }
- }));
- } else {
- tests = grunt.file.expand('build/umd/test/*.js');
- }
-
testrunner.run({
- code: 'build/umd/moment.js',
- tests: tests
+ code: 'moment.js',
+ tests: 'build/tests.js'
}, function (err, report) {
if (err) {
console.log('woot', err, report);
--- /dev/null
+var rollup = require('rollup');
+var babelPlugin = require('rollup-plugin-babel');
+var multiEntry = require('rollup-plugin-multi-entry').default;
+
+function testFiles(grunt) {
+ var only = grunt.option('only') || '{moment,locale}/*';
+ return grunt.file.expand({
+ filter: 'isFile'
+ }, 'src/test/**/' + only + '{,.js,**/*.js}');
+}
+
+module.exports = function (grunt) {
+ grunt.task.registerTask('rollup-tests', 'bundle tests', function () {
+ var done = this.async();
+ var files = testFiles(grunt);
+
+ if (grunt.option('only')) {
+ console.log('Only testing files ' + files.join(', '));
+ }
+
+ rollup.rollup({
+ entry: files,
+ plugins: [
+ multiEntry(),
+ babelPlugin({
+ babelrc: false,
+ compact: false,
+ presets: ['es2015-loose-rollup']
+ })
+ ]
+ }).then(function (bundle) {
+ return bundle.write({
+ format: 'iife',
+ moduleName: 'momentTests',
+ dest: 'build/tests.js'
+ });
+ }).then(done, done);
+ });
+};
src: 'src/locales.js',
dest: 'build/umd/locales.js'
}]
- },
- tests: {
- options: {
- format: 'iife'
- },
- files: [{
- src: 'src/test/all.js',
- dest: 'build/umd/test/all.js'
- }]
}
});
};