nightwatch could not find my step definition file - cucumber

I am doing a POC for my project. When i do run a sample test with below project structure am facing a error as mentioned. Any help on this is much appreciated.
I have my project structure as below.
and my conf file content is like below.
require('nightwatch-cucumber')({
cucumberArgs: [
'--require', 'features/step_definitions',
'features',
]
});
module.exports = {
output_folder : 'reports',
custom_assertions_path : '',
page_objects_path : 'page_objects',
live_output : false,
disable_colors: false,
globals_path : '',
selenium : {
start_process : true,
server_path : './bin/selenium-server-standalone-3.9.1.jar',
log_path : '',
host: '127.0.0.1',
port : 4444
},
test_settings : {
default : {
launch_url : "https://<url>",
selenium_host : '127.0.0.1',
selenium_port : 4444,
desiredCapabilities : {
browserName : 'chrome',
javascriptEnabled : true,
acceptSslCerts : true
}
},
chrome : {
desiredCapabilities : {
browserName : 'chrome',
javascriptEnabled : true,
acceptSslCerts : true
},
selenium : {
cli_args : {
'webdriver.chrome.driver' : './bin/chromedriver/chromedriver'
}
}
}
}
};
and the saturnLogin step file has
const { client } = require('nightwatch-cucumber')
const { defineSupportCode } = require('cucumber')
// const { Given, When, Then } = require('cucumber')
defineSupportCode( ({Given, When, Then}) => {
Given(/^I login SATURN application with "(.*?)" and "(.*?)"$/, (user, pass) => {
console.log("Manimaran....")
const loginPage = client.page.saturn_login()
return loginPage
.navigate()
.setValue('#userName', user)
.setValue('#passWord', pass)
})
})
and the package.json file has
{
"name": "nightwatch-poc",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"mytest": "nightwatch -e chrome"
},
"author": "",
"license": "ISC",
"dependencies": {
"cucumber": "^4.1.0",
"nightwatch": "^0.9.20",
"nightwatch-cucumber": "^9.1.2"
}
}
When i run my test, i am getting the error as below.
λ npm run mytest
> nightwatch-poc#1.0.0 mytest C:\<user>\nightwatch-POC
> nightwatch -e chrome
Starting selenium server... started - PID: 3220
There was an error while starting the test runner:
Error: Cannot find module 'features\step_definitions\saturnLogin.js'
at Function.Module._resolveFilename (module.js:536:15)
at Function.Module._load (module.js:466:25)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at C:\<user>\nightwatch-POC\node_modules\cucumber\lib\cli\index.js:163:16
at Array.forEach (<anonymous>)
at Cli.getSupportCodeLibrary (C:\<user>\nightwatch-POC\node_modules\cucumber\lib\cli\index.js:162:24)
at Cli.<anonymous> (C:\<user>\nightwatch-POC\node_modules\cucumber\lib\cli\index.js:181:39)
at Generator.next (<anonymous>)
at Generator.tryCatcher (C:\<user>\nightwatch-POC\node_modules\bluebird\js\release\util.js:16:23)
at PromiseSpawn._promiseFulfilled (C:\<user>\nightwatch-POC\node_modules\bluebird\js\release\generators.js:97:49)
at Promise._settlePromise (C:\<user>\nightwatch-POC\node_modules\bluebird\js\release\promise.js:574:26)
at Promise._settlePromise0 (C:\<user>\nightwatch-POC\node_modules\bluebird\js\release\promise.js:614:10)
at Promise._settlePromises (C:\<user>\nightwatch-POC\node_modules\bluebird\js\release\promise.js:693:18)
at Async._drainQueue (C:\<user>\nightwatch-POC\node_modules\bluebird\js\release\async.js:133:16)
at Async._drainQueues (C:\<user>\nightwatch-POC\node_modules\bluebird\js\release\async.js:143:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! nightwatch-poc#1.0.0 mytest: `nightwatch -e chrome`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the nightwatch-poc#1.0.0 mytest script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\par964\AppData\Roaming\npm-cache\_logs\2018-04-04T18_28_54_978Z-debug.log

Related

Angular build - Index html generation failed. undefined:9:219187: property missing ':'

I have an Angular App that doesn't seem to build with the prod configuration. I get the following error:
Index html generation failed.
undefined:9:219187: property missing ':'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! JI.Infopool.WebApp#0.0.0 build: `ng build --outputHashing=all "--configuration=prod"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the JI.Infopool.WebApp#0.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
The normal build works fine and I don't think that I changed any of the run configurations. I couldn't find anything useful in the log file either. Here's the config in the angular.json file:
"prod": {
"baseHref": "/myApp/",
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
]
},
Just change `angular.json' file like this:
"configurations": {
"production": { // <=
"optimization": { //<= add this
"scripts": true,
"styles": {
"minify": true,
"inlineCritical": false
}
},
"budgets": [...]
there are some reasons may not generate the index file
cause of minificaion on of errored css and script files or you may access the commonjs file. or external files like google fonts all are require internet at build time.
"optimization": {
"scripts": true,
"styles": {
"minify": true,
"inlineCritical": true
},
"fonts": true
}
please refer this link for more details
https://angular.io/guide/workspace-config#optimization-configuration

Cannot find module 'C:\dist\server.generated.js'

I'm trying to learn how to set up a small web app using node.js, Express, and yarn.
I've already used yarn install on the project working directory.
Upon running yarn development I get the following error:
Error: Cannot find module 'C:\dist\server.generated.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:976:15)
at Function.Module._load (internal/modules/cjs/loader.js:859:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
[nodemon] app crashed - waiting for file changes before starting...
I don't understand why it's looking for server.generated.js in C:\dist, as this is something which it autogenerated within the cwd of my project (C:\Users\name\Desktop\Coding\MERNing\MERN-Skeleton-Application\dist) upon running yarn development.
All of my Webpack files specify using the cwd for producing server.generated.js.
const path = require('path')
const nodeExternals = require('webpack-node-externals')
const CURRENT_WORKING_DIR = process.cwd()
console.log(CURRENT_WORKING_DIR+'!')
const config = {
name: "server",
entry: [ path.join(CURRENT_WORKING_DIR , './server/server.js') ],
target: "node",
output: {
path: path.join(CURRENT_WORKING_DIR , '/dist/'),
filename: "server.generated.js",
publicPath: '/dist/',
libraryTarget: "commonjs2"
},
externals: [nodeExternals()],
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: [ 'babel-loader' ]
},
{
test: /\.(ttf|eot|svg|gif|jpg|png)(\?[\s\S]+)?$/,
use: 'file-loader'
}
]
}
}
module.exports = config
The problem was that I had a typo in my nodemon.json file.
My code was
{
"verbose": false,
"watch": [ "./server" ],
"exec": "webpack --mode=development --config webpack.config.server.js && node/dist/server.generated.js"
}
the correct code would be:
{
"verbose": false,
"watch": [ "./server" ],
"exec": "webpack --mode=development --config webpack.config.server.js && node ./dist/server.generated.js"
}
I completely left out the ./ earlier, which explains why it was looking for 'server.generated.js' in C: rather than in the current working directory.

Deploying MS Teams App to Azure App Service

I have created a simple Teams App using Yeoman Generator and have added a single static tab to my Teams project. I'm trying to deploy this to an Azure App Service. This is the error log from App Service Deployment Center
Failed to load ./.env.
[11:41:54] [Webpack error] multi ./src/app/scripts/client.ts
Module not found: Error: Can't resolve 'D:\home\site\repository/src/app/scripts/client.ts' in 'D:\home\site\repository'
resolve 'D:\home\site\repository/src/app/scripts/client.ts' in 'D:\home\site\repository'
Unhandled rejection [31mError[39m in plugin "[36mwebpack[39m"
using description file: D:\home\site\repository\package.json (relative path: .)
Field 'browser' doesn't contain a valid alias configuration
using description file: D:\home\site\repository\package.json (relative path: ./src/app/scripts/client.ts)
no extension
Field 'browser' doesn't contain a valid alias configuration
Message:
Webpack errors, see log
D:\home\site\repository\src\app\scripts\client.ts doesn't exist
.ts
Field 'browser' doesn't contain a valid alias configuration
D:\home\site\repository\src\app\scripts\client.ts.ts doesn't exist
.tsx
Field 'browser' doesn't contain a valid alias configuration
D:\home\site\repository\src\app\scripts\client.ts.tsx doesn't exist
Unhandled rejection [31mError[39m in plugin "[36mwebpack[39m"
Message:
Webpack errors, see log
.js
Field 'browser' doesn't contain a valid alias configuration
D:\home\site\repository\src\app\scripts\client.ts.js doesn't exist
as directory
D:\home\site\repository\src\app\scripts\client.ts doesn't exist
[D:\home\site\repository\src\app\scripts\client.ts]
[D:\home\site\repository\src\app\scripts\client.ts.ts]
[D:\home\site\repository\src\app\scripts\client.ts.tsx]
[D:\home\site\repository\src\app\scripts\client.ts.js]
# multi ./src/app/scripts/client.ts client[0]
[11:41:55] [Webpack error] multi ./src/app/server.ts
Module not found: Error: Can't resolve 'D:\home\site\repository/src/app/server.ts' in 'D:\home\site\repository'
resolve 'D:\home\site\repository/src/app/server.ts' in 'D:\home\site\repository'
using description file: D:\home\site\repository\package.json (relative path: .)
using description file: D:\home\site\repository\package.json (relative path: ./src/app/server.ts)
no extension
D:\home\site\repository\src\app\server.ts doesn't exist
.ts
D:\home\site\repository\src\app\server.ts.ts doesn't exist
.tsx
D:\home\site\repository\src\app\server.ts.tsx doesn't exist
.js
D:\home\site\repository\src\app\server.ts.js doesn't exist
as directory
D:\home\site\repository\src\app\server.ts doesn't exist
[D:\home\site\repository\src\app\server.ts]
[D:\home\site\repository\src\app\server.ts.ts]
[D:\home\site\repository\src\app\server.ts.tsx]
[D:\home\site\repository\src\app\server.ts.js]
# multi ./src/app/server.ts server[0]
[tslint-plugin] Starting linter in separate process...
[tslint-plugin] Starting linter in separate process...
[tslint-plugin] Linting complete.
[tslint-plugin] Linting complete.
[11:42:02] The following tasks did not complete: build, webpack, webpack:client, webpack:server
[11:42:02] Did you forget to signal async completion?
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! emphub#0.0.1 build: `gulp build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the emphub#0.0.1 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
This is my webpack.config.js file
var webpack = require('webpack');
const Dotenv = require('dotenv-webpack');
var TSLintPlugin = require('tslint-webpack-plugin');
var path = require('path');
var fs = require('fs');
var argv = require('yargs').argv;
var debug = argv.debug !== undefined;
const lint = argv["linting"];
var nodeModules = {};
fs.readdirSync('node_modules')
.filter(function (x) {
return ['.bin'].indexOf(x) === -1;
})
.forEach(function (mod) {
nodeModules[mod] = 'commonjs ' + mod;
});
var config = [{
entry: {
server: [
__dirname + '/src/app/server.ts'
],
},
mode: debug ? 'development' : 'production',
output: {
path: __dirname + '/dist',
filename: '[name].js',
devtoolModuleFilenameTemplate: debug ? '[absolute-resource-path]' : '[]'
},
externals: nodeModules,
devtool: 'source-map',
resolve: {
extensions: [".ts", ".tsx", ".js"],
alias: {}
},
target: 'node',
node: {
__dirname: false,
__filename: false,
},
module: {
rules: [{
test: /\.tsx?$/,
exclude: [/lib/, /dist/],
loader: "ts-loader"
}]
},
plugins: []
},
{
entry: {
client: [
__dirname + '/src/app/scripts/client.ts'
]
},
mode: debug ? 'development' : 'production',
output: {
path: __dirname + '/dist/web/scripts',
filename: '[name].js',
libraryTarget: 'umd',
library: 'emphub',
publicPath: '/scripts/'
},
externals: {},
devtool: 'source-map',
resolve: {
extensions: [".ts", ".tsx", ".js"],
alias: {}
},
target: 'web',
module: {
rules: [{
test: /\.tsx?$/,
exclude: [/lib/, /dist/],
loader: "ts-loader",
options: {
configFile: "tsconfig-client.json"
}
},
{
test: /\.(eot|svg|ttf|woff|woff2)$/,
loader: 'file-loader?name=public/fonts/[name].[ext]'
}
]
},
plugins: [
new Dotenv({
systemvars: true
})
],
performance: {
maxEntrypointSize: 400000,
maxAssetSize: 400000,
assetFilter: function(assetFilename) {
return assetFilename.endsWith('.js');
}
}
}
];
if (lint !== false) {
config[0].plugins.push(new TSLintPlugin({
files: ['./src/app/*.ts']
}));
config[1].plugins.push(new TSLintPlugin({
files: ['./src/app/scripts/**/*.ts', './src/app/scripts/**/*.tsx']
}));
}
module.exports = config;
Could you please let me know what I am doing wrong? I'm pusing the code using git push azure master from my project root directory

