Protractor + jasmine : run same spec twice with different params: - jasmine

Hi this is my config :
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./e2e/xyz/xyz.e2e-spec.ts',
],
multiCapabilities: [
{
browserName: 'chrome',
chromeOptions: {
args: ['--headless', '--disable-gpu', '--window-size=1024x768', '--no-sandbox']
}
}
/* Failing in Jeniks, TODO : need to fix this,
{
browserName: 'firefox',
firefoxOptions: {
args: ['--headless']
},
'moz:firefoxOptions': {
args: ['--headless']
}
}
*/
],
directConnect: true,
chromeOnly: false,
baseUrl: nconf.get('BASE_URL'),
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 120000,
includeStackTrace : true,
print: function () { }
},
restartBrowserBetweenTests: false,
useAllAngular2AppRoots: true,
onPrepare: function () {
require('ts-node').register({
project: './e2e/tsconfig.json'
});
let SpecReporter = require('jasmine-spec-reporter').SpecReporter;
jasmine.getEnv().addReporter(new SpecReporter({displayStacktrace: 'spec'}));
},
params: {
login: {
username: nconf.get('USERNAME'),
password: nconf.get('PASSWORD'),
username_d: nconf.get('D_USERNAME'),
password_d: nconf.get('D_PASSWORD')
},
sddc_id: nconf.get('SDDC_ID'),
org_id: nconf.get('ORG_ID'),
env: nconf.get('env'),
d_sddc_id: nconf.get('D_SDDC_ID')
}
Now I want to call xyz.e2e-spec.ts twice for different usernames and passwords. Is there a way to run "describe('SOme work', () => {). twice in xyz.e2e-spec.ts?. I mean for loop wont works on this since describe is a function.

Related

Vscode rust-analyser plugin, on macOS; failing to load workspace due to permission denied

