No tests executed with grunt-qunit-junit - junit

I am following this guide to generate junit output from my js tests:
https://github.com/sbrandwoo/grunt-qunit-junit
I have installed grunt-qunit-junit into my local test project:
npm install grunt-contrib-qunit --save-dev
And this is my Gruntfile.js:
module.exports = function(grunt) {
"use:strict";
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
qunit_junit: {
options: {
},
all: ["all_tests.html"]
},
})
grunt.loadNpmTasks('grunt-qunit-junit');
};
where all_tests.html is located in the same dir and lists all my *test.js files. But when I run:
user#ubuntu:~/Test$ grunt qunit_junit
Running "qunit_junit" task
>> XML reports will be written to _build/test-reports
Done, without errors.
Why are the tests not executed (the folder _build/test-reports is not created)?

The README states that you should execute both the qunit_junit and qunit tasks: http://github.com/sbrandwoo/grunt-qunit-junit#usage-examples
For example: grunt.registerTask('test', ['qunit_junit', 'qunit']);

Related

composer in a gulp build and deployment

How do you get composer to install dependencies correctly whenusing a gulp build?
My build process set up that outputs to a set location, either ../sites/www/public_html or ../sites/dev/public_html dependent on if an environment argument is passed to a gulp task. These locations essentially mirror my remote host.
I'm wanting to automate composer installs, updates and optimisation to output the correct vendor files in either ../sites/www/vendor or ../sites/dev/vendor whenever the build is initially run or to just optimise based on any watched php files being changed.
My build folder has the following structure:
source/
bower.json
composer.json
composer.lock
gulpfile.json
package.json
My example composer.json has the following:
{
"name": "mycomposer/mycomposer",
"version": "1.0.0",
"autoload": {
"psr-4" : {
"mycomposer\\": "public_html/app/mycomposer"
}
},
"require": {
"rollbar/rollbar": "^1.3",
"vlucas/phpdotenv": "^2.4.0"
}
}
I have tried a gulp-compose and task to install the composer libraries and to run dumpautoload for local first party libraries
gulp.task('composer', function() {
var dest = argv.live ? 'www' : 'devsite',
env = '../sites/' + dest + '/public_html';
$.composer('config vendor-dir ' + env.replace('public_html', 'vendor') );
$.composer({
"no-ansi": true,
"no-dev": true,
"no-interaction": true,
"no-progress": true,
"no-scripts": true,
"optimize-autoloader": true
});
$.composer('dumpautoload ', {
optimize: true
});
});
When the task is complete I'm finding is that the $baseDir variable references the build directory
Expected
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
Output
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname(dirname(dirname($vendorDir))).'/mybuild';
Is this something I can achieve, or should I really be running composer separately from my build process?
Thanks
I had a similar problem.
I use gulp-composer package.
gulpfile.js
const composer = require('gulp-composer');
gulp.task('composer-deployed', async function() {
let opts = {
"working-dir": 'my-path-to-composer.json',
"self-install": true, // false for my case
optimize: true,
"classmap-authoritative": true
};
composer("dumpautoload", opts);
});
In my case, I use composer installed globaly but you can choose the bin path with bin: 'path-to-composer.phar' in opts{}.

How to Run Gulp Task on Netlify

Hi i'm trying to run some gulp task on netlify for building Hugo web.
I wonder how to run serial gulp task on netlify,
by the way this is my gulpfile.js
var gulp = require('gulp');
var removeEmptyLines = require('gulp-remove-empty-lines');
var prettify = require('gulp-html-prettify');
var rm = require( 'gulp-rm' );
var minifyInline = require('gulp-minify-inline');
gulp.task('tojson', function () {
gulp.src('public/**/*.html')
.pipe(removeEmptyLines())
.pipe(gulp.dest('public/./'));
});
gulp.task('htmlClean', function () {
gulp.src('public/**/*.html')
.pipe(removeEmptyLines({
removeComments: true
}))
.pipe(gulp.dest('public/./'));
});
gulp.task('templates', function() {
gulp.src('public/**/*.html')
.pipe(prettify({indent_char: ' ', indent_size: 2}))
.pipe(gulp.dest('public/./'))
});
gulp.task('minify-inline', function() {
gulp.src('public/**/*.html')
.pipe(minifyInline())
.pipe(gulp.dest('public/./'))
});
where should i put the command to run all my gulps task in Netlify?
There are two places to setup your build commands in Netlify.
Admin Option
Put your commands in the online admin under the Settings section of your site and go to Build & Deploy (Deploy settings) and change the Build command:
Netlify Config file (netlify.toml) Option
Edit/add a netlify.toml file to the root of your repository and put your build commands into the context you want to target.
netlify.toml
# global context
[build]
publish = "public"
command = "gulp build"
# build a preview (optional)
[context.deploy-preview]
command = "gulp build-preview"
# build a branch with debug (optional)
[context.branch-deploy]
command = "gulp build-debug"
NOTE:
The commands can be any valid command string. Serializing gulp commands would work fine if you do not want to create a gulp sequence to run them. In example, gulp htmlClean && hugo && gulp tojson would be a valid command.
Commands in the netlify.toml will overwrite the site admin command.
You can string your tasks together like this:
add another plugin with NPM:
https://www.npmjs.com/package/run-sequence
var runSequence = require('run-sequence');
gulp.task('default', function (callback) {
runSequence(['tojson', 'htmlClean', 'templates', 'minify-inline'],
callback
)
})
Then run $ gulp
There's a section on run-sequence on this page that will help:
https://css-tricks.com/gulp-for-beginners/