Error while using "Protractor jasmine 2 screen shot reporter"

I am trying to take the "Screen shot" of the web page when the "test case fails".
I installed "protractor-jasmine2-screenshot-reporter" using "npm".
I am using below data.
1.Node -- v6.11.4
2.NPM -- 3.10.10
3.Protractor -- 5.1.2
My "Protractor.conf.js" file code below.
var HtmlScreenshotReporter = require('protractor-jasmine2-screenshot-reporter');
var reporter = new HtmlScreenshotReporter({
dest: 'C:/Users/agudla/Desktop/VSCodeWorkSpace/my-app/screenshots',
filename: 'my-report.html'
});
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./e2e/**/*.e2e-spec.ts'
],
multiCapabilities: [{
'browserName': 'chrome',
'seleniumAddress':'http://localhost:4444/wd/hub'
},
{'browserName': 'firefox',
'marionette': 'false',
'seleniumAddress':'http://localhost:4444/wd/hub'
}
],
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
beforeLaunch: function() {
return new Promise(function(resolve){
reporter.beforeLaunch(resolve);
});
},
onPrepare() {
require('ts-node').register({
project: 'e2e/tsconfig.e2e.json'
});
jasmine.getEnv().addReporter(reporter);
},
// Close the report after all tests finish
afterLaunch: function(exitCode) {
return new Promise(function(resolve){
reporter.afterLaunch(resolve.bind(this, exitCode));
});
}
};
I am getting below error message while running the test script.
ECONNREFUSED connect ECONNREFUSED 127.0.0.1:4444
Can any one help me to solve this issue.
It is working now , i run "Selenium server" and i changed the var HtmlScreenshotReporter = require('protractor-jasmine2-screenshot-reporter'); as
var Jasmine2HtmlReporter = require('C:/Users/agudla/AppData/Roaming/npm/node_modules/protractor-jasmine2-html-reporter');
Should have to provide complete "path" for the "protractor jasmine2 html reporter".
To know the "protractor jasmine2 html reporter" path in your system , type below command in command prompt.
npm link protractor-jasmine2-html-reporter
It will print the complete path .

