BrowserStack cypress Run > error with cypress-cucumber-preprocessor dependency graph + cypress folder - testing

When launching tests with cypress to browserstack
At the moment, debuging it by runnning the command on my dev environment (ubuntu)
npm run browserstack
it calls the script from package.json "browserstack": "./node_modules/.bin/browserstack-cypress run --sync"
My feature log execution shows the following error in browerstack build dashboard
Running: features\desktop.feature (NaN of undefined)
Oops...we found an error preparing this test file:
cypress\integration\features\desktop.feature
The error was:
Error: Can't walk dependency graph: Cannot find module 'C:UsershelloDocumentsdocumentscypress_testcypress_test_folder
ode_modulescypress-cucumber-preprocessorlib
esolveStepDefinition' from 'cypress_test_folder\cypress\integration\features'
required by cypress_test_folder\cypress\integration\features\desktop.feature
at cypress_test_folder\node_modules\browser-resolve\node_modules\resolve\lib\async.js:46:17
at process (cypress_test_folder\node_modules\browser-resolve\node_modules\resolve\lib\async.js:173:43)
at ondir (cypress_test_folder\node_modules\browser-resolve\node_modules\resolve\lib\async.js:188:17)
at load (cypress_test_folder\node_modules\browser-resolve\node_modules\resolve\lib\async.js:69:43)
at onex (cypress_test_folder\node_modules\browser-resolve\node_modules\resolve\lib\async.js:92:31)
at cypress_test_folder\node_modules\browser-resolve\node_modules\resolve\lib\async.js:22:47
at callback (C:\Windows\cypress_package\6.8.0\node_modules\graceful-fs\polyfills.js:289:20)
at FSReqCallback.oncomplete (fs.js:172:21)
This occurred while Cypress was compiling and bundling your test code. This is usually caused by:
- A missing file or dependency
- A syntax error in the file or one of its dependencies
Fix the error in your code and re-run your tests.
(Results)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 0 │
│ Passing: 0 │
│ Failing: 1 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 0 │
│ Video: false │
│ Duration: 0 seconds │
│ Spec Ran: features\desktop.feature │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
(Uploading Results)
- Nothing to Upload
My browserstack.json is the following
{
"auth": {
"username": "<username>",
"access_key": "<access_key>"
},
"browsers": [
{
"os": "Windows 10",
"browser": "chrome",
"versions": ["latest"]
}
],
"run_settings": {
"cypress_version" : "6",
"cypress_config_file": "./cypress.json",
"project_name": "myproject",
"build_name": "ui-automation",
"specs": ["cypress/integration/features/desktop.feature","cypress/integration/features/desktop/desktop.js"],
"exclude": [],
"parallels": "Here goes the number of parallels you want to run",
"npm_dependencies": {
"cypress-cucumber-preprocessor": "^1.19.2",
"browserstack-cypress-cli": "^1.8.1",
"cypress": "^3.8.3",
"cypress-xpath": "^1.6.2"
},
"package_config_options": {
"cypress_options": {
"testFiles": "**/*.feature",
"ignoreTestFiles": "*.js",
"chromeWebSecurity": false
},
"cypress-cucumber-preprocessor_options": {
"nonGlobalStepDefinitions": true,
"step_definitions": "cypress/integration/features/dekstop/"
}
},
"headless": false
},
"connection_settings": {
"local": false,
"local_identifier": null,
"local_mode": null,
"local_config_file": null
},
"disable_usage_reporting": false
}
Following the start guide and any else tips, I did not find out what's going on, especially seems that on browserstack log, it's trying to locate a module with a windows path whereas all my testing env is on linux ubuntu > I aim next to run all these on gitlab

Related

Cypress cucumber configuration setup

