"before each" hook: codeceptjs error message - protractor

im using codeceptjs using protractor helper, and i tried to wtite simple code
and to run this command"npm run codeceptjs"
and i faced this error "× "before each" hook: codeceptjs.before for "test something" in 285ms"
here is my code on this file "test_test.js"
Feature('My First Test');
Scenario('test something', ({ I }) => {
I.amOnPage('/');
I.see('GitHub');
});
here package.json
{
"name": "codeceptjs-tests",
"version": "0.1.0",
"private": true,
"scripts": {
"codeceptjs": "codeceptjs run --steps",
"codeceptjs:headless": "HEADLESS=true codeceptjs run --steps",
"codeceptjs:ui": "codecept-ui --app",
"codeceptjs:demo": "codeceptjs run --steps -c node_modules/#codeceptjs/examples",
"codeceptjs:demo:headless": "HEADLESS=true codeceptjs run --steps -c
node_modules/#codeceptjs/examples",
"codeceptjs:demo:ui": "codecept-ui --app -c node_modules/#codeceptjs/examples"
},
"devDependencies": {
"#codeceptjs/configure": "^0.8.0",
"#codeceptjs/examples": "^1.2.1",
"#codeceptjs/ui": "^0.4.6",
"codeceptjs": "^3.0.0",
"playwright": "^1.19.2",
"protractor": "^5.3.0"
}
}
here codecept.conf.js file
const { setHeadlessWhen } = require('#codeceptjs/configure');
// turn on headless mode when running with HEADLESS=true environment variable
// export HEADLESS=true && npx codeceptjs run
setHeadlessWhen(process.env.HEADLESS);
exports.config = {
tests: './*_test.js',
output: './output',
helpers: {
Protractor: {
url: 'http://www.github.com',
driver: 'hosted',
browser: 'chrome',
rootElement: 'body',
angular: false
}
},
include: {
I: './steps_file.js'
},
bootstrap: null,
mocha: {},
name: 'Task1',
plugins: {
pauseOnFail: {},
retryFailedStep: {
enabled: true
},
tryTo: {
enabled: true
},
screenshotOnFail: {
enabled: true
}
}
}
how could i fix the issue?

Error seems to be related to the selenium server. You can see details on https://github.com/codeceptjs/CodeceptJS/issues/2634
Please follow the steps on codecept website for project setup
https://codecept.io/angular/#setting-up-codeceptjs-with-protractor

Related

Rollup.js building error with material-ui layout-grid component included