Grunt keeps erroring with "module path does not exist"

I'm trying to run grunt on a new machine and it won't compile.
The error I'm receiving is:
Running "requirejs:compile" (requirejs) task { [Error: Error: ERROR: module path does not exist: /Volumes/Users/dtdtdg/assets/js/src/../../../bower_components/almond/almond.js for module named: ../../../bower_components/almond/almond. Path is relative to: /Volumes/Users/dtdtdg
at /Volumes/Users/dtdtdg/node_modules/grunt-contrib-requirejs/node_modules/requirejs/bin/r.js:26824:35 ] originalError: [Error: ERROR: module path does not exist: /Volumes/Users/dtdtdg/assets/js/src/../../../bower_components/almond/almond.js for module named: ../../../bower_components/almond/almond. Path is relative to: /Volumes/Users/dtdtdg] }
I've run sudo npm install -g bower-installer and sudo npm install -g bower just to ensure I'm not missing any packages on this machine. Still no luck.
My grunt file is as follows:
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', [
'copy',
'sass',
'requirejs'
]);
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
copy: {
main: {
cwd: 'bower_components/foundation/css/',
src: '*',
dest: 'assets/css/vendor/foundation/',
expand: true,
rename: function(dest, src) {
return (dest + src).replace('.css', '.scss');
}
}
},
requirejs: {
compile: {
options: {
baseUrl: 'assets/js/src',
include: ['require-main'],
mainConfigFile: 'assets/js/src/require-main.js',
name: '../../../bower_components/almond/almond',
out: 'assets/js/build/app.js'
}
}
},
sass: {
dist: {
options: {
style: 'compressed'
},
files: {
'assets/css/build/styles.css': 'assets/css/src/manifest.scss'
}
}
},
watch: {
css: {
files: ['assets/css/src/**/*.scss'],
tasks: ['sass'],
options: {
spawn: false
}
}
//scripts:{
//files:['assets/js/src/**/*.js'],
//tasks:['requirejs']
//}
}
});
};
Ok I've now fixed this by running bower install almond but now have the following error:
Running "requirejs:compile" (requirejs) task
Error: ENOENT, no such file or directory '/Volumes/Users/dtdtdg/assets/js/src/routers/router.js'
In module tree:
require-main
{ [Error: Error: ENOENT, no such file or directory '/Volumes/Users/dtdtdg/assets/js/src/routers/router.js'
In module tree:
require-main
at Object.fs.openSync (fs.js:438:18)
]
originalError:
{ [Error: ENOENT, no such file or directory '/Volumes/Users/dtdtdg/assets/js/src/routers/router.js']
errno: 34,
code: 'ENOENT',
path: '/Volumes/Users/dtdtdg/assets/js/src/routers/router.js',
syscall: 'open',
fileName: '/Volumes/Users/dtdtdg/assets/js/src/routers/router.js',
moduleTree: [ 'require-main' ] } }
My fault - I had assets/js/src/routers/router.js renamed.

Resources