CucumberJs cannot find steps using webdriverio5 - webdriver-io

I have defined wdio.conf.js file (main file) and environment specific dev-chrome.conf.js file.
I can't get get cucumber to recognize my step definitions folder.
This is my structure:
And this is what I have in dev-chrome.config.js file:
const wdioConfig = require('../../../../../wdio.conf.js');
const commands = require('../../../../../src/commands/commands');
wdioConfig.config.cucumberOpts = [{
// other stuff here
require:
[
'./src/step_definitions/**/*.js',
// Or search a (sub)folder for JS files with a wildcard
// works since version 1.1 of the wdio-cucumber-framework
//'./src/**/*.js',
],
// other stuff here
}];
exports.config = wdioConfig.config;
I am getting an error:
"Step "When I add the product to a cart" is not defined. You can ignore this error by setting cucumberOpts.ignoreUndefinedDefinitions as true."
When I have same path for step definitions defined on main wdio.conf.js file then it works.
My main wdio.conf.js file is located in the root folder of the project.
Do you know how could I make it work in the environment specific conf.js file?
I am using #wdio/cucumber-framework": "^5.13.2"

As per the below example config, the cucumberopts should be an object and I think you are trying to set it as an array.
https://github.com/amiya-pattnaik/webdriverIO-with-cucumberBDD/blob/master/test/config/suite.cucumber.conf.js#L156
Maybe you should follow this example which will help to understand config setup.
Cheers!

Related

How to load different .env file in laravel 8

I need to load a different .env file, named .env.staging under certain conditions.
In .env file
APP_NAME="Laravel"
APP_ENV=staging
APP_KEY=
APP_DEBUG=true
APP_URL=
But my .env.staging file is not loaded. How to load different .env
Test my way: Create env folder in root folder with 2 environement files.
Content of env\.env.staging:
APP_NAME="STAGING MODE"
APP_KEY=base64:AjYSIS9myYGnVkdfaXy2Oz6lY/ofyNhuqN9ZtkKaNm0=
APP_DEBUG=true
APP_URL=http://localhost
Content of env\.env.test
APP_NAME="TEST MODE"
APP_KEY=base64:AjYSIS9myYGnVkdfaXy2Oz6lY/ofyNhuqN9ZtkKaNm0=
APP_DEBUG=true
APP_URL=http://localhost
Then set this code to boot file bootstrap\app.php:
<?php
use Dotenv\Dotenv;
$app = new Illuminate\Foundation\Application(
$_ENV['APP_BASE_PATH'] ?? dirname(__DIR__)
);
// Load temporary environement variables
$dotenv = Dotenv::createImmutable(__DIR__, '../.env');
$dotenv->load();
// Get dynamic APP_ENV wrote in .env file
$env = $_ENV['APP_ENV'];
// You can debug by command var_dump to check
// var_dump($env);
switch ($env) {
case 'staging':
// Overwrite existing environement variables
$dotenv = Dotenv::createMutable(__DIR__ .'/../env', '.env.staging');
$dotenv->load();
break;
case 'test':
// Overwrite existing environement variables
$dotenv = Dotenv::createMutable(__DIR__ .'/../env', '.env.test');
$dotenv->load();
break;
default:
break;
}
Create a route with a view has this title:
<title>{{ env('APP_NAME') }}</title>
When you change variable APP_ENV in .env file:
APP_ENV=test
You will get the title “TEST MODE”
If you change to:
APP_ENV=staging
You will get the title “STAGING MODE”
The title changed, mean the environement variables are loaded!
Tested with "laravel/framework": "^8.75" version has built-in package "vlucas/phpdotenv": "^5.4.1".
To use the .env.test file try to restructure your initial bootstrap() method inside of the App/Http/Kernel.php file to look like this:
public function bootstrap()
{
app()->loadEnvironmentFrom('.env.staging');
parent::bootstrap();
}

Swagger-UI and Ktor how to import swagger.json or .yaml file and start Swagger-UI?

