Hapi Lab why Test failed when all the tests are passed - hapi.js

Does anyone know the meaning of ?
npm ERR! Test failed. See above for more details.
3 tests complete
Test duration: 873 ms
The following leaks were detected:lr
npm ERR! Test failed. See above for more details.
I run my 3 tests I get
a successful green 3 tests complete
(all my test are passed)
but why I also see the nasty ?
npm ERR! Test failed. See above for more details.

The test fails because lab detected a global variable leak:
The following leaks were detected:lr
This means you probably defined the lr variable somewhere as global. Try to find where you did that and make the variable local. The other option is to run lab with the -l option which disables global variable leak detection (it is not recommended though).

I resolved this by deleting my node_modules folder and running "npm install" again since my major versions of both node & npm had changed.

Related

What executes on 'npm test' when script doesn't specified?

In my project there is no script for test, there is no also Jest or mocha, but result of npm run test is
> myproject#0.1.0 test /path/to/project
> echo 'Error: no test specified'
Error: no test specified
and return code 0, but for logic it should be code 1.
I know about config flag ignore-scripts with false value, but as I understood its about pre- and post- scripts. Also I read about Jest that is npm 'smart' and can detected, but as wrote previous there is no jest package.
npm -v
6.14.13
node -v
v12.22.3
Does it only for npm v6 and is this fixed in v7 that returns code 1?
Please explain this or give some links because I couldn't find any helpful
Behaviour changed in npm#7, now it occurs an error
https://github.com/npm/cli/blob/latest/CHANGELOG.md#npm-test

npm or yarn test fails with "npm ERR! enoent spawn bash ENOENT"

I am trying to follow a tutorial on how to fork Compound (https://medium.com/compound-finance/a-walkthrough-of-contributing-to-the-compound-protocol-9450cbe2133a). I want to add a new token. But in order to do that, I need to first be able to get the app to pass all tests.
The problem is that I can't get the tests to run in the first place. According to the tutorial, I simply need to type yarn test to run the tests. However, when I try to do this, I get error messages that seem to imply that it cannot find the path to the test file. For example:
'.\script\test' is not recognized as an internal or external command,
operable program or batch file.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command." >
or
npm ERR! code ENOENT
npm ERR! syscall spawn bash
npm ERR! path C:\Users\tombl\Documents\Code\compound-protocol
npm ERR! errno -4058
npm ERR! enoent spawn bash ENOENT
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent>
After investigating some, I discovered that it is trying to run a script in package.json called "test".
The script looks like this: "test": "./script/test",
At first, I got a response saying that "." is not a recognized command. I then tried to put the entire pathname in it so that it wouldn't have a period in it. So I edited package.json to say "test": "C:/Users/tombl/Documents/Code/compound-protocol/script/test",
That didn't work. Next, I tried to edit the environment variables in Windows so that CMD would recognize the folder (I'm using a terminal from within Visual Studio Code). That didn't work either.
After reading some other stack exchange answers, I followed the advice here (npm - The system cannot find the path specified) and typed npm config set script-shell bash. This also didn't work.
In addition, I tried editing package.json so that there is a second set of quotes in the path, like this: "test": "'C:/Users/tombl/Documents/Code/compound-protocol/script/test'", But it still didn't work.
Oh, and I tried using npm test instead of yarn test.
At this point, I have no idea what to try next.
I can see very clearly in file manager that the "test" file is there and that the path I've stated is correct. I can even open up the test file and see the code inside of it. But I can't get the terminal to run it. It just says that it isn't there.
One clue I do have is that it stops at the folder "compound-protocol". So it either doesn't recognize the folder compound-protocol at all or it doesn't recognize that the script folder is inside of it.
I've wondered if maybe the hyphen in "compound-protocol" is causing the problem, but the only advice I've gotten on how to fix that is to put the whole path in quotes, which I've already tried.
I've even tried navigating to the script folder within the terminal and running the test from there. While it does let me navigate into the script folder, trying to run the test produces a > Program 'test' failed to run: No application is associated with the specified file for this operationAt line:1 char:1. > error message.
Does anyone know how I might go about fixing this?
have you tried to use yarn install first? Also you need to use Node.js version 12 with that repository. NVM is a great tool to quickly switch between versions of Node on the command line. https://nvm.sh

Couldn't find a debug log in the cache or working directory

I want to create a VSTS build with npm package auditing capabilities using npm audit. I added a few tasks to run npm audit. The command runs and I can see the details in the console/logs for all the packages. However, the task fails complaining about not finding a logs file. Any idea on how I can get the builds to stop working if I find a high vulnerability package?
EDIT
This is the final line in the result when I run npm audit locally
Notice how it displays vulnerabilities in categories. I want the build to not proceed if there is a non-zero value for High vulnerability.
I got the same error, but then realize that I am using incorrect custom command for npm task:
it was "npm install gulp -g", but should be "install gulp -g" (without npm).
For me it helps.
There isn’t the way to stop/fail build directly if there is a non-zero value for High vulnerability.
The workaround is that you can do it through PowerShell with Build log REST api to analysis whether there is related information in the log, then fail the build (Write-error …) (Run the powershell through PowerShell task)

Mocha command is not found after adding in environment Variables in CodeBuild

In my buildspec.yml file I have a post-build command that runs my mocha tests:
npm run mochatest
That is something I have set in package.json as follows:
"scripts": {
"mochatest": "mocha --timeout 30000 test/functional_api_crud.js"
},
CodeBuild runs and it starts mocha and then I had a test failure because an environment variable I used in my Node.js code was not set. So, I went into the advanced settings of CodeBuild and added in the needed environment variables. Now when the run happens I get an error that mocha cannot be found! The error lines are:
[Container] 2017/12/28 19:24:29 Running command npm run mochatest
newswatcher#0.0.1 mochatest /codebuild/output/src251232826/src
mocha --timeout 30000 test/functional_api_crud.js
sh: 1: mocha: not found
npm ERR! Please include the following file with any support request:
npm ERR! /codebuild/output/src251232826/src/npm-debug.log
This started happening after I added in my own environment variables! Did some other environment variable get upset because I did this?
It turns out that I had set the NODE_ENV environment variable to production and thus, an npm install does not bring in my devDependencies modules!

How to see logs from npm installation?

I am unable to install ionic through npm. Are there any logs that I can check to see what's wrong and if yes, where are they located?
What I see is the waiting stick dancing forever. I've waited for an hour or so but nothing changes.
Append the --loglevel verbose argument to the command you want to run and all logs will be shown on STDERR and saved to npm-debug.log file in the current working directory.
Example usage: npm install ionic --loglevel verbose.
Running the npm commands like this, shows the logs in realtime and saves the logs to the directory its running within.
For permanent solution, just edit the global npm configuration. To do this, run npm config edit command and add loglevel=verbose. Now every npm command will show detailed logs