Goal
I'm trying to setup Visual Studio Code(vscode) on macOS for rust development.
I had my setup working, using the official rust extension, but it wasn't always consistent.
I saw that the rust-analyzer extension could provide a better experience.
Problem
Now that I have installed the extension, It keep throwing the following error:
rust-analyzer failed to load workspace: "/Users/michaelbailey/.cargo" "--version" failed: Permission denied (os error 13)
From my understanding, the plugin is trying to execute the .cargo folder rather than cargo itself.
running
$ /Users/michaelbailey/.cargo --version
zsh: permission denied: /Users/michaelbailey/.cargo
instead of
$ /Users/michaelbailey/.cargo/bin/cargo --version
cargo 1.61.0 (a028ae42f 2022-04-29)
This is causing rust analyser to fail loading any project.
What i have tried
Reinstalling the Rust-analyzer extension.
Disabling other rust based plugins.
Switching to the pre-release version.
reinstalling rust from the rust website.
clearing all rust settings.
creating a new project to test if my project was misconfigured somehow.
what i need help with
finding out a way to config rust-analyzer to point to the right file.
another way to resolve rust-analyzer.
Any help or pointers on the matter would be greatly appreciated.
Logs
output of rust-analyzer, in the vscode output tab.
INFO [6/9/2022, 6:10:00 PM]: Extension version: 0.3.1083
INFO [6/9/2022, 6:10:00 PM]: Using configuration {
cargoRunner: null,
runnableEnv: null,
server: { path: null, extraEnv: null },
trace: { server: 'off', extension: false },
debug: {
engine: 'auto',
sourceFileMap: {
'/rustc/<id>': '${env:USERPROFILE}/.rustup/toolchains/<toolchain-id>/lib/rustlib/src/rust'
},
openDebugPane: false,
engineSettings: {}
},
assist: { expressionFillDefault: 'todo' },
cachePriming: { enable: true, numThreads: 0 },
cargo: {
autoreload: true,
buildScripts: { enable: true, overrideCommand: null, useRustcWrapper: true },
features: [],
noDefaultFeatures: false,
noSysroot: false,
target: null,
unsetTest: [ 'core' ]
},
checkOnSave: {
allTargets: true,
command: 'check',
enable: true,
extraArgs: [],
features: null,
noDefaultFeatures: null,
overrideCommand: null,
target: null
},
completion: {
autoimport: { enable: true },
autoself: { enable: true },
callable: { snippets: 'fill_arguments' },
postfix: { enable: true },
privateEditable: { enable: false },
snippets: {
custom: {
'Arc::new': {
postfix: 'arc',
body: 'Arc::new(${receiver})',
requires: 'std::sync::Arc',
description: 'Put the expression into an `Arc`',
scope: 'expr'
},
'Rc::new': {
postfix: 'rc',
body: 'Rc::new(${receiver})',
requires: 'std::rc::Rc',
description: 'Put the expression into an `Rc`',
scope: 'expr'
},
'Box::pin': {
postfix: 'pinbox',
body: 'Box::pin(${receiver})',
requires: 'std::boxed::Box',
description: 'Put the expression into a pinned `Box`',
scope: 'expr'
},
Ok: {
postfix: 'ok',
body: 'Ok(${receiver})',
description: 'Wrap the expression in a `Result::Ok`',
scope: 'expr'
},
Err: {
postfix: 'err',
body: 'Err(${receiver})',
description: 'Wrap the expression in a `Result::Err`',
scope: 'expr'
},
Some: {
postfix: 'some',
body: 'Some(${receiver})',
description: 'Wrap the expression in an `Option::Some`',
scope: 'expr'
}
}
}
},
diagnostics: {
disabled: [],
enable: true,
experimental: { enable: false },
remapPrefix: {},
warningsAsHint: [],
warningsAsInfo: []
},
files: { excludeDirs: [], watcher: 'client' },
highlightRelated: {
breakPoints: { enable: true },
exitPoints: { enable: true },
references: { enable: true },
yieldPoints: { enable: true }
},
hover: {
actions: {
debug: { enable: true },
enable: true,
gotoTypeDef: { enable: true },
implementations: { enable: true },
references: { enable: false },
run: { enable: true }
},
documentation: { enable: true },
links: { enable: true }
},
imports: {
granularity: { enforce: false, group: 'crate' },
group: { enable: true },
merge: { glob: true },
prefix: 'plain'
},
inlayHints: {
bindingModeHints: { enable: false },
chainingHints: { enable: true },
closingBraceHints: { enable: true, minLines: 25 },
closureReturnTypeHints: { enable: 'never' },
lifetimeElisionHints: { enable: 'never', useParameterNames: false },
maxLength: 25,
parameterHints: { enable: true },
reborrowHints: { enable: 'never' },
renderColons: true,
typeHints: {
enable: true,
hideClosureInitialization: false,
hideNamedConstructor: false
}
},
joinLines: {
joinAssignments: true,
joinElseIf: true,
removeTrailingComma: true,
unwrapTrivialBlock: true
},
lens: {
debug: { enable: true },
enable: true,
forceCustomCommands: true,
implementations: { enable: true },
references: {
adt: { enable: false },
enumVariant: { enable: false },
method: { enable: false },
trait: { enable: false }
},
run: { enable: true }
},
linkedProjects: [],
lru: { capacity: null },
notifications: { cargoTomlNotFound: true },
procMacro: {
attributes: { enable: true },
enable: true,
ignored: {},
server: null
},
runnables: { command: null, extraArgs: [] },
rustc: { source: null },
rustfmt: {
extraArgs: [],
overrideCommand: null,
rangeFormatting: { enable: false }
},
semanticHighlighting: { strings: { enable: true } },
signatureInfo: { detail: 'full', documentation: { enable: true } },
typing: { autoClosingAngleBrackets: { enable: false } },
workspace: {
symbol: { search: { kind: 'only_types', limit: 128, scope: 'workspace' } }
}
}
INFO [6/9/2022, 6:10:00 PM]: PersistentState: { serverVersion: '0.3.1083' }
INFO [6/9/2022, 6:10:00 PM]: Using server binary at /Users/michaelbailey/.vscode/extensions/rust-lang.rust-analyzer-0.3.1083-darwin-x64/server/rust-analyzer
INFO [6/9/2022, 6:10:01 PM]: Extension version: 0.3.1083
INFO [6/9/2022, 6:10:01 PM]: Using configuration {
cargoRunner: null,
runnableEnv: null,
server: { path: null, extraEnv: null },
trace: { server: 'off', extension: false },
debug: {
engine: 'auto',
sourceFileMap: {
'/rustc/<id>': '${env:USERPROFILE}/.rustup/toolchains/<toolchain-id>/lib/rustlib/src/rust'
},
openDebugPane: false,
engineSettings: {}
},
assist: { expressionFillDefault: 'todo' },
cachePriming: { enable: true, numThreads: 0 },
cargo: {
autoreload: true,
buildScripts: { enable: true, overrideCommand: null, useRustcWrapper: true },
features: [],
noDefaultFeatures: false,
noSysroot: false,
target: null,
unsetTest: [ 'core' ]
},
checkOnSave: {
allTargets: true,
command: 'check',
enable: true,
extraArgs: [],
features: null,
noDefaultFeatures: null,
overrideCommand: null,
target: null
},
completion: {
autoimport: { enable: true },
autoself: { enable: true },
callable: { snippets: 'fill_arguments' },
postfix: { enable: true },
privateEditable: { enable: false },
snippets: {
custom: {
'Arc::new': {
postfix: 'arc',
body: 'Arc::new(${receiver})',
requires: 'std::sync::Arc',
description: 'Put the expression into an `Arc`',
scope: 'expr'
},
'Rc::new': {
postfix: 'rc',
body: 'Rc::new(${receiver})',
requires: 'std::rc::Rc',
description: 'Put the expression into an `Rc`',
scope: 'expr'
},
'Box::pin': {
postfix: 'pinbox',
body: 'Box::pin(${receiver})',
requires: 'std::boxed::Box',
description: 'Put the expression into a pinned `Box`',
scope: 'expr'
},
Ok: {
postfix: 'ok',
body: 'Ok(${receiver})',
description: 'Wrap the expression in a `Result::Ok`',
scope: 'expr'
},
Err: {
postfix: 'err',
body: 'Err(${receiver})',
description: 'Wrap the expression in a `Result::Err`',
scope: 'expr'
},
Some: {
postfix: 'some',
body: 'Some(${receiver})',
description: 'Wrap the expression in an `Option::Some`',
scope: 'expr'
}
}
}
},
diagnostics: {
disabled: [],
enable: true,
experimental: { enable: false },
remapPrefix: {},
warningsAsHint: [],
warningsAsInfo: []
},
files: { excludeDirs: [], watcher: 'client' },
highlightRelated: {
breakPoints: { enable: true },
exitPoints: { enable: true },
references: { enable: true },
yieldPoints: { enable: true }
},
hover: {
actions: {
debug: { enable: true },
enable: true,
gotoTypeDef: { enable: true },
implementations: { enable: true },
references: { enable: false },
run: { enable: true }
},
documentation: { enable: true },
links: { enable: true }
},
imports: {
granularity: { enforce: false, group: 'crate' },
group: { enable: true },
merge: { glob: true },
prefix: 'plain'
},
inlayHints: {
bindingModeHints: { enable: false },
chainingHints: { enable: true },
closingBraceHints: { enable: true, minLines: 25 },
closureReturnTypeHints: { enable: 'never' },
lifetimeElisionHints: { enable: 'never', useParameterNames: false },
maxLength: 25,
parameterHints: { enable: true },
reborrowHints: { enable: 'never' },
renderColons: true,
typeHints: {
enable: true,
hideClosureInitialization: false,
hideNamedConstructor: false
}
},
joinLines: {
joinAssignments: true,
joinElseIf: true,
removeTrailingComma: true,
unwrapTrivialBlock: true
},
lens: {
debug: { enable: true },
enable: true,
forceCustomCommands: true,
implementations: { enable: true },
references: {
adt: { enable: false },
enumVariant: { enable: false },
method: { enable: false },
trait: { enable: false }
},
run: { enable: true }
},
linkedProjects: [],
lru: { capacity: null },
notifications: { cargoTomlNotFound: true },
procMacro: {
attributes: { enable: true },
enable: true,
ignored: {},
server: null
},
runnables: { command: null, extraArgs: [] },
rustc: { source: null },
rustfmt: {
extraArgs: [],
overrideCommand: null,
rangeFormatting: { enable: false }
},
semanticHighlighting: { strings: { enable: true } },
signatureInfo: { detail: 'full', documentation: { enable: true } },
typing: { autoClosingAngleBrackets: { enable: false } },
workspace: {
symbol: { search: { kind: 'only_types', limit: 128, scope: 'workspace' } }
}
}
I've had the same problem. The reason was that the environment variable CARGO was set to ~/.cargo in my shell resources file. Removing it solved the problem.
You can check your environment by running echo $CARGO.

