Selenium Builder tests with Jenkins and Github - json

My goal: setup a simple test framework using Selenium Builder as a FF plugin, GitHub and Jenkins. Retain the test files in .json format. I don't wish to go near java or maven for now.
My current setup: - Selenium Builder add-on for FF28 with Github plugin - Jenkins 1.567 with SeleniumBuilder plugin - Jenkins job setup as a freestyle project, building when a push is made to Git repo and 'Invoke selenium Builder script' as a build step with 'Script file' pointing to root of my test folder(.json scripts)
I can run my .json scripts using se-interpreter from command line using java -jar SeInterpreter.jar example_test.json
What I need to know is - how do I configure Jenkins and the se-interpreter-config file so I can run from Jenkins? currently my interpeter config file looks like this:
{
"type": "interpreter-config",
"configurations": [
{
"settings": [
{
"driverOptions": {
"host": localhost,
"port": 4444
},
"browserOptions": {
"browserName": "firefox",
}
}
],
"scripts": [
"mySeleniumBuilderTests/tests/*"
]
}
]
}

This is how I did.
1. Add the Selenium Builder plugin to your Jenkins.
2. Upload your test script (html or json) to git repo.
3. In Build, select Invoke Selenium Builder Script.
4. Put your script file name there.
5. Build with the URL of your git repo.
Done.

Related

PhpStorm file watcher "Error: Cannot find module" with babel plugins in a rollupjs script (no executable available), plugins globally installed

I can't seem to be able to resolve this, hoping someone might be able to help.
I have configured a file watcher to check for changes in a source directory. When a change is found, it runs the following tool: -
Program: C:\xampp\htdocs\currentproject\packages\node_modules\.bin\rollup
Arguments: -c C:\xampp\htdocs\currentproject\packages\source_directory\rollup.config.js
It is finding the rollup script OK but then I run into an issue as the rollup.config.js file calls babel as a plugin: -
import babel from "rollup-plugin-babel"
plugins: [
babel({})
],
babel.config.js: -
module.exports = {
presets: [
'#babel/preset-env',
'#babel/preset-react',
],
plugins: [
"#babel/plugin-proposal-class-properties",
"babel-plugin-styled-components"
],
}
It finds this config file OK but then I get the following error: -
(plugin babel) Error: Cannot find module '#babel/plugin-proposal-class-properties' from 'C:\xampp\htdocs\currentproject'
Now I understand how to configure external tools in PhpStorm but #babel/plugin-proposal-class-properties does not have a .bin/executable, only a .js file. I have also tried installing it globally via yarn and created a Windows environment variable to point to the global yarn directory but to no avail - I still get the same error.
Can anyone help me with this?

Accessing environment variables in package.json

Recently I started working on a pretty old application where API endpoint URL differs on each system.
Right now, my package.json looks like this:
"start": "cross-env API_ENDPOINT=http://localhost:5000/api/v1 react-scripts start"
The problem is, this value is currently static so when I deploy the code into Heroku, it tries to connect my localhost. Instead, I'm looking to do something like this:
"start": "cross-env API_ENDPOINT={thisShouldBeDynamic} api/v1 react-scripts start"
Is there any way to do it?
Ps. react-app-scripts version is ^0.4.0 so I cannot rely on .env and believe me, you wouldn't want to update it.
JSON format doesn't support templating itself, so you need to create a script which will opens config.json, update it and save back to same file.
You can start from https://www.npmjs.com/package/config-template and create your own template filler which retrieve env variables you need and add them to config file, then same a file.
You can alter your installation before it starts up with the postinstall NPM hook. https://devcenter.heroku.com/articles/nodejs-support#customizing-the-build-process
For instance:
"scripts": {
"postinstall": "node ./ops/heroku-build.js"
}
And then in that script, simply read the appropriate env variables. process.env holds all the Heroku environment variables. Use those to edit your package.json.

Ext JS 5.1 Sencha CMD adding external css file

I am creating an Ext JS application using sencha cmd V5.1. I am trying to load external css file, but it is not working.
My external css file location:
resources/css/customStyle.css
In the app.json file I added the path to the external file.
"css": [
{
"path": "bootstrap.css",
"bootstrap": true
}, {
"path": "resources/css/customStyle.css"
}
],
But when I am using the cls class defined in the "customStyle.css" in the application, it is not working.
Please help me how I can use the external css file using Sencha CMD.
When you are including css files in app.json, you have to first run
sencha app refresh
and then
sencha app build development
After that sencha cmd will create bundled css files, which should also include your custom styles.
The bundled css files are usually located in
build/development/YOUR_APP/
If the bundled CSS files are not generated you could try running sencha cmd with --debug flag
sencha --debug app build development

