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
Related
In my npm project, in my package.json file, I have the following lines of code:
"scripts": {
"build": "webpack"
},
While in my terminal, if I run npm webpack, I get the error message:
Unknown command: "webpack"
But if I run npm run build, I get a prompt from webpack saying I need webpack-cli... so the command is obviously recognized.
I'm confused about the different behavior of these two commands. In this case, isn't running npm run build identical to running npm webpack in my terminal? Why does one command fail and one succeed? What is actually happening when I run npm run build?
If we look at the documentation,
Environment
Package scripts run in an environment where many pieces of information are made available regarding the setup of npm and the current state of the process.
path
If you depend on modules that define executable scripts, like test suites, then those executables will be added to the PATH for executing the scripts.
Maybe this is the reason webpack is not recognized by the command line.
I installed the #ui5/uiveri5 globally correctly. I download the ui-uiveri5 repository, then I go to directory of sample\apiTesting, and run the command
uiveri5 APITesting.spec
it report following error:
C:\src\open\ui5-uiveri5\sample\apiTesting\APITesting.spec.js:2
describe('APITesting', function() {
^
ReferenceError: describe is not defined
Please guide me on how to solve this issue. ( It report the same issue after I install the jasmine-node, mocha globally).
No need to install jasmine or mocha, just install uiveri5 globally with npm install #ui5/uiveri5 -g. Can you please try again, I merged a fix for another small issue. And with it, this sample starts fine.
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!
I'm running Windows 7 64bit with Node v6.5.0 and NPM 3.10.3. I ran npm install in the skeleton-typescript-webpack folder and all the packages installed fine. When I run any commands that call webpack though, I get the errors below.
When I run npm run build I get this error:
When I run npm start I get this error:
As you can see, the command that is run before the npm build error happens is concerning webpack, and same with the command that is run before the npm start error happens.
Anyone have an idea on how to fix this?
The skeleton skeleton-typescript-webpack uses TypeScript 2.0 for compilation.
This gives tries to compile adm-zip which is in the selenium-webdriver node module. And this gives an error on a break statement after a return statement.
The file .\nodes_modules\selenium-webdriver\node_modules\adm-zip\zipEntry.js gives the issue. You have to comment out two break; statements in the file on line 96 and line 115. After this you get a correct build.
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.