I integrated Material UI into my Svelte project with help of "Svelte Material UI" package.
But it don't contains Material layout-grid component.
I installed it separately using yarn add "#material/layout-grid" command.
But now I'm getting error during build process:
[!] (plugin postcss) Error: Invalid CSS after "...ch $size in map": expected expression (e.g. 1px, bold), was ".keys(variables.$co"
node_modules/#material/layout-grid/mdc-layout-grid.scss
Error: Invalid CSS after "...ch $size in map": expected expression (e.g. 1px, bold), was ".keys(variables.$co"
at options.error (/media/hdd-home/d/WebServers/home/spadmin.org/public_html/todoapp/node_modules/node-sass/lib/index.js:291:26)
So, I gave up resolving it myself.
The project package.json:
{
"name": "svelte-app",
"version": "1.0.0",
"scripts": {
"build": "rollup -c",
"dev": "rollup -c -w",
"start": "sirv ."
},
"devDependencies": {
"#mdi/js": "^5.3.45",
"#rollup/plugin-commonjs": "^12.0.0",
"#rollup/plugin-node-resolve": "^8.0.0",
"#smui/button": "^1.0.0-beta.21",
"#smui/card": "^1.0.0-beta.21",
"#smui/checkbox": "^1.0.0-beta.21",
"#smui/chips": "^1.0.0-beta.21",
"#smui/common": "^1.0.0-beta.21",
"#smui/form-field": "^1.0.0-beta.21",
"#smui/linear-progress": "^1.0.0-beta.21",
"#smui/textfield": "^1.0.0-beta.21",
"#smui/top-app-bar": "^1.0.0-beta.21",
"material": "^0.4.3",
"node-sass": "^4.14.1",
"rollup": "^2.3.4",
"rollup-plugin-copy": "^3.3.0",
"rollup-plugin-livereload": "^1.0.0",
"rollup-plugin-postcss": "^3.1.1",
"rollup-plugin-svelte": "^5.0.3",
"rollup-plugin-terser": "^5.1.2",
"svelte": "^3.0.0",
"svelte-preprocess": "^3.7.4"
},
"dependencies": {
"#material/layout-grid": "^6.0.0",
"sirv-cli": "^0.4.4"
}
}
And here is rollup.config.js
import svelte from 'rollup-plugin-svelte';
import resolve from '#rollup/plugin-node-resolve';
import commonjs from '#rollup/plugin-commonjs';
import copy from 'rollup-plugin-copy';
import livereload from 'rollup-plugin-livereload';
import {terser} from 'rollup-plugin-terser';
import postcss from 'rollup-plugin-postcss';
import autoPreprocess from 'svelte-preprocess';
const production = !process.env.ROLLUP_WATCH;
export default {
input: 'src/main.js',
output: {
sourcemap: true,
format: 'iife',
name: 'app',
file: 'scripts/app.js',
},
plugins: [
copy({
targets: [
{src: 'src/index.html', dest: '.'},
],
}),
svelte({
dev: !production,
emitCss: true,
css: css => {
css.write('css/app.css');
},
preprocess: autoPreprocess()
}),
resolve({
browser: true,
dedupe: ['svelte', '#material'],
}),
commonjs(),
postcss({
extract: 'css/app.css',
minimize: true,
sourceMap: true,
use: [
[
'sass', {
includePaths: [
'./theme',
'./node_modules',
],
},
],
],
}),
!production && serve(),
!production && livereload({watch: ['scripts', 'css', 'src', 'theme']}),
production && terser(),
],
watch: {
clearScreen: false,
},
};
function serve() {
let started = false;
return {
writeBundle() {
if (!started) {
started = true;
require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], {
stdio: ['ignore', 'inherit', 'inherit'],
shell: true,
});
}
},
};
}
It clearly tries to parse the scss file as css. So it probably misses the compile step. I can't find the scss rollup plugin in your package.json.
Check this, it could solve your problem: https://www.npmjs.com/package/rollup-plugin-scss

Using protractor with directconnect=true - how to fix - This version of ChromeDriver only supports Chrome version

