Mocha lmieulet:meteor-coverage code coverage error - failed to save - javascript

I’m trying to generate and save an LCOV code coverage report file from a mocha test suite for my server in my (non-Typescript) Meteor app. To enable this, I’ve added the lmieulet:meteor-coverage meteor package, the meteortesting:mocha meteor package, and the instanbul babel plugin.
I've also written a ./.coverage.json file:
{
"include": [
"**/*.js",
"**/packages/lmieulet_meteor-coverage.js"
],
"remap": {
"format": ["html", "clover", "cobertura", "json", "json-summary", "lcovonly", "teamcity", "text", "text-summary"]
},
"output": "./.coverage"
}
And added config for the babel plugin in package.json:
"babel": {
"env": {
"COVERAGE": {
"plugins": [
"istanbul"
]
}
}
}
And I’ve written an npm script (named “test-cov”) which includes the necessary env variables to run the test with coverage.
cross-env BABEL_ENV=COVERAGE TEST_CLIENT=0 COVERAGE_OUT_LCOVONLY=1 COVERAGE=1 COVERAGE_VERBOSE=1 COVERAGE_APP_FOLDER=$(pwd)/ meteor test --port 3030 --once --driver-package meteortesting:mocha
With all this set up, I'm expecting the code coverage report to successfully generate when I run "npm run test-cov".
However, when I do run it, I keep getting the following error:
Error: Failed to save lcov coverage... at packages/meteortestingLmocha/server.handlecoverage.js:37:18
I’ve tried:
Switching between the absolute path for ‘output’ in coverage.json file and relative path (./.coverage)
Updating the versions of meteortesting:mocha as well as the overall Meteor version of my app
Opening chmod permissions to 777 for ./.coverage folder (to be written into)
One complication may be that we also have a second testing suite (Jest), but I don’t believe that’s being invoked anywhere as a result of running “test-cov”
Does anyone have an idea of why this isn’t working? I’m at a loss about what to do, partly because the error message here is so brief…

Related

Why is Parcel build creating an import that fails when I try to execute the built module?

Preamble
I'm very new to parcel and using bundlers so I could be doing something completely wrong.
I followed the guidance provided at Building a library with Parcel since I am trying to bundle the server-side code which will be executed by node.js
My package.json contains the following(removed uneccessary details):
{
"source":"bin/server.js",
"module":"dist/server.js"
"scripts":{
"build": "parcel build"
}
"type":"module"
}
Main Problem
When I build my application with npm rum build it generates everything just fine, no errors are thrown and it only takes about 2 seconds.
Then when I try to run the application with "node .\bin\server.js" it throws the following error.
import {exit as $a7IyA$exit, on as $a7IyA$on} from "process";
------------------------------^^--------------------------------------------------
SyntaxError: The requested module 'process' does not provide an export named 'on'
For additional context, the application does run as expected before I bundle with parcel and the server.js file does include the following as the first import (where error is thrown).
import {exit as $a7IyA$exit, on as $a7IyA$on} from "process";
Update:
After reviewing the Targets documentation, this does make me more confident that Parcel can be used for backend bundling and I tried updating my package.json to the following:
{
"targets": {
"server": {
"source": "bin/server.js",
"context": "node",
"distDir": "./dist",
"includeNodeModules": true,
"outputFormat": "esmodule"
}
},
"scripts":{
"build": "parcel build"
}
"type":"module"
}
This did get me further, but I'm now getting the following error:
Uncaught ReferenceError ReferenceError: $2az4q$relative is not defined

How to avoid permission issues when using denon

I was running denon, which is like nodemon in node, but I'm getting permission issues even when I've manually specified the relevant flags (specifically --allow-net flag.)
How do I run my app with denon so I don't have to keep restarting?
Without knowing the exact error it's hard to give you the correct answer, but denon is unstable, it has several issues.
One of those errors that you might be affecting you is if you're trying to watch a folder that you may not have ownership you'll get:
error: Uncaught PermissionDenied: Permission denied (os error 13)
for example, if I run denon on /tmp I get that error thrown, even if the folder has all permissions.
Even though nodemon works perfectly on /tmp.
My recommendation is to use nodemon until denon is stable or until there's a better tool for deno.
You can do so by using --exec flag
nodemon --exec deno run --allow-net index.ts
For convenience you can use nodemon.json with the following content:
{
"execMap": {
"js": "deno run --allow-net",
"ts": "deno run --allow-net"
},
"ext": "js,json,ts"
}
And now just use: nodemon index.ts
You can create a denon.json file in your project root.
{
"scripts": {
"start": "deno run --allow-env --allow-net server.ts"
}
}
Then you can run the script this way (assuming denon installed):
denon start
https://deno.land/x/denon
Hope it helps!
adding --allow-net solved it for me.
for some reason creating the denon.json file manually didn't work, so I had to run
deno --init and add --allow-net to the start cmd
"start": {
"cmd": "deno run --allow-net app.ts",
"desc": "run my app.ts file"
}

Chicken-and-egg problem with node-gyp: Pointing to a header file in a dependency