Getting "Syntax error" when trying to setup Jasmine2HtmlReporter

Setting up Jasmine2HtmlReporter for my Protractor project.
Adding next code to my conf.js file:
onPrepare: function() {
jasmine.getEnv().addReporter(
new Jasmine2HtmlReporter({
savePath: 'target/screenshots'
})
);
}
And getting next error:
onPrepare: function() {
^^^^^^^^^
SyntaxError: Unexpected identifier
Below my whole conf.js file:
var Jasmine2HtmlReporter = require('protractor-jasmine2-html-reporter');
exports.config = {
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 100000
},
capabilities: {
'browserName': 'chrome'
},
directConnect: true,
framework: 'jasmine',
specs: ['specs/calbarSpec.js']
onPrepare: function() {
jasmine.getEnv().addReporter(
new Jasmine2HtmlReporter({
savePath: 'target/screenshots'
})
);
}
};
var Jasmine2HtmlReporter = require('protractor-jasmine2-html-reporter');
exports.config = {
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 100000
},
capabilities: {
'browserName': 'chrome'
},
directConnect: true,
framework: 'jasmine',
specs: ['specs/calbarSpec.js'],
onPrepare: function() {
jasmine.getEnv().addReporter(
new Jasmine2HtmlReporter({
savePath: 'target/screenshots'
})
);
}
};
Put a comma after the "specs" key.