package.json
{
"name": "test1",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "npm run webdriver-update && npm run test-protractor",
"test-protractor": "protractor protractor.conf.js",
"webdriver-update": "webdriver-manager update"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"cucumber": "^6.0.5",
"jasmine-spec-reporter": "^4.2.1",
"protractor": "^5.4.2",
"protractor-cucumber-framework": "^6.2.0",
"rimraf": "^3.0.1"
}
}
protractor.conf.js
const protractor = require('protractor');
// console.log('browser = ', browser);
exports.config = {
framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),
getPageTimeout: 60000,
allScriptsTimeout: 500000,
specs: ['features/*.feature'],
baseURL: 'http://www.google.com/',
cucumberOpts: {
require: [
'./features/step_definitions/stepDefinitions.js'
],
tags: false,
profile: false,
'no-source': true
},
onPrepare: function() {
// browser.ignoreSynchronization = true;
// browser.manage().window().maximize();
// browser.manage().timeouts().implicitlyWait(5000);
},
capabilities: {
browserName: "chrome",
chromeOptions: {
args: [
'--headless',
'--disaple-gpu',
'--window-size=1920,1080',
'--no-sandbox',
'--disable-dev-shm-usage'
],
prefs: {
download: {
prompt_for_download: false,
extensions_to_open: ''
},
profile: {
default_content_settings: {
popups: 0
}
},
directory_upgrade: true
},
useAutomationExtension: false
}
},
// connec direct to webdriver, instead of local selenium server!
directConnect: true,
ignoreUncaughtException: true,
onComplete: () => {
// Reporter.createHtmlReport();
}
}
Error
Session not created: This version of ChromeDriver only supports Chrome version 80
I can manually set update-config.json andhave downloaded many different chromedriver versions, but I still get the same error.
Example:
update-config.json
{"standalone":{"last":"node_modules/protractor/node_modules/webdriver-manager/selenium/selenium-server-standalone-3.141.59.jar","all":["node_modules/protractor/node_modules/webdriver-manager/selenium/selenium-server-standalone-3.141.59.jar"]},"gecko":{"last":"node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.26.0.exe","all":["node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.26.0.exe"]},"chrome":{"last":"node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_75.0.3770.8.exe","all":["node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_75.0.3770.8.exe","node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_75.0.3770.8.exe"]}}
Error
E/launcher - session not created: This version of ChromeDriver only supports Chrome version 75
This is version 75, so what is happening exactly?
I am not using angular. I am using directconnect=true, and set everything to be headless. I did have it working at one point but lost the code and stuck in this loop.
ok, so I have followed the advice from this thread:
- protractor 2.5.4 E/launcher - session not created: This version of ChromeDriver only supports Chrome version 79
I am now using chromedriver version: 78.0.3904.105.
node node_modules/protractor/bin/webdriver-manager clean
node node_modules/protractor/bin/webdriver-manager update
node node_modules/protractor/bin/webdriver-manager --versions.chrome=78.0.3904.105
Ensure this version - chromedriver_78.0.3904.105 - is updated in all references in update-config.json file.
update-config.json
{
"standalone":{
"last":"node_modules/protractor/node_modules/webdriver-manager/selenium/selenium-server-standalone-3.141.59.jar",
"all":[
"node_modules/protractor/node_modules/webdriver-manager/selenium/selenium-server-standalone-3.141.59.jar"
]
},
"gecko":{
"last":"node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.26.0.exe",
"all":[
"node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.26.0.exe"
]
},
"chrome":{
"last":"node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_78.0.3904.105.exe",
"all":[
"node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_78.0.3904.105.exe",
"node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_78.0.3904.105.exe"
]
}
}
run protractor with option: --no-webdriver-update
"scripts": {
"test": "npm run test-protractor --no-webdriver-update"
},
Now it works!

Protractor - Cucumber config query

My query is how config.js will be called when we say for example.. "npm run test" this will run tests as per the configuration defined in config.js
example my package.json contains
"scripts" : {
"test" : "Env=ST CukeTags=regression testrunner -s functional"
}
another query I had is, where can I find the details about how these config files, hooks file will be interrelated? how will these be called during the protractor tests running?
You should set the test script in your package.json
That test script will tell the command to run protractor giving the path of config file.
"scripts":{"test": "protractor typeScript/config/config.js"}
Here the test command will run protractor with the config file inside typescript/config folder.
Sample config file for protractor and cucumber
import * as path from "path";
import { browser, Config } from "protractor";
import { Reporter } from "../support/reporter";
const jsonReports = process.cwd() + "/reports/json";
export const config: Config = {
seleniumAddress: "http://127.0.0.1:4444/wd/hub",
SELENIUM_PROMISE_MANAGER: false,
baseUrl: "https://www.google.com",
capabilities: {
browserName: "chrome",
},
framework: "custom",
frameworkPath: require.resolve("protractor-cucumber-framework"),
specs: [
"../../features/*.feature",
],
onPrepare: () => {
browser.ignoreSynchronization = true;
browser.manage().window().maximize();
Reporter.createDirectory(jsonReports);
},
cucumberOpts: {
compiler: "ts:ts-node/register",
format: "json:./reports/json/cucumber_report.json",
require: ["../../typeScript/stepdefinitions/*.js", "../../typeScript/support/*.js"],
strict: true,
tags: "#CucumberScenario or #ProtractorScenario or #TypeScriptScenario or #OutlineScenario",
},
onComplete: () => {
Reporter.createHTMLReport();
},
};