Jasmine Protractor Reporter

I have installed:
$ npm install protractor-jasmine2-html-reporter --save-dev
for reporter
var Jasmine2HtmlReporter = require('protractor-jasmine2-html-reporter');
exports.config = {
// ...
onPrepare: function() {
jasmine.getEnv().addReporter(
new Jasmine2HtmlReporter({
savePath: 'target/screenshots'
})
);
}
}
and defined the path where the reporter is installed
var Jasmine2HtmlReporter =
require('../../build/node_modules/protractor-jasmine2-html-reporter');
Now i get this Error:
configParser - ReferenceError: jasmine is not defined
How should i define jasmine?
For info: i have a test execution task defined in a gulp file and i run the task using webstorm.
I have seen ReferenceError: jasmine is not defined in other reporters(jasmine-repoters) when there is a version mismatch.
Can you upgrade your protractor & reporter versions. Also make sure you have Jasmine2 as the framework in your config file
The below combination has been tested and is working fine
Protractor - 4.0.10
protractor-jasmine2-html-reporter - 0.0.7
Jasmine ~2

npm install is not installing + grunt-contrib.copy not found

I have two questions. I am completing a project from the book "Learning to Program", and am a little confused as to why npm is not installing, and why I am receiving another error message. I'm using Windows, I have installed node.js (v0.12.2) and have attempted to install grunt: npm install -g grunt-cli
Question 1 - When I try to install npm, it does not list all of the dependencies defined in package.json.
The following shows when I try to install npm in my main directory:
C:\Users\Me\My Documents\kittenbook\npm install
npm WARN package.json kittenbook#0.0.1 No description
npm WARN package.json kittenbook#0.0.1 No repository field
npm WARN package.json kittenbook#0.0.1 No README data
From what I see, it's supposed to display a bunch of lines after those three warnings, such as:
npm http GET https://registry.npmjs.org/grunt-contrib-concat
npm http GET https://registry.npmjs.org/grunt
npm http GET https://registry.npmjs.org/grunt-contrib-copy
and so on.
Question 2:
This is probably because installing npm is not working correctly, but when I try to run "grunt jshint" it gives me this error:
>> Local Npm module "grunt-contrib-.copy" not found. Is it installed?
Running "jshint:files" (jshint) task
>> 2 files lint free
Done, without errors.
Sorry for this very unorganized question, but I am very new to programming and I am very confused as to where the problem is.
Here is some more information.
Gruntfile.js
module.exports = function(grunt) {
// Project configuration
grunt.initConfig({
concat: {
release: {
src: ['js/values.js', 'js/prompt.js'],
dest: 'release/main.js'
}
},
copy: {
release: {
src: 'manifest.json',
dest: 'release/manifest.json'
}
},
jshint: {
files: ['js/values.js', 'js/prompt.js']
}
});
// Load Grunt plugins
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib.copy');
grunt.loadNpmTasks('grunt-contrib-jshint');
// Register Tasks
grunt.registerTask('default', ['jshint', 'concat', 'copy']);
};
package.json
{
"name": "kittenbook",
"version": "0.0.1",
"devDependencies": {
"grunt": "~0.4.2",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-jshint": "~0.6.3",
"grunt-contrib-copy": "~0.5.0"
}
}
If you need other information I will gladly get it to you. Thank you all so much for your help.
grunt-contrib.copy should be grunt-contrib-copy (use dash, not period)

Why "gulp-jest" is failing with: "Please run node with the --harmony flag!"?

I get the following error when running gulp test:
Error: Please run node with the --harmony flag!
Here is my gulp task:
var jest = require('gulp-jest');
gulp.task('test', function() {
return gulp.src('src/**/__tests__').pipe(jest({
rootDir: 'src',
scriptPreprocessor: '../node_modules/6to5-jest',
unmockedModulePathPatterns: [ 'react' ]
}));
});
To reproduce: https://github.com/SEEK-Jobs/react-playground
Note that npm test works properly (test is failing as expected), but gulp test fails with the error above. Both npm test and gulp test have the same config object:
{
rootDir: 'src',
scriptPreprocessor: '../node_modules/6to5-jest',
unmockedModulePathPatterns: [ 'react' ]
}
What am I doing wrong?
As far as I can tell the error is thrown from jest-cli.
The reason you don't get it with npm test is that you probably configured npm to run the jest bin script directly, which uses harmonize to programmatically set the --harmony flag.
You can fix by installing harmonize and putting require('harmonize')() in your gulpfile.
It was a bug in gulp-eslint, and it is fixed now in version 0.3.0.