This is my first attempt at building an npm package that includes C++ code. I thought that I had everything set up properly because, while working in the project folder for the package itself, npm i or node-gyp rebuild was working just fine.
But now that I've published the package, and I'm trying to use that package as a dependency in another project, installation is failing during compilation, when trying to include an important C header file:
CXX(target) Release/obj.target/ar_signal_monitor/ar-signal-monitor-node.o
../ar-signal-monitor-node.cpp:1:10: fatal error: 'napi.h' file not found
#include <napi.h>
^~~~~~~~
1 error generated.
The header file is inside one of the package's dependencies, node-addon-api. My binding.gyp file looks like this:
{
"targets": [
{
"target_name": "ar_signal_monitor",
"cflags!": ["-fno-exceptions"],
"cflags_cc!": ["-fno-exceptions"],
"cflags": ["-Wall", "-std=c++11", "-pthread"],
"cflags_cc": ["-Wall", "-pthread"],
"sources": [
"ar-signal-monitor-node.cpp",
"ar-signal-monitor-node.h",
"ar-signal-monitor.cpp",
"ar-signal-monitor.h"
],
"include_dirs": [
"<!(node -e \"require('node-addon-api').include\")",
"node_modules/node-addon-api",
"/usr/include/node",
"/usr/local/include/node"
],
"libraries": [
"-lwiringPi"
],
"defines": ["NAPI_CPP_EXCEPTIONS"],
'conditions': [
["OS==\"mac\"", {
"defines": ["USE_FAKE_WIRING_PI"],
"libraries!": ["-lwiringPi"],
"xcode_settings": {"GCC_ENABLE_CPP_EXCEPTIONS": "YES"}
}],
["OS==\"win\"", {
"defines": ["USE_FAKE_WIRING_PI"],
"libraries!": ["-lwiringPi"]
}],
],
}
]
}
I'm trying to use "include_dirs" to tell the compiler where to find the <napi.h> header file. I think that perhaps the problem I have is that the installation process wants to compile my C++ code first, and only after that's successfully done then load the dependent npm packages where the header file I need for successful compilation lives.
Is there a way around this problem? Is it a different problem than I think it is? I tried first including node-addon-api in the client project, but that didn't help. (And even if it had worked, that wouldn't be any better than a temporary word-around.)
Full code for the project can be found here: https://github.com/kshetline/rpi-acu-rite-temperature
I'd been thinking I'd needed to do something different in my binding.gyp file, but the solution (or, at least, a solution) turned out to be something I could do in my package.json:
"scripts": {
"preinstall": "npm i node-addon-api",

vuejs unit testing, default installation says no test specified

On Windows 7. Installed a fresh vue project using the VueJS UI utility. Set unit testing / Jest enabled. Added babel.
running "npm test" at the command line returns 'Error: no test specified'.
I have the typical "scripts": { "vue-cli-service test:unit" } set up in my package.json file.
jest.config.js has the expected matching pattern:
{ testMatch: [
'**/tests/unit/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)'
] }
So, it's not finding even the example file located in tests/unit/example.spec.js.
Curiously, I CAN get it to find tests I run directly from the node_modules directory, using vue-cli-service:
node_modules\.bin\vue-cli-service test:unit
from there I get a babel transpile problem (it fails to recognize the ES6 import command in the example.spec.js file) .. which is another nightmare, perhaps not for this post.
Tried updating npm (using 6.9.2). Vue cli version is 3.8.2. Tried deleting the node_modules directory.
Any help is most appreciated.
After running npm test, the error looks like this:
> testing_research#0.1.0 test C:\Users\allan.luchenitser\sandbox\testing_research
> echo 'Error: no test specified'
'Error: no test specified'
thanks again,
Your package.json's "scripts" should contain a named script. Example:
"scripts": {
// other scripts...
"test:unit": "vue-cli-service test:unit"
}
In addition, you have to configure jest to parse any .js or .ts test files in your project, adding this configuration to your package.json:
"jest": {
"moduleFileExtensions": [
"js",
"ts",
"json",
"vue"
],
"transform": {
".*\\.(vue)$": "vue-jest"
}
}
Now running npm run test:unit should find and run any tests you have in your project.

firebase deploy of create react app exposes all js code in the source tab?

I have compiled my app via create react app: yarn build //code is minified and obfuscated as expected
I have then deployed the app via both firebase serve and firebase deploy.
my firebase.json:
{
"database": {
"rules": "database.rules.json"
},
"hosting": {
"public": "build",
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
All is deployed "almost as expected", with 2 caveats:
inside Chrome developer tools/ Sources tab, my entire js codebase is listed with no minification and or obfuscation!
my fonts are not being deployed as the media folder doesnt seem to transfer
The structure looks nothing like the build folder which contains the media... (necessary for fonts):
Am I setting something up incorrectly, deploying the wrong folder or possibly not ignoring something I should be? Exposing the entire js stack unminified and or without any obfuscation seems very "un-secure"...
Again, and as always any and all direction is greatly appreciated!
Strongly advise to refer to the create-react-app github discussion here about this matter but as a quick workaround you can add the following to your package.json scripts:
"scripts": {
...
"build": "npm run build-css && react-scripts build && yarn run delete-maps",
"delete-maps": "rm ./build/static/js/*.map && rm ./build/static/css/*.map",
...
}
This will however in the short run remove all of your source code from the Source tab in developer tools...
Prefixing GENERATE_SOURCEMAP=false to your build target works too (which obviously doesn't generate sourcemap). In package.json file.
GENERATE_SOURCEMAP=false react-scripts build

Categories

Resources