How to interact with Windows Authentication and Users group using React.js .Net

I am curious how one would interact with Windows Authentication using React.js.
We have a little internal portal we are trying to set up, we already have predefined users groups and users that are in them. We are looking for a way to get those Authenticated credentials to the view using React.js. There are a couple of good links on how to get started with Reactjs.net but I don't see any tutorials on passing credentials to Reactjs.
Any suggested reading? Tutorials or maybe you know yourself and can provide direction?
enter link description here
I've found this really cool tutorial!
It says:
Here’s a minimal setup for React and Webpack based on what we did in this article. Now that you understand the steps, you can copy-paste this to your heart’s content.
package.json
Note: agentkeepalive is only needed for fixing a Windows authentication error with Hot Module Replacement.
{
"name": "ReactWebPackMVC5",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "webpack",
"dev": "webpack-dev-server –open –hot"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"#babel/core": "^7.0.0",
"#babel/preset-env": "^7.0.0",
"#babel/preset-react": "^7.0.0",
"agentkeepalive": "^3.5.1",
"babel-loader": "^8.0.2",
"react": "^16.5.0",
"react-dom": "^16.5.0",
"webpack": "^4.18.0",
"webpack-cli": "^3.1.0",
"webpack-dev-server": "^3.1.8"
}
}
webpack.config.js
Again, agentkeepalive is only needed for fixing a Windows authentication error with Hot Module Replacement. The same is true for the agent and onProxyRes properties.
const path = require("path"); const agent = require("agentkeepalive")
module.exports = { mode: "development", entry: "./Scripts/react/app.js", //or app.jsx output: { path: path.resolve(__dirname, "./Scripts/react/dist"), filename: "bundle.js", publicPath: "Scripts/react/dist" }, resolve: { extensions: ["*", ".js", ".jsx"] }, module: { rules: [ { test: /\.(js|jsx)/, exclude: /node_modules/, use: { loader: "babel-loader", options: { “presets”: [“#babel/preset-env”, “#babel/preset-react”] } } } ] }, devServer: { proxy: { "*": { target: "http://localhost:59829", changeOrigin: true, agent: new agent({ maxSockets: 100, keepAlive: true, maxFreeSockets: 10, keepAliveMsecs: 100000, timeout: 6000000, keepAliveTimeout: 90000 // free socket keepalive for 90 seconds }), onProxyRes: (proxyRes) => { var key = "www-authenticate"; proxyRes.headers[key] = proxyRes.headers[key] && proxyRes.headers[key].split(","); }, }, port: 8080, host: "0.0.0.0", hot: true, }, } };

Path is a file error loading tests with Karma and Webpack

I am trying to setup the Karma test runner on a webpack project I am working on. I have a few test files that I tried to include but Karma keeps on giving me Error: Path is a file '/_karma_webpack_/app/w/tests/components'. Why does MemoryFileSystem fail with this message? All help is appreciated.
My karma.conf.js:
//Require webpack config rather than duplicating it
var webpackConfig = require('./webpack.config');
webpackConfig.devtool = 'inline-source-map';
module.exports = function(config) {
config.set({
basePath:'',
browsers: ['Chrome_without_sandbox'], // Note: PhantomJS has too outdated WebKit, pre ES5, to work with Browserify
singleRun: true,
customLaunchers: {
Chrome_without_sandbox: {
base: 'Chrome',
flags: ['--no-sandbox'] // w/ sandbox it fails under Docker
}
},
frameworks: ['mocha'],
files: ['./app/w/tests/**/*-test.js'],
webpack: webpackConfig,
webpackMiddleware: {
noInfo: true
},
preprocessors: {
'./app/w/tests/**/*-test.js' : ['webpack']
}
});
};
I tried loading files with require.context and bundle them, but the result is the same.. so I figured the issue could be with what MemoryFileSystem expects as input.
webpack.config.js
var webpack = require('webpack');
var bower_dir = __dirname + '/bower_components';
var config = {
//devtool: 'cheap-module-eval-source-map',
devtool: 'eval',
entry: {
app: ['webpack/hot/dev-server', './app/w/scripts/app.js']
},
resolve: { alias: {} },
output: {
path: './app/w/dist',
filename: 'app.js',
publicPath: '/dist/'
},
module: {
noParse: [],
loaders: [
{ test: /\.js$/, loader: 'eslint!babel?optional[]=runtime', exclude: /node_modules/},
{ test: /\.json$/, loader: 'json'},
{ test: /\.png$/, loader: "url?limit=10000&mimetype=image/png" },
{ test: /\.woff$/, loader: "url?limit=10000&mimetype=application/font-woff" },
{ test: /\.ttf$/, loader: "url?limit=10000&mimetype=application/octet-stream" },
{ test: /\.eot$/, loader: "file" },
{ test: /\.svg$/, loader: "url?limit=10000&mimetype=image/svg+xml" },
{ test: /\.less/, loader: 'style!css!less'}
]
},
plugins: new webpack.optimize.UglifyJsPlugin({
minimize: true,
sourceMap: false,
})
};
module.exports = config;
Error log:
ERROR [karma]: [Error: Path is a file '/_karma_webpack_/app/w/tests/components']
Error: Path is a file '/_karma_webpack_/app/w/tests/components'
at MemoryFileSystem.mkdirpSync (/Users/magnuslien/Documents/internprosjekter/woop-frontend/node_modules/karma-webpack/node_modules/webpack-dev-middleware/node_modules/memory-fs/lib/MemoryFileSystem.js:116:10)
at MemoryFileSystem.(anonymous function) [as mkdirp] (/Users/magnuslien/Documents/internprosjekter/woop-frontend/node_modules/karma-webpack/node_modules/webpack-dev-middleware/node_modules/memory-fs/lib/MemoryFileSystem.js:193:34)
at Tapable.<anonymous> (/Users/magnuslien/Documents/internprosjekter/woop-frontend/node_modules/webpack/lib/Compiler.js:244:27)
at /Users/magnuslien/Documents/internprosjekter/woop-frontend/node_modules/webpack/node_modules/async/lib/async.js:187:20
at /Users/magnuslien/Documents/internprosjekter/woop-frontend/node_modules/webpack/node_modules/async/lib/async.js:239:13
at _arrayEach (/Users/magnuslien/Documents/internprosjekter/woop-frontend/node_modules/webpack/node_modules/async/lib/async.js:91:13)
at _each (/Users/magnuslien/Documents/internprosjekter/woop-frontend/node_modules/webpack/node_modules/async/lib/async.js:82:13)
at Object.async.forEachOf.async.eachOf (/Users/magnuslien/Documents/internprosjekter/woop-frontend/node_modules/webpack/node_modules/async/lib/async.js:238:9)
at Object.async.forEach.async.each (/Users/magnuslien/Documents/internprosjekter/woop-frontend/node_modules/webpack/node_modules/async/lib/async.js:215:22)
at Tapable.emitFiles (/Users/magnuslien/Documents/internprosjekter/woop-frontend/node_modules/webpack/lib/Compiler.js:234:20)
package.json
"devDependencies": {
"babel-loader": "^5.3.2",
"browserify": "^11.0.1",
"karma": "^0.12.31",
"karma-chrome-launcher": "^0.2.0",
"karma-mocha": "^0.2.0",
"karma-sourcemap-loader": "^0.3.5",
"karma-webpack": "^1.7.0",
"mocha": "^2.2.5",
"proxyquireify": "^3.0.0",
"webpack": "^1.11.0",
"webpack-dev-server": "^1.10.1"
}
I had the same problem.
Somehow the webpack.config.js is not allowed to have the entry app.
Add
webpackConfig.entry = {};
just under the line
webpackConfig.devtool = 'inline-source-map'; in your karma.conf.js
This worked for me