Why protractor cucumber is not able to locate step file with latest version of Cucumber in Protractor Cucumber framework - protractor

I'm working with protractor cucumber framework and since from the long time i observed is cucumber is not able to find the spec file in the project. I have used the cucumber latest version 6.0.3 it is not able to find the spec file but same code i have run using the cucumber 1.3.3.. can any body tell me what's the difference with this versions? is there any thing i need to update for 6.0.3
Cucumber Dependency - 1.3.3
"cucumber": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/cucumber/-/cucumber-1.3.3.tgz",
"integrity": "sha1-Za+2Xy+T9y2teN8qterPFGCf7C8=",
"requires": {
"camel-case": "^3.0.0",
"cli-table": "^0.3.1",
"co": "^4.6.0",
"colors": "^1.1.2",
"commander": "^2.9.0",
"duration": "^0.2.0",
"figures": "1.7.0",
"gherkin": "^4.1.0",
"glob": "^7.0.0",
"is-generator": "^1.0.2",
"lodash": "^4.0.0",
"stack-chain": "^1.3.5",
"stacktrace-js": "^1.3.0"
}
Cucumber Dependency 6.0.3 Latest
"cucumber": {
"version": "6.0.3",
"resolved": "https://registry.npmjs.org/cucumber/-/cucumber-6.0.3.tgz",
"integrity": "sha512-FSx7xdAQfFjcxp/iRBAuCFSXp2iJP1tF2Q5k/a67YgHiYbnwsD9F+UNv9ZG90LFHNsNQhb+67AmVxHkp4JRDpg==",
"dev": true,
"requires": {
"assertion-error-formatter": "^3.0.0",
"bluebird": "^3.4.1",
"cli-table3": "^0.5.1",
"colors": "^1.1.2",
"commander": "^3.0.1",
"cucumber-expressions": "^8.0.1",
"cucumber-tag-expressions": "^2.0.2",
"duration": "^0.2.1",
"escape-string-regexp": "^2.0.0",
"figures": "^3.0.0",
"gherkin": "5.0.0",
"glob": "^7.1.3",
"indent-string": "^4.0.0",
"is-generator": "^1.0.2",
"is-stream": "^2.0.0",
"knuth-shuffle-seeded": "^1.0.6",
"lodash": "^4.17.14",
"mz": "^2.4.0",
"progress": "^2.0.0",
"resolve": "^1.3.3",
"serialize-error": "^4.1.0",
"stack-chain": "^2.0.0",
"stacktrace-js": "^2.0.0",
"string-argv": "^0.3.0",
"title-case": "^2.1.1",
"util-arity": "^1.0.2",
"verror": "^1.9.0"
}
StepDef
module.exports=function(){
this.Given(/^Open the browser and Load the URL$/,async function(){
await firstBrowser.get(properties.get("url1"));
browser.logger.info("Title of the window is :"+await browser.getTitle());
//screenshots.takesScreenshot("filename");
});
this.When(/^User entered the text in the search box$/,async function(){
firstBrowser.sleep(3000);
await page1.email().sendKeys(testData.Login.CM[0].Username);
browser.sleep(3000);
await page1.password().sendKeys(testData.Login.CM[0].Password);
});
}
Config File
exports.config = {
//seleniumAddress: 'http://localhost:4444/wd/hub',
getPageTimeout: 60000,
allScriptsTimeout: 500000,
directConnect:true,
framework: 'custom',
// path relative to the current config file
frameworkPath: require.resolve('protractor-cucumber-framework'),
capabilities: {
'browserName': 'chrome'
},
ignoreUncaughtExceptions:true,
// Spec patterns are relative to this directory.
specs: [
'H:\\workspace\\Protractor_Cucumber\\src\\FeatureFiles\\Test.feature'
],
cucumberOpts: {
require: 'H:\\workspace\\Protractor_Cucumber\\src\\StepDefFiles\\*.js',
tags: false,
profile: false,
'no-source': true
},
onPrepare: function () {
browser.waitForAngularEnabled(false);
const {Given, Then, When, Before} = require('cucumber');
}
};
i didn't used any cucumber hooks in my test scripts..
What makes them to work different, can some help in this?

One reason is Then/When/Given usage change in cucumber 6.x, you can change few step functions to verify this.
For 1.x step function file looks like
module.exports = function () {
this.Then(/^Then the response status is (.*)$/, function (status) {
assert.equal(this.responseStatus, status)
});
this.When(//, ...)
}
For 6.x step function file looks like
const { Then, When } = require('cucumber');
Then(/^the response status is (.*)$/, function (status) {
assert.equal(this.responseStatus, status)
});
When(//,...)
Another possible reason is need to upgrade protractor-cucumber-framework version which is compatible with the cucumber#6.x

Related

Set up testing-library/react with mocha got SyntaxError: Unexpected token

I am setting up testing-library/react with mocha. Faced a lot of problems on the setup that were resolved by installing babel libraries and configuring them in .babelrc file as explained on the bottom most part of this question. Now, I am stuck on this error:
> mocha --exit --require #babel/register --require jsdom-global/register
D:\projects\demo_app\node_modules\antd\es\row\index.js:1
(function (exports, require, module, __filename, __dirname) { import { Row } from '../grid';
^
SyntaxError: Unexpected token {
at new Script (vm.js:79:7)
at createScript (vm.js:251:10)
at Object.runInThisContext (vm.js:303:10)
at Module._compile (internal/modules/cjs/loader.js:657:28)
This comes from ant.design component which uses the syntax above. I have tried to test a dummy component like below:
const component = () => (<div>hello</div>)
And it has no problem. But whenever I import my real component that I need to test that is using ant design, I get the error above.
Is it setup part for babel not configured properly? I have no idea how to fix the error. Somehow have a guess that it might be related to babel presets or plugins.
P.S. My project is using Create React App, the exact same test runs smoothly with Jest, but for some reason I don't want to use jest.
Below is .babelrc
{
"presets": [
["#babel/preset-env",
{
"targets": {
"esmodules": true,
"node": "current"
}
}
],
["#babel/preset-react"]
],
"plugins": [
["#babel/plugin-proposal-class-properties"],
["module-resolver", {
"root": ["./src"],
"alias": {
"underscore": "lodash"
}
}]
]
}
Below is package.json
{
"dependencies": {
"antd": "^4.4.2",
"axios": "^0.19.2",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-google-oauth": "^1.0.0",
"react-icons": "^3.10.0",
"react-redux": "^7.1.3",
"react-router-dom": "^5.1.2",
"react-scripts": "3.3.1",
"recompose": "^0.30.0",
"redux": "^4.0.5",
"redux-thunk": "^2.3.0",
"styled-components": "^5.0.1",
"validator": "^13.1.17"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "mocha --exit --require #babel/register --require jsdom-global/register",
"test:jest": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"#babel/core": "7.12.9",
"#babel/plugin-proposal-class-properties": "7.12.1",
"#babel/preset-env": "^7.12.7",
"#babel/preset-react": "7.12.7",
"#babel/register": "7.12.1",
"#testing-library/jest-dom": "^4.2.4",
"#testing-library/react": "^9.5.0",
"#testing-library/user-event": "^7.2.1",
"babel-eslint": "10.1.0",
"babel-plugin-module-resolver": "^4.0.0",
"chai": "4.2.0",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.2",
"eslint-plugin-flowtype": "^3.13.0",
"eslint-plugin-import": "^2.20.1",
"husky": "^4.2.1",
"jsdom": "^16.4.0",
"jsdom-global": "^3.0.2",
"mocha": "8.2.1",
"msw": "^0.19.5",
"react-test-renderer": "^16.13.1",
"redux-mock-store": "^1.5.4",
"standard": "^14.3.1"
},
"optionalDependencies": {
"fsevents": "^2.1.2"
},
"standard": {
"parser": "babel-eslint",
"ignore": [
"/public"
]
},
"jest": {
"transformIgnorePatterns": [
"node_modules/?!(react)/"
]
},
"extends": [
"eslint:recommended",
"plugin:react/recommended"
]
}
Any help would be appreciated.
You have "esmodules": true which forces Babel to use ES modules. That means that if you're using Node, it needs to support ES modules, and you either need to have your tests in .mjs files or have "type": "module" in package.json. If this isn't supported or you want to support older Node versions, remove "esmodules": true from your Babel config to enable compatibility with CJS modules.

Ava additional babel plugins are not being run

I'm trying to use an additional babel plugin when running Ava to transpile react dynamic imports so they can run on node (based on this response)
ava dynamic syntax import enable support
I cannot add it to my main .babelrc file as we are implementing bundle splitting in webpack.
To get around this I'm trying to include the plugin through ava's babel configuration. When I run ava, babel does not use the additional plugin.
package.json
{
"dependencies": {
"babel-cli": "6.16.0",
"babel-core": "^6.26.3",
"babel-eslint": "7.2.1",
"babel-loader": "^7.1.2",
"babel-plugin-dynamic-import-node": "^2.1.0",
"babel-plugin-flow-react-proptypes": "^5.1.2",
"babel-plugin-module-resolver": "^2.7.1",
"babel-plugin-recharts": "1.1.0",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"babel-plugin-transform-async-to-generator": "^6.22.0",
"babel-plugin-transform-builtin-extend": "^1.1.2",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-flow-strip-types": "^6.22.0",
"babel-plugin-transform-object-rest-spread": "^6.22.0",
"babel-polyfill": "^6.23.0",
"babel-preset-es2015": "6.16.0",
"babel-preset-es2015-node": "^6.1.1",
"babel-preset-react": "6.16.0"
},
"devDependencies": {
"ava": "^0.24.0",
"babel-preset-env": "^1.7.0",
"babel-register": "6.16.3"
},
"ava": {
"require": [
"babel-register",
"babel-polyfill",
"ignore-styles"
],
"babel": {
"plugins": [
"babel-plugin-dynamic-import-node"
]
}
}
}
.babelrc
{
"plugins": [
["babel-plugin-transform-builtin-extend", {
"globals": ["Error"]
}],
"recharts",
"transform-object-rest-spread",
"flow-react-proptypes",
"transform-flow-strip-types",
"transform-async-to-generator",
"transform-class-properties",
"syntax-dynamic-import",
"react-hot-loader/babel",
[
"module-resolver",
{
"root": ["./src"],
"alias": {
"tests": "./tests"
}
}
]
],
"presets": ["env", "react"]
}
0.24 is quite old. The latest version for Babel 6 is 0.25, but if possible you should upgrade to Babel 7 and use the latest AVA 1.0 beta.

Cannot read property 'format' of undefined - Build on Mac - Open the prog - Ionic 2 with Electron

If I want to build my app, which is Ionic 2 and Electron used to get native node modules. I get this error, if I want to build the program and open it.
Log-files while building:
electron-builder 19.22.1
Rebuilding native production dependencies for darwin:x64
Packaging for darwin x64 using electron 1.6.11 to dist/mac
⚠️ Application icon is not set, default Electron icon will be used
⚠️ App is not signed: cannot find valid "Developer ID Application" identity or custom non-Apple code signing certificate, see https://github.com/electron-userland/electron-builder/wiki/Code-Signing
All identities:
1) 6C3F7754F6D009926038537F387FAB2791787B78 "com.apple.idms.appleid.prd.4d4f32455a31724551527a61443857327430692b61773d3d"
2) AC427E392FE8EB003E7D5A19C841FC82BEC52A25 "iPhone Developer: philipp.fock#icloud.com (Y5UY9Y69QB)"
2 identities found
Valid identities only
1) 6C3F7754F6D009926038537F387FAB2791787B78 "com.apple.idms.appleid.prd.4d4f32455a31724551527a61443857327430692b61773d3d"
2) AC427E392FE8EB003E7D5A19C841FC82BEC52A25 "iPhone Developer: philipp.fock#icloud.com (Y5UY9Y69QB)"
2 valid identities found
Building macOS zip
Building DMG
⚠️ Application icon is not set, default Electron icon will be used
This is my code in electron.js:
'use strict';
const electron = require('electron');
//const electronprinter = require('electron-printer');
// Module to control application life.
const {
app } = electron;
// Module to create native browser window.
const {
BrowserWindow
} = electron;
const {ipcMain} = require('electron');
const electronPrinter = require('printer');
const fs = require('file-system');
var imagemagick;
try {
imagemagick = require('imagemagick');
} catch(e) {
throw 'please install imagemagick-native: `npm install imagemagick-native`'
}
let win;
function createWindow() {
// Create the browser window.
win = new BrowserWindow({
width: 1024,
height: 600
});
var url = process.env.E_URL || url.format({
pathname: path.join(__dirname, '/../www/index.html'),
protocol: 'file:',
slashes: true
});
// and load the index.html of the app.
win.loadURL(url);
// Open the DevTools.
win.webContents.openDevTools();
// Emitted when the window is closed.
win.on('closed', () => {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
win = null;
});
}
ipcMain.on('get-printers', (event, arg)=> {
console.log("ping");
var printers = electronPrinter.getPrinters();
console.log(printers);
event.sender.send('get-printers-response', printers);
});
ipcMain.on('print-pdf', (event, arg) => {
console.log(arg.pdf);
console.log(arg.printer);
try {
var buf;
if (typeof Buffer.from === "function") {
// Node 5.10+
buf = Buffer.from(arg.pdf, 'base64'); // Ta-da
} else {
// older Node versions
buf = new Buffer(arg.pdf, 'base64'); // Ta-da
}
console.log("hello");
electronPrinter.printDirect({
data: buf,
printer: arg.printer,
type: 'PDF',
success: function (id) {
console.log('printed with id ' + id);
},
error: function (err) {
console.error('error on printing: ' + err);
}
});
} catch(e) {
console.log(e);
console.log(e.message);
}
});
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow);
// Quit when all windows are closed.
app.on('window-all-closed', () => {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', () => {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (win === null) {
createWindow();
}
});
You can see. I use the native node-module printer.
Then my start site is index.html of generated Ionic2 browser code.
Here is my package.json:
{
"name": "benutzerPanel",
"version": "0.0.1",
"author": {
"name": "Philipp Fock"
},
"homepage": "http://ionicframework.com/",
"private": true,
"scripts": {
"dev": "nf start",
"start": "ionic-app-scripts serve",
"electron dist": "electron .",
"ebuild": "yarn run build && node_modules/.bin/build",
"postinstall": "electron-builder install-app-deps",
"clean": "ionic-app-scripts clean",
"build": "ionic-app-scripts build",
"lint": "ionic-app-scripts lint",
"ionic:build": "ionic-app-scripts build",
"ionic:serve": "ionic-app-scripts serve"
},
"dependencies": {
"#angular/common": "4.1.3",
"#angular/compiler": "4.1.3",
"#angular/compiler-cli": "4.1.3",
"#angular/core": "4.1.3",
"#angular/forms": "4.1.3",
"#angular/http": "4.1.3",
"#angular/platform-browser": "4.1.3",
"#angular/platform-browser-dynamic": "4.1.3",
"#ionic-native/core": "3.12.1",
"#ionic-native/printer": "^4.1.0",
"#ionic-native/splash-screen": "3.12.1",
"#ionic-native/status-bar": "3.12.1",
"#ionic/storage": "2.0.1",
"cordova-browser": "^4.1.0",
"cordova-plugin-console": "^1.0.5",
"cordova-plugin-device": "^1.1.4",
"cordova-plugin-splashscreen": "^4.0.3",
"cordova-plugin-statusbar": "^2.2.2",
"cordova-plugin-whitelist": "^1.3.1",
"de.appplant.cordova.plugin.printer": "^0.7.3",
"file-system": "^2.2.2",
"imagemagick": "^0.1.3",
"ionic-angular": "3.5.3",
"ionic-plugin-keyboard": "^2.2.1",
"ionicons": "3.0.0",
"lodash": "^4.17.4",
"ngx-electron": "^1.0.3",
"node-printer": "^1.0.2",
"printer": "^0.2.2",
"rxjs": "5.4.0",
"sw-toolbox": "3.6.0",
"zone.js": "0.8.12"
},
"devDependencies": {
"#ionic/app-scripts": "2.0.2",
"#ionic/cli-plugin-cordova": "1.6.2",
"#ionic/cli-plugin-ionic-angular": "1.4.1",
"#types/electron": "^1.4.34",
"electron": "^1.6.2",
"electron-builder": "^19.22.1",
"foreman": "^2.0.0",
"ionic": "3.7.0",
"typescript": "2.3.4"
},
"description": "DPos",
"main": "electron/electron.js",
"config": {
"ionic_bundler": "webpack",
"ionic_webpack": "./config/webpack.config.js"
},
"build": {
"appId": "com.banana.Pos",
"electronVersion": "1.6.11",
"asar": true,
"files": [
"www/**/*",
"electron/*"
]
},
"cordova": {
"plugins": {
"de.appplant.cordova.plugin.printer": {},
"cordova-plugin-console": {},
"cordova-plugin-device": {},
"cordova-plugin-splashscreen": {},
"cordova-plugin-statusbar": {},
"cordova-plugin-whitelist": {},
"ionic-plugin-keyboard": {}
},
"platforms": [
"browser"
]
}
}
I think your issue here is with this block here
var url = process.env.E_URL || url.format({
pathname: path.join(__dirname, '/../www/index.html'),
protocol: 'file:',
slashes: true
});
I am guessing you are setting the environment variable process.env.E_URL in a js script somewhere to http://localhost:{port}. This is fine when spinning up the development server but not when packaging the app during the electron build. This variable doesn't remain permanently set.
Try adding the following to the top of the electron.js file.
const path = require('path')
const url_lib = require('url')
Then change where you are setting the URL for the electron BrowserWindow to the following.
var url = process.env.E_URL || url_lib.format({
pathname: path.join(__dirname, '/../www/index.html'),
protocol: 'file:',
slashes: true
});
This should fix the issue. The issue was that url was undefined during the electron build.

