Related
I am using codeceptJS with webdriverio Selenium standalone server. my problem is how do i load my unpacked chrome extension when i run tests. i’ve been searching for the solution from past 2 days but couldn’t find a solution. all i get is some java code from searches.
first of all thank you very much both of you wOxxOm && Yandimirkin Vladislav
what i did was added few lines into codecept.conf.js
desiredCapabilities: {
chromeOptions: {
args: [ "--load-extension=D:/Projects/dpl/dist", "--disable-gpu", "--window-size=1366,768" ]
}
}
Here is what codecept.conf.js looks like now:
exports.config = {
tests: './*_test.js',
output: './output',
helpers: {
WebDriver: {
url: 'http://localhost',
browser: 'chrome',
desiredCapabilities: {
chromeOptions: {
args: [ "--load-extension=D:/Projects/dpl/dist", "--disable-gpu", "--window-size=1366,768" ]
}
}
},
ResembleHelper : {
require: "codeceptjs-resemblehelper",
screenshotFolder : "./tests/output/",
baseFolder: "./tests/screenshots/base/",
diffFolder: "./tests/screenshots/diff/"
}
},
plugins: {
wdio: {
enabled: true,
services: ['selenium-standalone']
}
},
include: {},
bootstrap: null,
mocha: {},
name: 'codecept'
}
1) Add to you
capababilies: { extensions: extensionsToLoad }
Where extensionsToLoad is array of base64 encoded extensions, something like this
fs.readFileSync("./test.crx").toString("base64")
Build Errors on Netlify. Build exceeds maximum allowed runtime.
Can build locally running yarn build and inside the Netlify docker container, however when on Netlifys build it exceeds maximum allowed runtime.
Am getting some warnings like the below when running in the Netlify docker container
Warning: a promise was created in a handler at opt/buildhome/repo/node_modules/postcss/lib/lazy-result.js:213:17 but was not returned from it
Warning: a promise was created in a handler at /opt/buildhome/repo/node_modules/gatsby-transformer-remark/extend-node-type.js:179:19 but was not returned from it
Those two warnings are pointing to two Gatsby plugins I have configured. (Config below)
require('dotenv').config();
module.exports = {
siteMetadata: {
title: 'My Website',
},
proxy: {
prefix: '/.netlify/functions',
url: 'http://localhost:9000',
},
plugins: [
'gatsby-plugin-eslint',
'gatsby-plugin-react-helmet',
'gatsby-plugin-postcss',
{
resolve: 'gatsby-source-contentful',
options: {
spaceId: process.env.SPACE_ID,
accessToken: process.env.ACCESS_TOKEN,
},
},
{
resolve: 'gatsby-plugin-react-svg',
options: {
rule: {
exclude: /img/,
},
},
},
'gatsby-plugin-sharp',
{
resolve: 'gatsby-transformer-remark',
options: {
plugins: [
{
resolve: 'gatsby-remark-images-contentful',
options: {
maxWidth: 590,
},
},
],
},
},
'gatsby-plugin-netlify', // make sure to keep it last in the array
],
};
Have tried to debug all weekend but not sure what else to do. I couldn't find anyone else who has had similar issues.
I'm new in using Grunt tool, I was doing the steps like the video said, but i faced some errors and started from the whole beginning again, but now i'm facing this issue, when i type the command "grunt" in the CMD in the directory of the project folder i get everything good, but there is no JavaScript file created in the distribution folder directory "dist/scripts", and even the Uglify is not generated.
In the video after the instructor typed the command grunt a JS file created in dist/scripts directory with name "main.6c5adb2140e008f7bb85.js", and css file created in dist/styles directory with name "main.d1901e133950f2e3aeae.css", and also in his terminal it was written replaced 1 reference to assets and Uglify generated like in the picture:
Instead i get replaced 0 references to assets and the uglify is not generated:
I did all the installation command that in the video by order, and i created all the files (package.json, Gruntfile.js, app.js, .jshintrc)
after that i added the usemin to the require jit-grunt
and added it to the registerTask. Here's the Gruntfile.js source code:
'use strict';
module.exports = function (grunt) {
// Time how long tasks take. Can help when optimizing build times
require('time-grunt')(grunt);
// Automatically load required Grunt tasks
require('jit-grunt')(grunt, {
useminPrepare: 'grunt-usemin'
});
// Define the configuration for all the tasks
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// Make sure code styles are up to par and there are no obvious mistakes
jshint: {
options: {
jshintrc: '.jshintrc',
reporter: require('jshint-stylish')
},
all: {
src: [
'Gruntfile.js',
'app/scripts/{,*/}*.js'
]
}
},
useminPrepare: {
html: 'app/menu.html',
options: {
dest: 'dist'
}
},
// Concat
concat: {
options: {
separator: ';'
},
// dist configuration is provided by useminPrepare
dist: {}
},
// Uglify
uglify: {
// dist configuration is provided by useminPrepare
dist: {}
},
cssmin: {
dist: {}
},
// Filerev
filerev:{
options: {
encoding: 'utf8',
algorithm: 'md5',
length: 20
},
release: {
// filerev: release hashes(md5) all assets (images, js and css)
// in dist directory
files: [{
src: [
'dist/scripts/*.js',
'dist/styles/*.css',
]
}]
}
},
// Usemin
// Replace all assets with their revved version in html and css files.
// options.assetDirs contains the directories for finding the assets
// according to their relative paths
usemin: {
html: ['dist/*.html'],
css: ['dist/styles/*.css'],
options: {
assetsDirs: ['dist', 'dist/styles']
}
},
copy: {
dist: {
cwd: 'app',
src: [ '**','!styles/**/*.css','!scripts/**/*.js' ],
dest: 'dist',
expand: true
},
fonts: {
files: [
{
//for bootstrap fonts
expand: true,
dot: true,
cwd: 'bower_components/bootstrap/dist',
src: ['fonts/*.*'],
dest: 'dist'
}, {
//for font-awesome
expand: true,
dot: true,
cwd: 'bower_components/font-awesome',
src: ['fonts/*.*'],
dest: 'dist'
}
]
}
},
clean: {
build: {
src: [ 'dist/']
}
}
});
grunt.registerTask('build', [
'clean',
'jshint',
'useminPrepare',
'concat',
'cssmin',
'uglify',
'copy',
'filerev',
'usemin'
]);
grunt.registerTask('default',['build']);
};
Need help please !!
it's look like there is no mistake in the commands that 've wrote but the mistake here is the name of the html in my project folder is not the same name which is "menu.html" and i wrote it in Gruntfile "meun.html" that's why it doesn't create the js & css file !!
Backend of our app is in PHP and for frontend we are using AngularJs.
We successfully managed to run e2e tests on local as well as on production server using protractor.
After writing loads of e2e tests for our app, we started looking for its coverage similar to that of unit testing. After searching for lot, luckily we find https://www.npmjs.com/package/grunt-protractor-coverage , exactly what we wanted.
I took help from http://lkrnac.net/blog/2014/04/measuring-code-coverage-by-protractor/ article which beautifully helps in setting up everything. I setup the config and other grunt tasks for my app, and finally our code(js files) were properly instrumented. I copied the rest of the files(html, static, etc.) to that instrumented code and provided the correct path for the proractor-config file. Tests started running as they were running before, but this time with instrumented files.
Till this point, everything is OK. But when the task for generating coverage-report was executed, we figured that we had empty coverage.json file {}. This means the report will surely be empty as it reads that file to generate report, and as far as I have figured out, this file is generated by protractor-coverage grunt task while tests are executing. It sends the information to the collector(port: 3001) using a POST req and while generating report, a GET req is being made to the same collector.
So, what I figured is, No POST req is being made to collector.
var options = {
hostname: 'localhost',
port: <%=collectorPort%>,
path: '/data',
method: 'POST',
headers:{
'Content-Type':'application/json'
}
};
function saveCoverage(data){
var req = http.request(options, function(res) {
res.on('data', function (chunk) {
});
});
req.on('error', function(e) {
console.log('problem with request: ' + e.message);
});
// write data to request body
req.write(JSON.stringify(data));
req.write('\n');
req.end();
}
Each time it just shows
where it should have listed down every file:
And also, that 100 everywhere is misleading, I ran tests for the source code: http://lkrnac.net/blog/2014/04/measuring-code-coverage-by-protractor/ as explained, but even if there's only one e2e test, the report must have given the actual numbers instead of giving a straight 100 for all.
It might happen that I have some wrong configuration or missed something.
Below are my files:
'use strict';
module.exports = function(grunt) {
// Load grunt tasks automatically
require('load-grunt-tasks')(grunt);
// Define the configuration for all the tasks
grunt.initConfig({
// Project settings
yeoman: {
// configurable paths
app: 'app',
dist: 'dist-test',
e2e: 'coverage/e2e',
instrumentedServer: 'coverage/server/instrument',
instrumentedE2E: 'coverage/e2e/instrumented'
},
// Empties folders to start fresh
clean: {
coverageE2E: {
src: ['<%= yeoman.e2e %>/'],
}
},
// Copies remaining files to places other tasks can use
copy: {
coverageE2E: {
files: [{
expand: true,
dot: true,
cwd: '<%= yeoman.app %>',
dest: '<%= yeoman.e2e %>/instrumented/app',
src: [
'**/*',
'!modules/**/*.js',
'!editor/**/*.js'
]
}, {
expand: true,
cwd: '.tmp/images',
dest: '<%= yeoman.e2e %>/instrumented/app/images',
src: ['generated/*']
}, ]
},
},
// start - code coverage settings
instrument: {
files: ['app/modules/**/*.js', 'app/editor/**/*.js'],
options: {
lazy: true,
basePath: 'coverage/e2e/instrumented/'
}
},
makeReport: {
src: '<%= yeoman.instrumentedE2E %>/*.json',
options: {
type: 'html',
dir: '<%= yeoman.e2e %>/reports',
print: 'detail',
// type: 'lcov'
// dir: 'reports'
}
},
protractor_coverage: {
options: {
configFile: 'test/e2e/protractor-config.js', // Default config file
keepAlive: true, // If false, the grunt process stops when the test fails.
noColor: false, // If true, protractor will not use colors in its output.
coverageDir: '<%= yeoman.instrumentedE2E %>',
args: {},
run: {}
},
chrome: {
options: {
args: {
baseUrl: 'https://localapp.vwo.com/v3/#/',
// Arguments passed to the command
'browser': 'chrome'
}
}
}
}
});
grunt.registerTask('default', [
'clean:coverageE2E',
'copy:coverageE2E',
'instrument',
'protractor_coverage:chrome',
'makeReport'
]);
};
And my coverage.json file:
{}
I'm trying to use grunt-ng-annotate in my build, and my files don't seem to be annotated when I view them.
ngAnnotate: {
options: {
singleQuotes: true
},
dist: {
files: [{
expand: true,
cwd: '.tmp/concat/scripts',
src: '*.js',
dest: '.tmp/concat/scripts'
}]
}
},
However, if I add:
ext: '.annotated.js',
Then I can see the annotation in the file. It appears that somehow, it just doesn't want to overwrite the old files, unless I name them something different. What's the deal here?
I encountered this problem today as well. I decided to post solution for myself, because I really struggled with this and thought maybe someone else may need this at some point. So what I had to do was set remove and add options for ngAnnotate, so it can remove and add annotated items like this:
ngAnnotate: {
options: {
remove: true,
add: true
},
dist: {
files: [{
expand: true,
sourceMap: true,
src: 'src/js/**/*.js',
}],
}
},