I have a problem, I have already generated OpenApi Swagger files (swagger.json and swagger.yaml) Is it possible somehow in Ktor (kotlin) import this files and start swagger-ui server on specific route ?
I have visited ktor-swagger project but could get how just to add json file to display swagger-ui.
Any suggestions ?
Make you json file accessible from static routing
Create "files" directory in resources dir
Use next code to routing static files from "files" dir
routing {
static("/static") {
resources("files")
}
//...
}
Lets name json file "test.json", then put you it in "files" folder
so now you run the app and see this file by http://localhost:8080/static/test.json
Then we need to install and configure OpenApiGen
Add OpenApiGen dependencies you can find how to do this here https://github.com/papsign/Ktor-OpenAPI-Generator
Then use the following code
install(OpenAPIGen) {
serveSwaggerUi = true
swaggerUiPath = "/swagger-ui"
}
now you can use http://localhost:8080/swagger-ui/index.html?url=/static/test.json URL to see your file through the swagger UI
Also, you can provide your own route to using redirection
get("/api") {
call.respondRedirect("/swagger-ui/index.html?url=/static/test.json", true)
}
this will allow you to use just http://localhost:8080/api

Is there a way to build a master css file based on required css in javascript components using browserify?

Let's say I have modules similar to this one:
"use strict";
var moduleCss = require("module1.css");
var template = require("module1.hmtl");
module.exports = function(){
//my module code here
};
And another one with a different css file.
"use strict";
var moduleCss = require("module2.css");
var template = require("module2.hmtl");
module.exports = function(){
//my module code here
};
The main file would look like this:
"use strict";
var module1 = require("module1");
var module2 = require("module2");
var normalize = require("normalize.css");
var bootstrap = require("bootstrap.css");
module.exports = function(){
//my module code here
};
Instead of appending each css file content as a style tag, i'd like to get a main.css when building the main bundle by looking at each required css file in each module and building a single CSS file containing all the styles in all required modules so that I can append this single css file where I want.
I'm basically trying to have the css requirements in the same spot as the js and html requirements. The solutions that I found so far require a different CSS file that keeps track of each module css dependency, so adding or removing a module in my applications requires work in 2 files, the main js and the main css.
Is there a way to achieve this? To have ALL dependencies into one file? Or could a "package.json" thingy be used for each module where the CSS dependencies could be declared?
After playing around a little bit with browserify it turned out the transform function hook reveals the file name of each required file. I basically looked for css and less file, return a empty module for them, and kept each file in a reference array.
After the bundle was done, by listening to the bundle event, I created a string where I basically "included" each file that I captured in the reference array.
With the import file created, I simply passed it to the less compiler.
Here's a link to the gist for my current task : https://gist.github.com/vladnicula/fd1ff7b30ef20789e1dc

sails.js less livereload with grunt watch not working

I got my less files compiled in css perfectly by grunt and I see result in .tmp/public/styles
So now livereload with grunt-contrib-watch should be made naturally in sails generated project ?
Or do I have to make a special configuration ?
I found that in tasks/pipeline.js file but not sure of what to do.
// CSS files to inject in order
//
// (if you're using LESS with the built-in default config, you'll want
// to change `assets/styles/importer.less` instead.)
var cssFilesToInject = [
'styles/**/*.css'
];
I saw in the file tasks/README.md :
###### `sails lift`
Runs the `default` task (`tasks/register/default.js`).
And in the file default.js we got :
module.exports = function (grunt) {
grunt.registerTask('default', ['compileAssets', 'linkAssets', 'watch']);
};
But watch.js file is missing in the folder...
What should it be ?
Watch does only looking for files that have changed and execute less, sass, injection and so on - but it doesn't make a reload.
You can add this in task/config/watch.js

Using gon with jasmine-rails

Our backbone app uses gon. When we try to run our tests, we are getting a gon is undefined error in the console of the browser. Our layout file includes a call to include_gon, but that file is not being loaded by jasmine, so jasmine is failing in our first javascript file that contains gon. We tried creating a helper to assign the gon variable to an empty hash (like a fixture), but the helper was called after the first call to gon and therefore didn't fix our issue.
The secret was to use the asset pipeline to define the load order of my files. I commented out these lines from jasmine.yml
# path to parent directory of src_files
# relative path from Rails.root
# defaults to app/assets/javascripts
#src_dir: "app/assets/javascripts"
# list of file expressions to include as source files
# relative path from src_dir
#src_files:
# - "application.{js.coffee,js,coffee}"
And created spec.js.coffee with these lines:
#= require application
#= require jasmine-jquery
Now my js files get loaded in order and I am good to go.
What worked for me was to define window.gon = {} inside the test like so:
describe("A suite is just a function", function() {
beforeEach(function() {
window.gon = {}
gon.test = "this"
})
it ("should find gon", function() {
expect(gon.test).toBe("this")
})
})