How to atomatically apply migrations that comes from Yii2 extensions

I have installed an extension for Yii2 dektrium/yii2-user using composer using it's "require" section. This extension contains migrations for database. Is it possible to apply migrations from this extension using console syntax not like this:
php yii migrate --migrationPath=#dektrium/yii2-user/migrations
but run all migrations automatically by using a simple command like:
php yii migrate
Is it possible to tell composer where the concrete extension contains it's migrations?
If you want to make this process automated, you can use scripts property of composer. For more information you can see https://getcomposer.org/doc/articles/scripts.md. In your case you can do your goal with something like this on composer.json:
{
// Some codes are here
"scripts": {
"post-update-cmd": [
"php yii migrate --migrationPath=#dektrium/yii2-user/migrations"
],
"post-install-cmd": [
"php yii migrate --migrationPath=#dektrium/yii2-user/migrations"
]
},
// Some codes are here
}
I prefer to save all commands that must be run after install -or update- on a file (for example file named commands) in the root of project, like this:
#!/usr/bin/env bash
./yii migrate/up --migrationPath=#vendor/dektrium/yii2-user/migrations
./yii migrate/up
./yii migrate/up --migrationPath=#app/modules/rules/migrations
./yii migrate/up --migrationPath=#app/modules/formsaz/migrations
./yii migrate/up --migrationPath=#app/modules/todo/migrations
./yii formsaz/rules/init
./yii husky/rules/init
and on composer.json file put its name:
{
// Some codes are here
"scripts": {
"post-update-cmd": [
"sh commands"
],
"post-install-cmd": [
"sh commands"
]
},
// Some codes are here
}
So each time after composer install or composer update, all commands will be run (and it's useful on teamwork).
I found only one good solution - Install yii2 extension https://github.com/dmstr/yii2-migrate-command
Now i can easily use command "php yii migrate" and don't worry that someone from my team doesn't apply required migrations.
Thanks others for help! If u find more appropriate solutions, please share =)
Yii2: Allow Migrate From Multiple Path

Composer doesn't load repository packages from cache

When I install my app from a clean checkout, It always grabs my packages from my local repository as opposed to installing from cache like the remote packages.
My composer file:
{
"name": "app/name",
"description": "Desc",
"homepage": "http://homepage.com",
"repositories": [
{
"type": "composer",
"url": "http://packages.localrepository.com/",
"options": {
"http": {
"proxy": ""
}
}
}
],
"require": {
"php": ">=5.3.3",
"zendframework/zendframework": "2.*",
"guzzlehttp/guzzle": "4.*",
"local/health-check": "1.*",
"local/file-upload": "1.*",
"rediska/rediska": "dev-master"
}
}
This produces:
[exec] - Installing guzzle/guzzle (v3.9.2)
[exec] Loading from cache
[exec]
[exec] - Installing local/health-check (1.2.0)
[exec] Cloning f62651a1e2328a03ab7fd3fa8f84239ce7ee3a7c
This would be to accommodate the current build process that does a clean checkout each time. Any ideas?
The remote packages are hosted on Github or other hosting services that do provide a means to download ZIP or TGZ files of tagged releases. Composer knows the API of these services and tries to download the ZIP when appropriate (and you can try to force it by using --prefer-dist if it chose badly).
Your own hosted code isn't on Github, I assume. So if Composer doesn't know where to get a ZIP, the only other way is to clone the repository, no matter what the command line says (on the other hand, you can try to force cloning by using --prefer-source).
Note that neither of those two options guarantee anything - if Composer cannot download a ZIP it will clone - if it cannot clone, e.g. when the meta data of that package only mentions ZIP downloads, but no repository, it will download a ZIP.
Switching from one method to the other usually requires deleting the vendor folder as well as the composer.lock file, and then running Composer again. This will act as an update operation, so be warned that you will have to deal with this if it destroys your dependencies (i.e. you rely on branch names like "dev-master" instead of tagged versions).