I am trying to run tests with cypress and Cucumber, but, I am limited by a terrible error when running tests. I don't know much about what's going on, but I have tried to follow all the documentations I could find related to the problem.
The errors I am getting
coder#jessie:~/Desktop/jessie/cypressLearn$ yarn run loginTest
yarn run v1.22.19
warning ../../../package.json: No license field
$ cypress run --spec features/login/login.feature
====================================================================================================
(Run Starting)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Cypress: 11.2.0 │
│ Browser: Electron 106 (headless) │
│ Node Version: v16.14.2 (/home/coder/.nvm/versions/node/v16.14.2/bin/node) │
│ Specs: 1 found (login.feature) │
│ Searched: features/login/login.feature │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
────────────────────────────────────────────────────────────────────────────────────────────────────
Running: login.feature (1 of 1)
Oops...we found an error preparing this test file:
> features/login/login.feature
The error was:
Error: Build failed with 7 errors:
node_modules/#badeball/cypress-cucumber-preprocessor/lib/create-tests.js:6:50: ERROR: Could not resolve "#cucumber/tag-expressions"
node_modules/#badeball/cypress-cucumber-preprocessor/lib/create-tests.js:7:39: ERROR: Could not resolve "#cucumber/cucumber-expressions"
node_modules/#badeball/cypress-cucumber-preprocessor/lib/create-tests.js:8:23: ERROR: Could not resolve "uuid"
node_modules/#badeball/cypress-cucumber-preprocessor/lib/registry.js:7:39: ERROR: Could not resolve "#cucumber/cucumber-expressions"
node_modules/#badeball/cypress-cucumber-preprocessor/lib/registry.js:8:50: ERROR: Could not resolve "#cucumber/tag-expressions"
...
at failureErrorWithLog (/home/coder/Desktop/jessie/cypressLearn/node_modules/esbuild/lib/main.js:1574:15)
at /home/coder/Desktop/jessie/cypressLearn/node_modules/esbuild/lib/main.js:1032:28
at runOnEndCallbacks (/home/coder/Desktop/jessie/cypressLearn/node_modules/esbuild/lib/main.js:1446:61)
at buildResponseToResult (/home/coder/Desktop/jessie/cypressLearn/node_modules/esbuild/lib/main.js:1030:7)
at /home/coder/Desktop/jessie/cypressLearn/node_modules/esbuild/lib/main.js:1142:14
at responseCallbacks.<computed> (/home/coder/Desktop/jessie/cypressLearn/node_modules/esbuild/lib/main.js:679:9)
at handleIncomingPacket (/home/coder/Desktop/jessie/cypressLearn/node_modules/esbuild/lib/main.js:734:9)
at Socket.readFromStdout (/home/coder/Desktop/jessie/cypressLearn/node_modules/esbuild/lib/main.js:655:7)
at Socket.emit (node:events:526:28)
at addChunk (node:internal/streams/readable:315:12)
at readableAddChunk (node:internal/streams/readable:289:9)
at Socket.Readable.push (node:internal/streams/readable:228:10)
at Pipe.onStreamRead (node:internal/stream_base_commons:190:23)
This occurred while Cypress was compiling and bundling your test code. This is usually caused by:
- A missing file or dependency
- A syntax error in the file or one of its dependencies
Fix the error in your code and re-run your tests.
(Results)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 0 │
│ Passing: 0 │
│ Failing: 1 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 0 │
│ Video: true │
│ Duration: 0 seconds │
│ Spec Ran: login.feature │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
(Video)
- Started processing: Compressing to 32 CRF
- Finished processing: /home/coder/Desktop/jessie/cypressLearn/cypress/videos/logi (2 seconds)
n.feature.mp4
====================================================================================================
(Run Finished)
Spec Tests Passing Failing Pending Skipped
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ ✖ login.feature 0ms - - 1 - - │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
✖ 1 of 1 failed (100%) 0ms - - 1 - -
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
My package.json
{
"name": "cypresslearn",
"version": "1.0.0",
"description": "Learning cypress and cucumber",
"main": "index.js",
"scripts": {
"cy:open": "cypress open",
"cy:tests": "cypress run",
"loginTest": "cypress run --spec features/login/login.feature"
},
"keywords": [
"cypress",
"cucumber",
"testing"
],
"author": "Jexsie",
"license": "ISC",
"devDependencies": {
"#bahmutov/cypress-esbuild-preprocessor": "^2.1.5",
"cypress": "^11.2.0",
"esbuild": "^0.15.16"
},
"dependencies": {
"#badeball/cypress-cucumber-preprocessor": "^14.0.0",
"#esbuild-plugins/node-modules-polyfill": "^0.1.4"
},
"cypress-cucumber-preprocessor": {
"stepDefinitions": [
"cypress/stepDefinitions/[filePath]/*.js"
]
}
}
My cypress.config.js
const { defineConfig } = require("cypress");
const createBundler = require("#bahmutov/cypress-esbuild-preprocessor");
const {
addCucumberPreprocessorPlugin,
} = require("#badeball/cypress-cucumber-preprocessor");
const nodePolyfills =
require("#esbuild-plugins/node-modules-polyfill").NodeModulesPolyfillPlugin;
const {
createEsbuildPlugin,
} = require("#badeball/cypress-cucumber-preprocessor/esbuild");
module.exports = defineConfig({
e2e: {
async setupNodeEvents(on, config) {
const bundler = createBundler({
plugins: [nodePolyfills(), createEsbuildPlugin(config)],
});
on("file:preprocessor", bundler);
await addCucumberPreprocessorPlugin(on, config);
return config;
},
specPattern: "features/**/*.feature",
supportFile: "cypress/support/e2e.js",
baseUrl: "http://zero.webappsecurity.com",
},
});
I tried to run tests using yarn run loginTest for the login and expected the test to be passing

