2018-01-03 04:05:53 +00:00
|
|
|
// Copyright IBM Corp. 2014,2018. All Rights Reserved.
|
2016-05-03 22:50:21 +00:00
|
|
|
// Node module: loopback
|
|
|
|
// This file is licensed under the MIT License.
|
|
|
|
// License text available at https://opensource.org/licenses/MIT
|
|
|
|
|
2017-01-06 11:12:35 +00:00
|
|
|
/* global module:false */
|
2016-11-15 21:46:23 +00:00
|
|
|
'use strict';
|
2014-02-12 00:01:51 +00:00
|
|
|
module.exports = function(grunt) {
|
2015-03-03 13:31:57 +00:00
|
|
|
// Do not report warnings from unit-tests exercising deprecated paths
|
|
|
|
process.env.NO_DEPRECATION = 'loopback';
|
|
|
|
|
2014-06-23 12:44:19 +00:00
|
|
|
grunt.loadNpmTasks('grunt-mocha-test');
|
|
|
|
|
2014-02-12 00:01:51 +00:00
|
|
|
// Project configuration.
|
|
|
|
grunt.initConfig({
|
|
|
|
// Metadata.
|
|
|
|
pkg: grunt.file.readJSON('package.json'),
|
|
|
|
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
|
|
|
|
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
|
|
|
|
'<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
|
|
|
|
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
|
|
|
|
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
|
|
|
|
// Task configuration.
|
|
|
|
uglify: {
|
|
|
|
options: {
|
2016-04-01 09:14:26 +00:00
|
|
|
banner: '<%= banner %>',
|
2014-02-12 00:01:51 +00:00
|
|
|
},
|
|
|
|
dist: {
|
|
|
|
files: {
|
2016-04-01 09:14:26 +00:00
|
|
|
'dist/loopback.min.js': ['dist/loopback.js'],
|
|
|
|
},
|
2014-02-12 00:01:51 +00:00
|
|
|
},
|
2016-04-01 09:14:26 +00:00
|
|
|
},
|
|
|
|
eslint: {
|
2014-02-12 00:01:51 +00:00
|
|
|
gruntfile: {
|
2016-04-01 09:14:26 +00:00
|
|
|
src: 'Gruntfile.js',
|
2014-02-12 00:01:51 +00:00
|
|
|
},
|
2014-10-16 23:16:27 +00:00
|
|
|
lib: {
|
2016-04-01 09:14:26 +00:00
|
|
|
src: ['lib/**/*.js'],
|
2014-10-16 23:16:27 +00:00
|
|
|
},
|
2014-11-04 12:52:49 +00:00
|
|
|
common: {
|
2016-04-01 09:14:26 +00:00
|
|
|
src: ['common/**/*.js'],
|
2014-11-04 12:52:49 +00:00
|
|
|
},
|
2014-11-12 11:36:16 +00:00
|
|
|
server: {
|
2016-04-01 09:14:26 +00:00
|
|
|
src: ['server/**/*.js'],
|
2014-11-21 01:57:22 +00:00
|
|
|
},
|
|
|
|
test: {
|
2016-04-01 09:14:26 +00:00
|
|
|
src: ['test/**/*.js'],
|
|
|
|
},
|
2014-10-30 20:49:47 +00:00
|
|
|
},
|
2014-02-12 00:01:51 +00:00
|
|
|
watch: {
|
|
|
|
gruntfile: {
|
2016-04-01 09:14:26 +00:00
|
|
|
files: '<%= eslint.gruntfile.src %>',
|
|
|
|
tasks: ['eslint:gruntfile'],
|
|
|
|
},
|
|
|
|
browser: {
|
|
|
|
files: ['<%= eslint.browser.src %>'],
|
|
|
|
tasks: ['eslint:browser'],
|
|
|
|
},
|
|
|
|
common: {
|
|
|
|
files: ['<%= eslint.common.src %>'],
|
|
|
|
tasks: ['eslint:common'],
|
2014-02-12 00:01:51 +00:00
|
|
|
},
|
2014-10-16 23:16:27 +00:00
|
|
|
lib: {
|
2016-04-01 09:14:26 +00:00
|
|
|
files: ['<%= eslint.lib.src %>'],
|
|
|
|
tasks: ['eslint:lib'],
|
|
|
|
},
|
|
|
|
server: {
|
|
|
|
files: ['<%= eslint.server.src %>'],
|
|
|
|
tasks: ['eslint:server'],
|
2014-10-16 23:16:27 +00:00
|
|
|
},
|
|
|
|
test: {
|
2016-04-01 09:14:26 +00:00
|
|
|
files: ['<%= eslint.test.src %>'],
|
|
|
|
tasks: ['eslint:test'],
|
|
|
|
},
|
2014-02-12 00:01:51 +00:00
|
|
|
},
|
|
|
|
browserify: {
|
|
|
|
dist: {
|
|
|
|
files: {
|
|
|
|
'dist/loopback.js': ['index.js'],
|
|
|
|
},
|
|
|
|
options: {
|
2014-12-08 22:59:21 +00:00
|
|
|
ignore: ['nodemailer', 'passport', 'bcrypt'],
|
2016-04-01 09:14:26 +00:00
|
|
|
standalone: 'loopback',
|
|
|
|
},
|
|
|
|
},
|
2014-02-12 00:01:51 +00:00
|
|
|
},
|
2014-06-23 12:44:19 +00:00
|
|
|
mochaTest: {
|
|
|
|
'unit': {
|
|
|
|
src: 'test/*.js',
|
2014-02-12 00:01:51 +00:00
|
|
|
options: {
|
2014-06-23 12:44:19 +00:00
|
|
|
reporter: 'dot',
|
2017-01-26 09:10:11 +00:00
|
|
|
require: require.resolve('./test/helpers/use-english.js'),
|
2016-04-01 09:14:26 +00:00
|
|
|
},
|
2014-04-14 19:25:41 +00:00
|
|
|
},
|
2014-06-23 12:44:19 +00:00
|
|
|
'unit-xml': {
|
|
|
|
src: 'test/*.js',
|
|
|
|
options: {
|
|
|
|
reporter: 'xunit',
|
2016-04-01 09:14:26 +00:00
|
|
|
captureFile: 'xunit.xml',
|
|
|
|
},
|
|
|
|
},
|
2014-06-23 12:44:19 +00:00
|
|
|
},
|
|
|
|
karma: {
|
|
|
|
'unit-once': {
|
|
|
|
configFile: 'test/karma.conf.js',
|
2019-09-30 09:14:04 +00:00
|
|
|
browsers: ['ChromeDocker'],
|
2014-06-23 12:44:19 +00:00
|
|
|
singleRun: true,
|
|
|
|
reporters: ['dots', 'junit'],
|
|
|
|
|
|
|
|
// increase the timeout for slow build slaves (e.g. Travis-ci)
|
|
|
|
browserNoActivityTimeout: 30000,
|
|
|
|
|
|
|
|
// CI friendly test output
|
|
|
|
junitReporter: {
|
2016-04-01 09:14:26 +00:00
|
|
|
outputFile: 'karma-xunit.xml',
|
2014-06-23 12:44:19 +00:00
|
|
|
},
|
2015-05-04 16:30:01 +00:00
|
|
|
|
|
|
|
browserify: {
|
|
|
|
// Disable sourcemaps to prevent
|
|
|
|
// Fatal error: Maximum call stack size exceeded
|
|
|
|
debug: false,
|
|
|
|
// Disable watcher, grunt will exit after the first run
|
2016-04-01 09:14:26 +00:00
|
|
|
watch: false,
|
|
|
|
},
|
2014-06-23 12:44:19 +00:00
|
|
|
},
|
|
|
|
unit: {
|
|
|
|
configFile: 'test/karma.conf.js',
|
|
|
|
},
|
2014-04-14 19:25:41 +00:00
|
|
|
e2e: {
|
|
|
|
options: {
|
|
|
|
// base path, that will be used to resolve files and exclude
|
|
|
|
basePath: '',
|
|
|
|
|
|
|
|
// frameworks to use
|
|
|
|
frameworks: ['mocha', 'browserify'],
|
|
|
|
|
|
|
|
// list of files / patterns to load in the browser
|
|
|
|
files: [
|
2014-04-16 14:33:17 +00:00
|
|
|
'test/e2e/remote-connector.e2e.js',
|
2016-04-01 09:14:26 +00:00
|
|
|
'test/e2e/replication.e2e.js',
|
2014-04-14 19:25:41 +00:00
|
|
|
],
|
|
|
|
|
|
|
|
// list of files to exclude
|
|
|
|
exclude: [
|
2014-10-16 23:16:27 +00:00
|
|
|
|
2014-04-14 19:25:41 +00:00
|
|
|
],
|
|
|
|
|
|
|
|
// test results reporter to use
|
|
|
|
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
|
|
|
|
reporters: ['dots'],
|
|
|
|
|
|
|
|
// web server port
|
|
|
|
port: 9876,
|
|
|
|
|
|
|
|
// cli runner port
|
|
|
|
runnerPort: 9100,
|
|
|
|
|
|
|
|
// enable / disable colors in the output (reporters and logs)
|
|
|
|
colors: true,
|
|
|
|
|
|
|
|
// level of logging
|
|
|
|
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
|
|
|
|
logLevel: 'warn',
|
|
|
|
|
|
|
|
// enable / disable watching file and executing tests whenever any file changes
|
|
|
|
autoWatch: true,
|
|
|
|
|
|
|
|
// Start these browsers, currently available:
|
|
|
|
// - Chrome
|
|
|
|
// - ChromeCanary
|
|
|
|
// - Firefox
|
|
|
|
// - Opera
|
|
|
|
// - Safari (only Mac)
|
|
|
|
// - PhantomJS
|
|
|
|
// - IE (only Windows)
|
|
|
|
browsers: [
|
2016-04-01 09:14:26 +00:00
|
|
|
'Chrome',
|
2014-04-14 19:25:41 +00:00
|
|
|
],
|
|
|
|
|
|
|
|
// If browser does not capture in given timeout [ms], kill it
|
|
|
|
captureTimeout: 60000,
|
|
|
|
|
|
|
|
// Continuous Integration mode
|
|
|
|
// if true, it capture browsers, run tests and exit
|
|
|
|
singleRun: false,
|
|
|
|
|
|
|
|
// Browserify config (all optional)
|
|
|
|
browserify: {
|
|
|
|
// extensions: ['.coffee'],
|
|
|
|
ignore: [
|
|
|
|
'nodemailer',
|
|
|
|
'passport',
|
|
|
|
'passport-local',
|
|
|
|
'superagent',
|
2014-12-08 22:59:21 +00:00
|
|
|
'supertest',
|
2016-04-01 09:14:26 +00:00
|
|
|
'bcrypt',
|
2014-04-14 19:25:41 +00:00
|
|
|
],
|
|
|
|
// transform: ['coffeeify'],
|
|
|
|
// debug: true,
|
|
|
|
// noParse: ['jquery'],
|
|
|
|
watch: true,
|
|
|
|
},
|
|
|
|
|
|
|
|
// Add browserify to preprocessors
|
2016-11-15 21:46:23 +00:00
|
|
|
preprocessors: {'test/e2e/*': ['browserify']},
|
2016-04-01 09:14:26 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2014-02-12 00:01:51 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
// These plugins provide necessary tasks.
|
|
|
|
grunt.loadNpmTasks('grunt-browserify');
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-uglify');
|
2016-04-01 09:14:26 +00:00
|
|
|
grunt.loadNpmTasks('grunt-eslint');
|
2014-02-12 00:01:51 +00:00
|
|
|
grunt.loadNpmTasks('grunt-contrib-watch');
|
|
|
|
grunt.loadNpmTasks('grunt-karma');
|
|
|
|
|
2014-04-14 19:25:41 +00:00
|
|
|
grunt.registerTask('e2e-server', function() {
|
|
|
|
var done = this.async();
|
|
|
|
var app = require('./test/fixtures/e2e/app');
|
2016-01-07 21:29:27 +00:00
|
|
|
app.listen(0, function() {
|
|
|
|
process.env.PORT = this.address().port;
|
|
|
|
done();
|
|
|
|
});
|
2014-04-14 19:25:41 +00:00
|
|
|
});
|
|
|
|
|
2018-08-08 10:45:58 +00:00
|
|
|
grunt.registerTask('skip-karma', function() {
|
|
|
|
console.log(`*** SKIPPING PHANTOM-JS BASED TESTS ON ${process.platform}` +
|
|
|
|
` ${process.arch} ***`);
|
2016-09-22 08:45:09 +00:00
|
|
|
});
|
|
|
|
|
2014-04-14 19:25:41 +00:00
|
|
|
grunt.registerTask('e2e', ['e2e-server', 'karma:e2e']);
|
|
|
|
|
2014-02-12 00:01:51 +00:00
|
|
|
// Default task.
|
|
|
|
grunt.registerTask('default', ['browserify']);
|
|
|
|
|
2014-06-23 12:44:19 +00:00
|
|
|
grunt.registerTask('test', [
|
2016-04-01 09:14:26 +00:00
|
|
|
'eslint',
|
2014-06-23 12:44:19 +00:00
|
|
|
process.env.JENKINS_HOME ? 'mochaTest:unit-xml' : 'mochaTest:unit',
|
2018-08-08 10:45:58 +00:00
|
|
|
process.env.JENKINS_HOME && (/^win/.test(process.platform) ||
|
|
|
|
/^s390x/.test(process.arch) || /^ppc64/.test(process.arch)) ?
|
2019-09-30 07:14:35 +00:00
|
|
|
'skip-karma' : 'karma:unit-once',
|
2016-09-22 08:45:09 +00:00
|
|
|
]);
|
2014-06-23 12:44:19 +00:00
|
|
|
|
|
|
|
// alias for sl-ci-run and `npm test`
|
|
|
|
grunt.registerTask('mocha-and-karma', ['test']);
|
2014-02-12 00:01:51 +00:00
|
|
|
};
|