Good afternoon, how are you guys?
Thanking you already
I’m new yet not adonis and following this topic to generate a test report coverage file for this project
project ->https://github.com/Yuri-Tiofilo/adonisTdd 1, and adding the file .nycrc to the project’s root folder and running the adonis test command it doesn’t generate this report.
is there any configuration?
To generate the reports goto to your package.json file where you have
"scripts": {
"start": "node server.js",
"test": "node ace test"
},
replace it with
"scripts": {
"start": "node server.js",
"test": "nyc node ace test"
},
Cool, thank you very much, #Onwubiko Chibuike, make and replace and add nyc modules and it worked, I will leave the steps here, for future interested
1. install module nyc
yarn add nyc or npm i nyc
2º - replace package.json
"scripts": { "start": "node server.js", "test": "nyc node ace test" },
3º - create file in base file project .nycrc
{
"all": true,
"include": ["app/**"],
"reporter": "html",
"report-dir": "test/coverage"
}
4º - run comand
npm test work's for me, Thx.
Related
I have downloaded a zip file of a Barba project, unzipped opened it in VS then npm install yarn and then npm run dev.. I get error missing script dev. What am I missing ?
"name": "barba-starter-template",
"version": "1.0.0",
"description": "A simple starter template for setting up a ECMAScript 6 project with barba.js and webpack.",
"main": "app.js",
"scripts": {
"dev": "webpack-dev-server --mode development",
"build": "webpack --mode production",
"start": "node index.js"
},
I'm implementing a VSCode extension. I set up the project following this link.
It generates a starter project with a src/test/runTest.ts file:
import * as path from 'path';
import { runTests } from '#vscode/test-electron';
async function main() {
try {
// The folder containing the Extension Manifest package.json
// Passed to `--extensionDevelopmentPath`
const extensionDevelopmentPath = path.resolve(__dirname, '../../');
// The path to test runner
// Passed to --extensionTestsPath
const extensionTestsPath = path.resolve(__dirname, './suite/index');
// Download VS Code, unzip it and run the integration test
await runTests({ extensionDevelopmentPath, extensionTestsPath });
} catch (err) {
console.error('Failed to run tests');
process.exit(1);
}
}
main();
And a command in the package.json:
{
"compile": "tsc -p ./",
"pretest": "npm run compile && npm run lint",
"lint": "eslint src --ext ts",
"test": "node ./out/test/runTest.js"
}
Is there a way to generate a coverage report with it?
VSCode extension unittesting uses Mocha under the hood. You can generate coverage reports like in any other Typescript/Javascript project using one of the many available frameworks, e.g. c8, jest, istanbul, etc.
Install the framework of your choice, here I use c8
npm i --save-dev c8
and add to scripts
"scripts": {
"compile": "tsc -p ./",
"pretest": "npm run compile && npm run lint",
"lint": "eslint src --ext ts",
"test": "node ./out/test/runTest.js",
"coverage": "c8 --check-coverage npm run test"
}
Depending on your extension you might need to create a configuration file with the files you want to check for coverage. Here we are checking the compiled .js files placed under the out/ dir and we also excluding the files responsible for unittesting i.e. out/test/ (usually).
.c8rc
{
"all": true,
"include": ["out/**"],
"exclude": ["**/node_modules/**", "out/test/"],
"reporter": ["html", "text"]
}
Run the coverage script and you should get an output of your coverage
npm run coverage
I'm using npm#5.6.0 on Mac High Sierra. I want to run tests that were setup in this Stratum client project. I have run npm install successfully. But when I try and run individual tests, I get the error:
no test specified
What gives? I am in the root project directory and the tests are in my "test" folder. Here is what happens:
localhost:stratum-client-master davea$ npm install
up to date in 0.381s
localhost:stratum-client-master davea$ npm test test/callbacks.js
> stratum-client#1.0.1 test /Users/davea/Documents/workspace/stratum-client-master
> echo "Error: no test specified" && exit 1 "test/callbacks.js"
Error: no test specified
sh: line 0: exit: too many arguments
npm ERR! Test failed. See above for more details.
Try replacing
"scripts": {
"test": "mocha"
},
in your package.json.
You're outputting exactly what the package.json file was told to output. Take a peek under scripts.
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"int-test": "mocha --require babel-core/register --recursive test"
},
Try int-test, the other command in there.
Update: The package link has changed to the following and mocha should be the default test suite. You can run the other script with npm run bump-version; the original script above can be run with npm run int-test.
"scripts": {
"test": "mocha --recursive test",
"bump-version": "npm version patch"
},
You didn't specify which testing framework you're using such as Jest or Mocha.
In case of Jest, add this in your package.json:
"scripts" : {
"test" : "jest"
}
In the case of mocha refer to #Divyeshpal's answer.
The error can be for "exit 1"
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
Change it to this:
"scripts": {
"test": "echo \"No test specified\""
},
This change works because exit 1 creates an error.
if you are using Jest and enzyme for unit testing and you have a jest.config.json config file, you can update your package.json under scripts to the following:
"scripts":{
"test": "jest --config=./jest.config.json --coverage",
}
The error can be for "exit 1"
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
Change it to this:
"scripts": {
"test": "echo \"No test specified\""
},
This change worked for me because exit 1 created the error.
find and make changes in your package.json
"scripts":{
"test":"mocha"
}
add this on your packages.json file:
"scripts":{
"test": "mocha --ui tdd tests/callbacks.js",
}
then npm test on the console.
Replace
echo \"Error: no test specified\" && exit 1
in your
package.json
with
mocha.
I'm a big fan of bower. I don't need to put a stack of packages in my repository, I just commit bower.json each time and I'm done.
So my question really is, can I make npm read from a json file in the same way that bower does?
npm has package.json. This file has dependencies and devDependencies parts. You can use this file similar to bower.json.
npm install
will install necessary dependencies to your project's node_modules directory.
See sample package.json below.
{
"name": "SampleMobileApp",
"version": "0.0.1",
"description": "Sample App",
"dependencies": {
"grunt": "~0.4.2",
},
"devDependencies": {
"grunt": "~0.4.2",
"grunt-contrib-jshint": "~0.8.0",
"grunt-open": "~0.2.3",
"grunt-contrib-copy": "~0.5.0",
"grunt-bowercopy": "~0.7.1",
"grunt-contrib-watch": "~0.5.3",
"grunt-phonegap": "~0.12.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"grunt",
"javascript"
],
"author": "Atilla Ozgur",
"license": "MIT",
}
dependencies are your runtime dependencies that your users need to download while devDependencies are your developer dependencies like your test runtime, grunt helper packages etc.
I have a simple package.json:
{
"name": "camapaign",
"version": "0.0.1",
"scripts": {
"start": "node app.js"
},
"engines": {
"node": "0.10.15",
"npm": "1.3.5"
},
"repository": {
"type": "svn",
"url": ""
}
}
When I execute "npm install" i get the following warning which I would like to fix:
"npm WARN package.json camapaign#0.0.1 No readme data."
I have tried adding "README.md" & "readme.txt" to the same dir as the package but with no joy. What am I missing?
Simply adding a README.md file will not fix it, you should write something inside it; at least the project title and a brief description is good for people! But for NPM, one byte may be enough...
Doing so should stop showing the warnings.
Also, when you read that warning, ensure that the problem is not related to a 3rd party package.
Just set as private ;)
{
"name": "camapaign",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node app.js"
},
"engines": {
"node": "0.10.15",
"npm": "1.3.5"
},
"repository": {
"type": "svn",
"url": ""
}
}
Adding a README.md to your project root is the answer, but I've noticed that it takes a short while for NPM to pick up on this. Maybe a few minutes?
Add to package.json "readme": "README.md"
As of today, Apr 2017, just setting below in package.json, still works fine:
"private": true
this means its your private repository
even, with latest npm, it works fine:
npm update -g npm
> 3.10.8
my solution
npm show
npm dist-tag add
1.use npm show check the remote website deploy info.
eg.should like this:
SOME_PACKAGEs#0.3.60-beta | Proprietary | deps: 14 | versions: 289
<span style="color:red;">最新日志倒序在这里增加,注明作者+日期+功能</span>
dist
.tarball: https://registry.npmjs.org/xxx/-/xxx-0.3.60-beta.tgz
.shasum: 021e30640a62f13905b1e2b7a4facd169df46a1d
.integrity: sha512-9N4pUwwoYGNek34fCCCjURuQdx1K5VBlCWl4t1sy8wi3xul/N/TiDvjmUBF24t2Dg2fX6cFM9on+tftnVaEr7A==
.unpackedSize: 114.5 kB
dependencies:
#hanyk/rc-viewer: ^0.0.3 crypto-js: ^3.1.9-1 moment: ^2.25.3 react-dom: ^16.12.0 uuid: ^3.3.3
axios: ^0.19.0 dirty-json-ie11: ^0.0.2 query-string: ^6.9.0 react-quill: ^1.3.3 yqquill-image-drop-module: ^0.0
cookie-universal: ^2.0.16 md5: ^2.2.1 quill-delta-to-html: ^0.11.0 react-resizable: ^1.10.1
maintainers:
- jyjin <jyjin#qq.com>
- jyjin1 <jyjin1#163.com>
- jyjin2 <jyjin2#163.com>
dist-tags:
beta: 0.3.61-beta latest: 0.3.53-beta
published 26 minutes ago by jyjin1 <jyjin1#163.com>
2.npm dist-tag add [PACKAGE_NAME]#[VERSION]
and then update lasest 0.3.53-beta to 0.3.61-beta
npm dist-tag add SOME_PACKAGE#0.3.61-beta
3.npm show check agin
same to step 1
go back to your npm package site, all have refreshed!
Wish to helps, thanks~
[One Chinese Teach]希望对您有帮助,谢谢~