How to run an npm script without triggering update check

Is there command line option to use npm run-script ... without triggering an update check?
I ask because I am using concurrently to run two scripts. Often, but not always, I get a "npm update check failed" error message and (I believe) this is because both invocations of node are trying to access the .config store concurrently.
Relevant part of package.json
"scripts": {
"build": "webpack",
"start": "concurrently \"npm:start-browser\" \"npm:start-server\"",
"start-browser": "node start-browser.js",
"start-server": "node index.mjs",
},
and I run this with npm start.
I am using node 14.15.1 and npm 6.14.8, on Windows 10.
The full text of the error is
┌────────────────────────────────────────────────────────────┐
│ npm update check failed │
│ Try running with sudo or get access │
│ to the local update config store via │
│ sudo chown -R $USER:$(id -gn $USER) C:\Users\pedro\.config │
└────────────────────────────────────────────────────────────┘
Note: I never see this error when running other npm scripts, only the one with concurrently, that's why I think it's something to do with concurrent access to .config
(edit) Here is a minimal package.json which will show the error (for me, about 25% of the time)
{
"name": "coco",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "concurrently npm:start-1 npm:start-1",
"start-1":"node index.js"
},
"author": "",
"license": "ISC",
"devDependencies": {
"concurrently": "^6.0.2"
}
}
and index.js is
console.log("Hello World");
Note: I still get the error if I run in a Windows Administrator Power Shell

How do I package a node module for BuckleScript / ReasonML?