using protractor-cucumber-framework for testing it gives this error

Hello friends i testing my angular 2 app using protractor and cucumber js but it give me this error i try several solution for this issue but no one can solve my issue.if you know any sol it would be great thank u..
[1] Unhandled rejection TypeError: this.registerHandler is not a function
[1] at Object.registerHandlers (/home/ca1/WebstormProjects/DME/node_modules/protractor-cucumber-framework/lib/resultsCapturer.js:16:8)
[1] at /home/ca1/WebstormProjects/DME/node_modules/protractor-cucumber-framework/lib/resultsCapturer.js:6:22
[1] at Object.defineSupportCode (/home/ca1/WebstormProjects/DME/node_modules/cucumber/src/support_code_library_builder/index.js:20:9)
[1] at Object. (/home/ca1/WebstormProjects/DME/node_modules/protractor-cucumber-framework/lib/resultsCapturer.js:5:12)
[1] at Module._compile (module.js:570:32)
[1] at Object.Module._extensions..js (module.js:579:10)
[1] at Module.load (module.js:487:32)
[1] at tryModuleLoad (module.js:446:12)
[1] at Function.Module._load (module.js:438:3)
[1] at Module.require (module.js:497:17)
[1] at require (internal/module.js:20:19)
[1] at /home/ca1/WebstormProjects/DME/node_modules/cucumber/src/cli/index.js:61:42
[1] at Array.forEach (native)
[1] at Cli.getSupportCodeLibrary (/home/ca1/WebstormProjects/DME/node_modules/cucumber/src/cli/index.js:61:22)
[1] at Cli. (/home/ca1/WebstormProjects/DME/node_modules/cucumber/src/cli/index.js:76:37)
[1] at next (native)
[1] [17:30:50] E/launcher - BUG: launcher exited with 1 tasks remaining
here is my package.json
{
"name": "dpt-angular",
"version": "1.0.0",
"description": "QuickStart package.json from the documentation, supplemented with testing support",
"scripts": {
"start": "concurrently \"npm run tsc:w\" \"npm run lite\" ",
"e2e": "concurrently \"http-server -s\" \"protractor protractor.config.js\" --kill-others --success first",
"lint": "tslint ./app/**/*.ts -t verbose",
"lite": "lite-server",
"pree2e": "webdriver-manager update",
"test": "concurrently \"tsc -w\" \"karma start karma.conf.js\"",
"test-once": "karma start karma.conf.js --single-run",
"tsc": "tsc",
"tsc:w": "tsc -w"
},
"keywords": [],
"author": "",
"license": "MIT",
"dependencies": {
"#angular/common": "~2.4.0",
"#angular/compiler": "~2.4.0",
"#angular/core": "~2.4.0",
"#angular/forms": "~2.4.0",
"#angular/http": "~2.4.0",
"#angular/platform-browser": "~2.4.0",
"#angular/platform-browser-dynamic": "~2.4.0",
"#angular/router": "~3.4.0",
"#types/file-saver": "0.0.1",
"angular-in-memory-web-api": "~0.2.4",
"angular2-moment": "^1.1.0",
"core-js": "^2.4.1",
"mydatepicker": "^2.0.25",
"ng2-completer": "^1.5.2",
"ng2-file-upload": "^1.2.1",
"ng2-pdf-viewer": "^1.1.0",
"rxjs": "5.0.1",
"systemjs": "0.19.40",
"zone.js": "^0.7.4"
},
"devDependencies": {
"#types/jasmine": "^2.5.36",
"#types/node": "^6.0.46",
"canonical-path": "0.0.2",
"concurrently": "^3.1.0",
"cucumber": "^3.0.0",
"cucumber-tsflow": "^2.2.0",
"http-server": "^0.9.0",
"jasmine-core": "~2.4.1",
"karma": "^1.3.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-jasmine-html-reporter": "^0.2.2",
"lite-server": "^2.2.2",
"lodash": "^4.16.4",
"protractor": "^4.0.14",
"protractor-cucumber-framework": "^3.0.0",
"rimraf": "^2.5.4",
"ts-node": "^3.3.0",
"tslint": "^3.15.1",
"typescript": "~2.3.4",
"webdriver-manager": "^12.0.6"
},
"repository": {}
}
and my protractor.conf.json
var fs = require('fs');
var path = require('canonical-path');
var _ = require('lodash');
exports.config = {
directConnect: true,
// Capabilities to be passed to the webdriver instance.
capabilities: {
'browserName': 'chrome'
},
allScriptsTimeout:90000,
getPageTimeout:400000,
ignoreUncaughtExceptions: true,
framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),
// Spec patterns are relative to this config file
specs: ['**/cucumber_test/*.feature' ],
cucumberOpts: {
compiler: "ts:ts-node/register",
require: ['**/*e2e-spec.js'], // require step definition files before executing features
tags: '#TypeScriptScenario,#dev,#AddScenario,#SubtractScenario,#MultiplyScenario,#DivideScenario,#ModulusScenario', // <string[]> (expression) only execute the features or scenarios with tags matching the expression
strict: true, // <boolean> fail if there are any undefined or pending steps
format: ["pretty"], // <string[]> (type[:path]) specify the output format, optionally supply PATH to redirect formatter output (repeatable)
dryRun: false, // <boolean> invoke formatters without executing steps
'fail-fast': true
},
// For angular tests
useAllAngular2AppRoots: true,
// Base URL for application server
baseUrl: 'http://localhost:3000',
// doesn't seem to work.
// resultJsonOutputFile: "foo.json",
onPrepare: function() {
//// SpecReporter
//var SpecReporter = require('jasmine-spec-reporter');
//jasmine.getEnv().addReporter(new SpecReporter({displayStacktrace: 'none'}));
//// jasmine.getEnv().addReporter(new SpecReporter({displayStacktrace: 'all'}));
// debugging
// console.log('browser.params:' + JSON.stringify(browser.params));
/*jasmine.getEnv().addReporter(new Reporter( browser.params )) ;*/
// Allow changing bootstrap mode to NG1 for upgrade tests
global.setProtractorToNg1Mode = function() {
browser.useAllAngular2AppRoots = false;
browser.rootEl = 'body';
};
// browser.manage().window().maximize();
},
/*jasmineNodeOpts: {
// defaultTimeoutInterval: 60000,
defaultTimeoutInterval: 10000,
showTiming: true,
print: function() {}
}*/
}
This issue will be solved just downgrading the cucumber version 3 to 2.