Test Export / Download file with protractor

i got a problem. Can someome help me !
i want to export file from export button in js page and download file to a directory in my project for testing. But i cant change download default_directory. when i run test, it was downloaded in /Downloads , not /resource/download/ directory.
How can i set download directory for protractor
This is my protractor-config.js
directConnect: true,
multiCapabilities: [
{
browserName: 'firefox',
acceptInsecureCerts: true,
'moz:firefoxOptions': {
args: ["--headless"]
},
prefs: {
'download': {
'prompt_for_download': false,
'default_directory': process.cwd() + "/resources/test/download",
'directory_upgrade': true
},
},
},
{
browserName: 'chrome',
acceptInsecureCerts: true,
chromeOptions: {
args: [
"--headless",
]
},
prefs: {
'download': {
'prompt_for_download': false,
'default_directory': process.cwd() + "/resources/test/download",
'directory_upgrade': true,
},
},
}
],
Try the below one,
capabilities: {
'browserName': 'chrome',
'chromeOptions': {
prefs: {
download: {
'prompt_for_download': false,
'directory_upgrade': true,
'default_directory': process.cwd() + '/resources/test/download' // change in this place
}
}
}
},
Hope it helps you

No autoprefix with webpack config

I'm getting no prefixes with these setup. Cssnano and write to style.css is working but there is no prefixes added from my sass to css.
I'm just started with webpack so maybe I'm just not gettings it.
Config:
var development = process.env.NODE_ENV !== "production";
var webpack = require('webpack');
var path = require('path');
var precss = require('precss');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var cssnano = require('cssnano');
var autoprefixer = require('autoprefixer');
var extractCSS = new ExtractTextPlugin('style.css');
module.exports = [
{
name: 'app-bundle',
entry: "./src/js/main.js",
module: {
loaders: [
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
},
]
},
output: {
path: "",
filename: "bundle.min.js"
},
plugins: development ? [
]: [
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({ mangle: false, sourcemap: false }),
],
},
{
name: 'css/scss',
entry: './src/sass/style.scss',
module: {
loaders:
[
{
test: /\.scss$/,
loader: extractCSS.extract('style', 'css!postcss!sass')
}
]
},
postcss: function(webpack)
{
returnĀ [
cssnano({
autoprefixer: {
add: true,
remove: false,
browsers: [
'last 2 versions',
'ie >= 9'
]
},
discardComments: {
removeAll: true
},
discardUnused: false,
mergeIdents: false,
reduceIdents: false,
safe: true,
sourcemap: true
})
]
},
output: {
path: "",
filename: "style.css"
},
plugins: development ? [
extractCSS
] : []
}
];
There is a problem with your postcss plugin declaration
postcss: function(webpack)
{
return [
autoprefixer(), // Should be a function call and not reside inside cssnano config
cssnano({
discardComments: {
removeAll: true
},
discardUnused: false,
mergeIdents: false,
reduceIdents: false,
safe: true,
sourcemap: true
}),
]
},