Background
I'm an absolute beginner in BuckleScript, and while I've downloaded packgages with npm before, I've never written a library.
Goal: installing my new package local package in my project using npm
I am trying to wrap some parts of the service worker api in JavaScript. I have started with a file bs-service-worker/src/ExtendableEvent.re like so
type _extendableEvent('a);
type extendableEvent_like('a) = Dom.event_like(_extendableEvent('a));
type extendableEvent = extendableEvent_like(Dom._baseClass);
[#bs.send] external waitUntil: (extendableEvent, Js.Promise.t('a)) => unit
= "waitUntil";
This compiles and produces ExtendableEvent.bs.js as expected.
Now, though, I'd like to go ahead and test what I have so far by creating a new npm project and importing what I have locally. I created a new sibling directory and did an npm install ../bs-service-worker. That succeeded, and then I did a sanity-check build on my new BuckleScript project. That also succeeded.
The issue: opening my module causes an error
When I add open ExtendableEvent; to Demo.re in the new project, I get the following error:
We've found a bug for you!
/home/el/workbench/bucklescript/bs-service-worker-examples/src/Demo.re 11:6-20
9 │
10 │ /**/
11 │ open ExtendableEvent;
12 │
13 │ /*
The module or file ExtendableEvent can't be found.
- If it's a third-party dependency:
- Did you list it in bsconfig.json?
- Did you run `bsb` instead of `bsb -make-world`
(latter builds third-parties)?
- Did you include the file's directory in bsconfig.json?
What I've tried
I'm guessing I'm misusing BuckleScript here instead of npm because npm is so widely adopted and well documented that I think I'd have found the problem, but I'm definitely not ruling out the possibility that I'm misusing npm, too.
I do have "bs-service-worker" listed as a bs-dependency. I also tried "../bs-service-worker" in case BuckleScript didn't like the virtual directory, but it didn't seem to help.
My npm run build command is indeed npx bsb -make-world.
More code:
bs-service-worker/bs-config.json
{
"name": "bs-service-worker",
"version": "0.1.0",
"sources": {
"dir" : "src",
"subdirs" : true,
"public": "all"
},
"package-specs": {
"module": "commonjs",
"in-source": true
},
"suffix": ".bs.js",
"bs-dependencies": [
],
"warnings": {
"error" : "+101"
},
"namespace": true,
"refmt": 3
}
bs-service-worker-examples/bsconfig.json
{
"name": "bs-service-worker-examples",
"version": "0.1.0",
"sources": {
"dir" : "src",
"subdirs" : true
},
"package-specs": {
"module": "commonjs",
"in-source": true
},
"suffix": ".bs.js",
"bs-dependencies": [
"bs-service-worker",
"bs-fetch",
],
"warnings": {
"error" : "+101"
},
"namespace": true,
"refmt": 3
}
bs-service-worker-examples/package.json
{
"name": "bs-service-worker-examples",
"version": "0.0.1",
"scripts": {
"build": "npx bsb -make-world",
"start": "npx bsb -make-world -w",
"clean": "npx bsb -clean-world"
},
"keywords": [
"BuckleScript"
],
"author": "Eleanor (https://webbureaucrat.bitbucket.io)",
"license": "MIT",
"devDependencies": {
"bs-platform": "^7.3.2"
},
"dependencies": {
"bs-fetch": "^0.6.1",
"bs-service-worker": "file:../bs-service-worker"
}
}
Easy Reproduction of the Issue
The fastest way to reproduce this would be to fork this repository and try to add it as a local npm dependency.
The problem seems to be that you have "namespace": true in your library's bsconfig.json, which will wrap all the modules in a namespace module with a silly generated name based on the name field. In this case it will be BsServiceWorker I think.
You could just remove that setting, or set it to false, but namespacing is a good idea to avoid collisions between modules from different libraries, or your own app, so I would recommend setting it to a custom, sensible name. For example:
"namespace": "ServiceWorker"
You can then open ExtendableEvent in the consumer project with:
open ServiceWorker.ExtendableEvent;
For more details, see the documentation on the namespace field.

Npm audit report says '1 vulnerability required manual review and could not be updated' / .Node js

Firstly, I got this message below when running npm audit:
updated 1 package and audited 381 packages in 1.767s
found 1 moderate severity vulnerability
run `npm audit fix` to fix them, or `npm audit` for details
→ weatherApp npm audit
=== npm audit security report ===
┌────────────────────────────────────────────────────────────────────────────┐
│ Manual Review │
│ Some vulnerabilities require your attention to resolve │
│ │
│ Visit https://go.npm.me/audit-guide for additional guidance │
└────────────────────────────────────────────────────────────────────────────┘
┌───────────────┬────────────────────────────────────────────────────────────┐
│ Moderate │ Denial of Service │
├───────────────┼────────────────────────────────────────────────────────────┤
│ Package │ axios │
├───────────────┼────────────────────────────────────────────────────────────┤
│ Patched in │ >=0.18.1 │
├───────────────┼────────────────────────────────────────────────────────────┤
│ Dependency of │ nominatim-geocoder │
├───────────────┼────────────────────────────────────────────────────────────┤
│ Path │ nominatim-geocoder > axios │
├───────────────┼────────────────────────────────────────────────────────────┤
│ More info │ https://npmjs.com/advisories/880 │
└───────────────┴────────────────────────────────────────────────────────────┘
found 1 moderate severity vulnerability in 381 scanned packages
1 vulnerability requires manual review. See the full report for details.
→ weatherApp █
Typing npm audit fix didn't help neither:
fixed 0 of 1 vulnerability in 381 scanned packages
1 vulnerability required manual review and could not be updated
On https://npmjs.com/advisories/880 they recommended to upgrade axios version to >=0.18.1. However, in my package.json the version is ^0.19.0.
package.json:
...
"dependencies": {
"axios": "^0.19.0",
"body-parser": "^1.19.0",
"ejs": "^3.0.1",
"epxress": "0.0.1-security",
"express": "^4.17.1",
"nodemon": "^2.0.1",
"nominatim-geocoder": "^0.1.4",
"request": "^2.88.0"
}
...
So, I tried to manually upgrade the version of axios in the package-lock.json as it still shows 0.16.1.
package-lock.json:
"nominatim-geocoder": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/nominatim-geocoder/-/nominatim-geocoder-0.1.4.tgz",
"integrity": "sha1-7o8I+CZq0tL5zYfdQhzCdmtRF78=",
"requires": {
"axios": "^0.16.1",
"lru": "^3.1.0",
"promise-queue": "^2.2.3",
"sha1": "^1.1.1"
},
"dependencies": {
"axios": {
"version": "0.16.2",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.16.2.tgz",
"integrity": "sha1-uk+S8XFn37q0CYN4VFS5rBScPG0=",
"requires": {
"follow-redirects": "^1.2.3",
"is-buffer": "^1.1.5"
}
... to version 0.19.0. However, that didn't help... Any suggestions?

failed to start nuxt project through pm2

I am continuously failing to start the nuxt project through pm2.
I created the project today using npx create-nuxt-app arif-app my project structure is initial for testing purpose but still i would like to illustrate -
arif-app (project-dir) -->
.editorconfig
.gitignore
.nuxt <DIR>
assets <DIR>
components <DIR>
ecosystem.config.js
layouts <DIR>
middleware <DIR>
node_modules <DIR>
nuxt.config.js
package-lock.json
package.json
pages <DIR>
plugins <DIR>
README.md
static <DIR>
store <DIR>
pm2 ecosystem config in ecosystem.config.js is -
module.exports = {
apps : [{
name: '.nuxt',
script: 'index.js',
// Options reference: https://pm2.io/doc/en/runtime/reference/ecosystem-file/
args: 'one two',
instances: 1,
autorestart: true,
watch: false,
max_memory_restart: '1G',
env: {
NODE_ENV: 'development'
},
env_production: {
NODE_ENV: 'production'
}
}],
deploy : {
production : {
user : 'momustafa',
host : '127.0.0.1',
ref : 'origin/master',
repo : 'git#github.com:repo.git',
path : 'C:\Users\momustafa\Desktop\Assets\new_test\arif-app',
'post-deploy' : 'npm install && pm2 reload ecosystem.config.js --env production'
}
}
};
and inside the package.json is :
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "pm2 start ./node_modules/nuxt/bin/nuxt -i max --attach",
"generate": "nuxt generate"
},
"dependencies": {
"#nuxtjs/axios": "^5.3.6",
"nuxt": "^2.0.0",
"vue": "^2.6.10",
"vue-awesome": "^3.5.4",
"vue-loader": "^15.7.0"
},
and before the pm2 start, I already have build the project using npm run build,
and now after the build, I passed the following command(s) through pm2 to run nuxt project,
C:\Users\momustafa\Desktop\Assets\new_test\arif-app>pm2 start .nuxt
[PM2] Applying action restartProcessId on app [.nuxt](ids: 0)
[PM2] [.nuxt](0) ✓
[PM2] Process successfully started
┌──────────┬────┬─────────┬──────┬───────┬─────────┬─────────┬────────┬─────┬────────┬───────────┬──────────┐
│ App name │ id │ version │ mode │ pid │ status │ restart │ uptime │ cpu │ mem │ user │ watching │
├──────────┼────┼─────────┼──────┼───────┼─────────┼─────────┼────────┼─────┼────────┼───────────┼──────────┤
│ .nuxt │ 0 │ N/A │ fork │ 11164 │ stopped │ 16 │ 0 │ 0% │ 0 B │ momustafa │ disabled │
└──────────┴────┴─────────┴──────┴───────┴─────────┴─────────┴────────┴─────┴────────┴───────────┴──────────┘
Use `pm2 show <id|name>` to get more details about an app
C:\Users\momustafa\Desktop\Assets\new_test\arif-app>pm2 kill
[PM2] [v] Modules Stopped
[PM2] Applying action deleteProcessId on app [all](ids: 0)
[PM2] [.nuxt](0) ✓
[PM2] [v] All Applications Stopped
[PM2] [v] PM2 Daemon Stopped
C:\Users\momustafa\Desktop\Assets\new_test\arif-app>pm2 start npm --name .nuxt -- start
[PM2] Spawning PM2 daemon with pm2_home=C:\Users\momustafa\.pm2
[PM2] PM2 Successfully daemonized
[PM2] Starting C:\PROGRAM FILES\NODEJS\NPM.CMD in fork_mode (1 instance)
[PM2] Done.
┌──────────┬────┬─────────┬──────┬──────┬─────────┬─────────┬────────┬─────┬────────┬───────────┬──────────┐
│ App name │ id │ version │ mode │ pid │ status │ restart │ uptime │ cpu │ mem │ user │ watching │
├──────────┼────┼─────────┼──────┼──────┼─────────┼─────────┼────────┼─────┼────────┼───────────┼──────────┤
│ .nuxt │ 0 │ N/A │ fork │ 8864 │ stopped │ 1 │ 0 │ 0% │ 0 B │ momustafa │ disabled │
└──────────┴────┴─────────┴──────┴──────┴─────────┴─────────┴────────┴─────┴────────┴───────────┴──────────┘
Use `pm2 show <id|name>` to get more details about an app
and continuously I am getting following pm2 error logs -
C:\Users\momustafa\Desktop\Assets\new_test\arif-app\.nuxt\index.js:1
(function (exports, require, module, __filename, __dirname) { import Vue from 'vue'
^^^
SyntaxError: Unexpected identifier
at new Script (vm.js:80:7)
at createScript (vm.js:274:10)
at Object.runInThisContext (vm.js:326:10)
at Module._compile (internal/modules/cjs/loader.js:664:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Object.<anonymous> (C:\Users\momustafa\AppData\Roaming\npm\node_modules\pm2\lib\ProcessContainerFork.js:27:21)
at Module._compile (internal/modules/cjs/loader.js:701:30)
please help someone.
Note: In nuxt#2.8.1 the module file name is nuxt.js instead of nuxt-start.js