Karma tests works with PhantomJs but not with Chrome

Runing karma tests in Phantom works fine but in Chrome not. All I change in karma.config is browsers: ['PhantomJS'], to browsers: ['Chrome'],.
If I change it I have 0 tests executed and Test failed.
Here is my Chrome response:
Response with Phantom:
Here is my karma.config.js
// Karma configuration
// Generated on Mon Jan 16 2017 13:32:24 GMT+0100 (Środkowoeuropejski czas stand.)
var webpackConfig = require('./webpack.config.js');
var webpack = require('webpack');
var path = require('path');
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['mocha', 'chai', 'sinon', 'fixture'],
files: [
'spec/**/*.spec.ts',
'spec/fixtures/**/*.html',
],
exclude: [],
webpack: {
module: webpackConfig.module,
resolve: webpackConfig.resolve,
plugins: [
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
"window.jQuery": "jquery",
Tether: 'tether',
"window.Tether": 'tether'
})
],
},
preprocessors: {
"spec/**/*.ts": ['webpack'],
'spec/**/*.html': ['html2js'],
'spec/**/*.json': ['json_fixtures']
},
reporters: ['progress'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: false,
// browsers: ['Chrome'],
browsers: ['PhantomJS'],
singleRun: true,
concurrency: Infinity
})
};
And package:
"devDependencies": {
"#types/chai": "^3.4.34",
"#types/jquery": "^2.0.34",
"#types/karma-fixture": "^0.2.2",
"#types/mocha": "^2.2.37",
"#types/raty": "^2.7.26",
"#types/sinon": "^1.16.34",
"chai": "^3.5.0",
"css-loader": "^0.26.1",
"extract-text-webpack-plugin": "^2.0.0-beta.4",
"file-loader": "^0.9.0",
"karma": "^1.4.0",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^2.0.0",
"karma-fixture": "^0.2.6",
"karma-html2js-preprocessor": "^1.1.0",
"karma-json-fixtures-preprocessor": "0.0.6",
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.1",
"karma-phantomjs-launcher": "^1.0.2",
"karma-sinon": "^1.0.5",
"karma-typescript": "^2.1.6",
"karma-typescript-preprocessor2": "^1.2.1",
"karma-webpack": "^2.0.1",
"less": "^2.7.2",
"mocha": "^3.2.0",
"node-sass": "^4.0.0",
"phantomjs-prebuilt": "^2.1.14",
"sass-loader": "^4.0.2",
"sinon": "^1.17.7",
"style-loader": "^0.13.1",
"ts-loader": "^1.2.2",
"typescript": "^2.0.10",
"url-loader": "^0.5.7",
"webpack": "^2.2.0-rc.6"
}
Adding a mime configuration to karma.conf fixed a similar issue for me:
To debug in Chrome define in karma config:
autowatch:true
and define:
singleRun: false
Start your karma test and open in Chrome a page to the karma-server.
The following error was shown in the console:
Refused to execute script from
'http://localhost:9876/base/src/app/search-persons/search-
persons.component.spec.ts?fe78e0d6a85c32fb65115ec3fd4e171b9f39ded7'
because its MIME type ('video/mp2t') is not executable.
The mime config that fixed this for me:
mime: {
'text/x-typescript': ['ts']
},