TypeScript compilation extremely slow > 12s

Just putting this out there to see if someone else is having this issue...
I have building an angular 2 app with typescript using webpack as my build tool, it all works well, however I have noticed typescript compilation is super super slow, I am at 12 seconds right now...., and its pretty clear that is all due to the typescript compilation process....
I have used ts-loader or awesome-typescript-loader with a similar result, if I comment out this loader, my build time drops to around 1 sec....
After some research it seems like its 'normal' to have 'slow' times when compiling typescript, but is 12secs the normal??
Old posts hinted it might be due to a node version conflict, I am currently running v4.4.2...
Any how below is my webpack code in case anyone spots something wrong there.. the commented code in the Uglify section is due to some 'bug' on the angular 2 side...
const path = require('path');
const merge = require('webpack-merge');
const webpack = require('webpack');
const NpmInstallPlugin = require('npm-install-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const TARGET = process.env.npm_lifecycle_event;
const PATHS = {
app: path.join(__dirname, 'app'),
dist: path.join(__dirname, 'dist')
};
const common = {
entry: {
vendor: ['./app/vendor.ts'],
main: ['./app/boot.component.ts']
},
output: {
filename: '[name].[hash].bundle.js',
path: PATHS.dist
},
resolve: {
extensions: ['', '.js', '.ts']
},
plugins: [
new HtmlWebpackPlugin({
title: 'Qarrot Performance',
template: 'index.template.ejs',
commonStyles: [
'/public/styles/vendor/normalize.css',
'/public/styles/main.css'
],
commonScripts: [],
baseHref: '/',
unsupportedBrowser: true,
mobile: true,
appMountId: 'app'
}),
],
module: {
loaders: [
{
test: /\.ts$/,
exclude: /node_modules/,
loaders: ['ts-loader']
},
{
test: /\.scss$/,
loader: 'raw-loader!sass-loader'
},
{
test: /\.html$/,
loader: "html"
}
]
}
}
// Dev Settings
if(TARGET === 'start' || !TARGET) {
module.exports = merge(common, {
devtool: 'eval-source-map',
devServer: {
contentBase: PATHS.build,
historyApiFallback: true,
hot: true,
inline: true,
progress: true,
stats: 'errors-only',
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new NpmInstallPlugin({
save: true
})
]
});
}
// Prod Settings
if(TARGET === 'build') {
module.exports = merge(common, {
devtool: 'cheap-module-source-map',
plugins: [
// new webpack.optimize.UglifyJsPlugin({
// beautify: false,
// mangle: false,
// compress : { screw_ie8 : true },
// comments: false
// }),
new webpack.optimize.DedupePlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': '"production"'
}),
new CopyWebpackPlugin([
{ from: 'public', to: 'public' }
]),
new webpack.optimize.CommonsChunkPlugin({
names: ['vendor', 'manifest']
}),
]
});
}
I am also on a Mac, running Angular 2 beta.15 and webpack version 1.12, below is my tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
},
"compileOnSave": false,
"exclude": [
"node_modules",
"typings/main",
"typings/main.d.ts"
]
}
I would stick to the awesome-typescript-loader. It has some performance options you can enable: a caching option and a transpile only option:
"awesomeTypescriptLoaderOptions": {
"useCache": true,
"transpileOnly": true
}
Both of these had a significant improvement on compile times.
Please share you tsconfig.json. Most likely you have noEmitOnError set to true which means that the compiler is forced to typecheck the whole codebase before any emitting.
Please set that to false.

Resources