I have AngularJs application that uses grunt as a Task Runner..
Builds are successful as on local machine as inside docker container.
But the problem is when I run Jenkins pipeline it fails.. I found out where it's failing but still can't understand what could be the reason.
Here's my Gruntfile.js
'use strict';
module.exports = function (grunt) {
grunt.initConfig({
...
replace: {
dist: {
options: {
patterns: [
...
{
match: /\btheme\-([a-z]|[0-9]|\w)+\.css\b/gi,
replacement: "theme-%theme.name%.css"
}
]
},
files: [{
expand: true,
flatten: true,
src: ['dist/scripts/settings*.js'],
dest: 'dist/scripts'
}]
}
}
...
});
grunt.registerTask('build', [
...
'replace'
]);
};
Jenkins build just hanging on this part, if I comment out that section it works..
Any ideas?
Related
I've got some issues with codeceptjs appium.
I run test script by npx codeceptjs run , it did not execute the step_definitions file.
I config steps definition with /*steps.js and its not working, i have to direct exact path of steps file.
The app crashed without throw exception, the script still being execute.
add-task.feature
Feature: Add task
Background: I opened the application
Scenario: Add task
Given I click Add Task button
And I input all information
add-task-steps.js
When("I input all information", () => {
AddTaskScreen.inputTaskName('sdsada')
});
const HomeScreen = require("../screens/home-screen.js")
const { I } = inject();
home-screen-steps.js
Given("I click Add Task button", () => {
HomeScreen.tapAddTaskButton();
});
Details
CodeceptJS version: ^3.3.6
NodeJS Version: 8.15.0
Operating System: Windows 10
webdriverio 7.25.2
Configuration file:
exports.config = {
output: './output',
helpers: {
Appium: {
app: 'Appium/ToDoList.apk',
platform: 'Android',
device: 'emulator-5556'
}
},
include: {
I: './steps_file.js',
env:{
TIMEOUT: 5000,
}
},
mocha: {},
bootstrap: null,
timeout: null,
teardown: null,
hooks: [],
gherkin: {
features: './features/*.feature',
steps: ['./step_definitions/home-screen-steps.js']
},
plugins: {
screenshotOnFail: {
enabled: true
},
tryTo: {
enabled: true
},
retryFailedStep: {
enabled: false
},
retryTo: {
enabled: true
},
eachElement: {
enabled: true
},
pauseOnFail: {}
},
stepTimeout: 10000,
stepTimeoutOverride: [{
pattern: 'wait.*',
timeout: 0
},
{
pattern: 'amOnPage',
timeout: 0
}
],
tests: './*_test.js',
name: 'appium'
}
Thanks in advance. <3
I resolved it by replace waitForElementToBeClickable with waitForElement.
Idk why Codeceptjs not recognize waitForElementToBeClickabe and also not throw any exception.
i have a problem with hashes in vue cli build.
And now to the details.
I build my app, and in dist folder i see my files with names like
app.dsadas.js, chunk-1-dsadaas.js etc.. all looks good.
But i build my app in docker images, there may be 2 or more, and i need all this images with the same hashes in filenames, but it is not.
This 'webpack-md5-hash' plugin helped me with this problem, but its very old solution, works with warnings.
Help pls find solution for webpack 4.
This is my vue config file:
const path = require('path');
const VuetifyLoaderPlugin = require('vuetify-loader/lib/plugin');
const CompressionWebpackPlugin = require('compression-webpack-plugin');
const productionGzipExtensions = ['js', 'css'];
function resolve(dir) {
return path.resolve(__dirname, dir);
}
module.exports = {
assetsDir: 'static',
runtimeCompiler: true,
lintOnSave: process.env.NODE_ENV !== 'production',
devServer: {
overlay: {
warnings: true,
errors: true,
},
},
configureWebpack: {
performance: {
hints: false,
},
resolve: {
extensions: ['.js', '.vue', '.json'],
alias: {
vue$: 'vue/dist/vue.esm.js',
'#': resolve('src'),
utils: resolve('src/utils'),
api: resolve('src/api'),
defaultStates: resolve('src/store/modules/defaultStates'),
router: resolve('src/router'),
store: resolve('src/store'),
config: resolve('src/config'),
helpers: resolve('src/store/modules/helpers'),
constants: resolve('src/constants'),
mixins: resolve('src/mixins'),
},
},
plugins: [
new VuetifyLoaderPlugin(),
new CompressionWebpackPlugin({
filename: '[path].gz[query]',
algorithm: 'gzip',
test: new RegExp(`\\.(${productionGzipExtensions.join('|')})$`),
threshold: 10240,
minRatio: 0.8,
}),
],
},
};
I am trying to run grunt karma in my jenkins farm but I keep getting this error
[4mRunning "karma:continuous" (karma) task[24m
[32m29 07 2015 19:17:24.976:INFO [karma]: [39mKarma v0.13.3 server started at http://localhost:9876/
[32m29 07 2015 19:17:24.984:INFO [launcher]: [39mStarting browser PhantomJS
[33m29 07 2015 19:18:25.017:WARN [launcher]: [39mPhantomJS have not captured in 60000 ms, killing.
[33m29 07 2015 19:18:27.024:WARN [launcher]: [39mPhantomJS was not killed in 2000 ms, sending SIGKILL.
[33m29 07 2015 19:18:29.028:WARN [launcher]: [39mPhantomJS was not killed by SIGKILL in 2000 ms, continuing.
Warning: Task "karma:continuous" failed. Use --force to continue.
This is my Gruntfile.js
/*global module:false*/
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
// Metadata.
meta: {
version: '0.1.1'
},
banner: '/*! PROJECT_NAME - v<%= meta.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
'* http://PROJECT_WEBSITE/\n' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> ',
// Task configuration.
concat: {
main: {
options: {
banner: '<%= banner %>',
stripBanners: true
},
dist: {
src: ['lib/**/*.js'],
//src: ['lib/**/broadcast.js'],
dest: 'dist/concat-main-app.js',
//dest: 'dist/concat-broadcast.js',
nonull:true
}
},
modules : {
options: {
banner: '<%= banner %>',
stripBanners: true
},
dist: {
src: ['bower_components/angular/angular.min.js'],
//src: ['lib/**/broadcast.js'],
dest: 'dist/concat-angular.js',
//dest: 'dist/concat-broadcast.js',
nonull:true
}
},
build: {
files: {
'dist/concat-main-app.js': ['lib/**/*.js'],
'dist/concat-angular.js':
[
'bower_components/angular/angular.min.js',
'bower_components/angular-route/angular-route.min.js',
'bootstrap-3.3.4-dist/js/bootstrap.min.js',
'ui-bootstrap-custom-0.12.1.min.js',
'ui-bootstrap-custom-tpls-0.12.1.min.js',
'bower_components/summernote/dist/summernote.min.js',
'bower_components/angular-summernote/dist/angular-summernote.js',
'bower_components/angular-ui-select/dist/select.min.js',
'bower_components/angular-sanitize/angular-sanitize.min.js'
]
}
},
},
uglify: {
options: {
banner: '<%= banner %>'
},
build: {
files: {
'dist/main-app.min.js': ['<%= concat.main.dist.dest %>'],
'dist/checklist-model.min.js': ['bower_components/checklist-model/checklist-model.js']
}
}
},
jshint: {
options: {
jshintrc: '.jshintrc',
loopfunc: true,
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
unused: true,
boss: true,
eqnull: true,
jasmine: true,
devel:true,
asi:true,
lastsemic: true,
globals: {
jQuery: true
}
},
gruntfile: {
src: './Gruntfile.js'
},
lib_test: {
src: ['lib/controller/**/*.js']
}
},
cssmin: {
options: {
shorthandCompacting: false,
roundingPrecision: -1
},
target: {
files: {
'dist/bittrove-css.min.css':
[
'../css/custom.css',
//'../css/select2-3-5-2.css',
//'bootstrap-3.3.4-dist/css/bootstrap.css'
]
}
}
},
karma: {
unit: {
configFile: './karma.conf.js'
},
continuous: {
configFile: './karma.conf.js',
singleRun: true,
browsers: ['PhantomJS']
}
},
watch: {
gruntfile: {
files: '<%= jshint.gruntfile.src %>',
tasks: ['jshint:gruntfile']
},
lib_test: {
files: '<%= jshint.lib_test.src %>',
tasks: ['jshint:lib_test']
}
}
});
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-karma');
// Default task.
grunt.registerTask('default', [ 'concat', 'uglify','cssmin','karma:continuous']);
};
This is my karma.conf.js
// Karma configuration
// Generated on Tue Mar 24 2015 19:54:10 GMT-0500 (CDT)
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: './',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],
// list of files / patterns to load in the browser //ORDER IS IMPORTANT!
files: [
"bower_components/angular/angular.min.js",
"bower_components/angular-mocks/angular-mocks.js",
//"dist/main-app.min.js",
"lib/**/*.js",
"test/*.js",
// "bower_components/angular-latest/test/**/*.js"
],
// list of files to exclude
exclude: [
"bower_components/angular-latest/test/e2e/**",
"bower_components/angular-latest/test/helpers/**"
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],
// web server port
port: 9876,
// 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: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: false,
plugins : [
'karma-jasmine',
'karma-phantomjs-launcher'
],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: true
});
};
This is my Jenkins shell exe:
cd src/app/public/js
npm install
bower install
npm list
I installed nodejs on my Jenkins farm using the NodeJs Plugin.
I have node 0.10.36, bower 1.4.1, grunt-cli v0.1.13, grunt v0.4.5. Karma 0.13.3
I faced the same issue after updating nodejs and karma modules.
Removing PHANTOMJS_BIN environment variable finally solved the issue for me.
I am trying to copy files over from a parent folder using grunt-contrib-copy. My folder structure is:
-libs
-html5shiv
-respond
-jquery
-apps
-exampleApp1
-GruntFile.js
-build
-exampleApp2
-GruntFile.js
-build
I am trying to copy all the JavaScript files from the libs folder over to the apps/exampleApp1/build when I run the GruntFile.js in exampleApp1. I have the following setup in the GruntFile.js:
build_dir: 'build';
lib_files: {
js: [
'../../libs/html5shiv/dist/html5shiv.js',
'../../libs/respond/dest/respond.min.js',
'../../libs/jquery/dist/jquery.min.js'
]
};
copy: {
build_libjs: {
files: [
{
src: [ '<%= lib_files.js %>' ],
dest: '<%= build_dir %>/',
cwd: '.',
expand: true
}
]
},
},
At the moment it copies all the files over to apps/libs because of the '../../' each file has in the lib_files.js array. How can I make sure that the files end up in the build folder like so?:
-apps
-exampleApp1
-GruntFile.js
-build
-libs
-html5shiv/dist/html5shiv.js
-libs/respond/dest/respond.min.js
-jquery/dist/jquery.min.js
The answer is quite simple actually. There is a rename function which can be used in combination with grunt-contrib-copy.
"You just need to attach one parameter to my configuration, which overrides the standard rename function of the Grunt file utilities.".
from:
http://fettblog.eu/blog/2014/05/27/undocumented-features-rename/
I combined this with a simple regular expression and problem solved:
build_libjs: {
files: [
{
src: [ '<%= lib_files.js %>' ],
dest: '<%= build_dir %>/',
cwd: '.',
expand: true,
rename: function(dest, src) {
//Replace '../../' with an empty string
return dest + ( src.replace(/^..\/..\// ,"") );
}
}
]
},
Try using the cwd property to change the source directory
lib_files: {
js: [
'html5shiv/dist/html5shiv.js',
'respond/dest/respond.min.js',
'jquery/dist/jquery.min.js'
]
};
copy: {
build_libjs: {
files: [
{
src: [ '<%= lib_files.js %>' ],
dest: '<%= build_dir %>/',
cwd: '../libs',
expand: true
}
]
},
I am trying to run guinness tests in WebStorm but it Karma does not seem to be recognising the guinness tests.
The following using unittest.dart works (gives me a pass and fail)
void main(){
test('trivial', () {
expect(1, equals(1));
});
test('trivial fail', () {
expect(1, equals(2));
});
}
When I switch to using guinness in the same file:
void main(){
describe('stuff happens', (){
it('works sometimes', (){
expect(1).toEqual(1);
});
it('fails others', (){
expect(1).toEqual(2);
});
});
}
Karma returns a result of NO TESTS.
Here is my karma.config.js
module.exports = function(config) {
config.set({
basePath: '.',
frameworks: ['dart-unittest'],
files: [
'test/*.dart',
{pattern: '**/*.dart', watched: true, included: false, served: true},
'packages/browser/dart.js',
'packages/browser/interop.js'
],
exclude: [
],
autoWatch: true,
captureTimeout: 20000,
browserNoActivityTimeout: 300000,
plugins: [
'karma-dart'
],
karmaDartImports: {
guinness: 'package:guinness/guinness_html.dart'
},
browsers: ['Dartium']
});
};
Does anyone have any suggestions as to what might be wrong?
Thanks
John
Doing the following import statement in the dart test file solved it for me:
import 'package:unittest/unittest.dart' hide expect;
Check the linked tutorial. Maybe you're just missing the 'karma-chrome-launcher' in the plugins of your karma config file.
Karma Dart Step by Step Setup