How do I instrument `.vue` files using the istanbul/nyc command line - vue.js

Ultimately, I am trying to instrument my Vue 3 app so that I can get code coverage that includes my .js and .vue files using the below command:
nyc instrument --compact=false src instrumented
I see that my .vue files are getting duplicated and included in my instrumented folder thanks to my .nycrc configuration.
{
"extension": [".js", ".vue"]
}
But they are not getting instrumented.
They are simply copies.
What else do I need to do to get these files properly instrumented so that they can be included in my coverage report?

Related

Meson: how to copy subproject file to build directory?

I'm using Meson build system to build a simple executable app.
Problem is: the executable needs to have access to file file.txt which is located in the separate utils repository. The executable app reads this file at runtime and can't work without accessing it.
I have pulled in the utils repository as a Meson subproject, but I am not sure how would I copy the subprojects/utils/file.txt to a builddirdirectory where the executable is built. Currently the app is built without problems, but when I run it, it fails to find file.txt.
How do I copy the subprojects/utils/file.txt to builddir?

React-Native metro bundler remove imports with babel transformer keeps bundle size constant

Following situation:
I have a ModuleUtils.ts file. Inside that file I have some static imports.
import { a } from 'abc';
import { b } from 'bcd';
import { c } from 'cde';
I have different .env files for different environments created by: react-native-dotenv
.env.dev
.env.int
.env.live
This .env files contain a modules configuration like following:
MODULES=[ a, b, c ]
.env.dev e.g. can only contain:
MODULES=[ a ]
I use babel transformer to change the ModuleFiles.ts to modify/remove unused or unwanted module imports from that file.
e.g. if the .env.dev configuration is:
MODULES=[ a ]
then the babel transformers hits the file and remove the imports, so it only consists of:
import { a } from 'abc';
and the other two
import { b } from 'bcd';
import { c } from 'cde';
are getting replace/removed. I can see this happening, when I do a console output of the transformed ModuleUtils.ts file while metro bundler is running.
I then would suppose, that if the build process is finished and e.g. an APK file is created for an Android build, that the generated index.android.bundle file is smaller than index.android.bundle file where all 3 imports and therefore modules are integrated, but the size of both files is identical, but the APK size is a little bit different. That means the APK file with all three imports/modules is some KB larger than the one with only one module. That shows me, that the process somehow works, but I thought, that the index.android.bundle should also have a different size, but that is not the case, so I am asking why not? I thought, that static imports get bundled by metro bundler into the index.android.bundle file and therefore if I remove some imports they should not be integrated in the index.android.bundle.
Why do I still get the identical index.android.bundle size for both cases?
The Metro Bundler consist of 3 processes.
Resolution
Transformation
Serialization
I tried to transform a .ts file (ModuleUtils.ts) with help of the transformation process. The transformation process can change files before they get bundled. Here I tried to remove static imports of my ModuleUtils.ts in hope that the removed imports will not be bundled in the bundle file.
That does not work, because the resolution process is running in parallel of the Transformation process and already decides which modules to integrate in the bundle.
Metro needs to build a directed graph of all the modules that are required from the entry point to start the building process. To find which file is required from another file Metro uses a resolver.
Therefore, the transformation process can change the content of a file, but removing imports won't effect the bundle size at all.
To implement a dynamic module imports I would have to do the following for a typescript react project.
First remove the imports from the file.
Start the build e.g. yarn build:ts, so the typescript files get compiled to javascript files
Start the build process e.g. yarn start
I still need to find out how to do the 1) step, but that should be solvable. For example, I could create multiple ModuleUtils.ts files for every .env file I have and blacklist all of them in metro except the one with the correct imports for the specific .env file.
const exclusionList = require('metro-config/src/defaults/exclusionList');
// exclusionList is a function that takes an array of regexes and combines
// them with the default exclusions to return a single regex.
module.exports = {
resolver: {
blacklistRE: exclusionList([/dist\/.*/])
}
};

Can GCOV create .gcda file in the different directory structure?

I am trying to generate code coverage report using lcov from home directory. Sorce code is compiled with -coverage option to generate coverage information at compilation time(gcno files are created).
Then I have copied the executables and gcno files to home directory.I am trying to check if by ./exe in home directory ,is it possible to generate coverage report.I run the executables in /home and its showing test cases passed but it was discovered that the .gcda files are not created.
I add the following CPP flag:
-fprofile-dir= “/home”
and hence run the executable but still .gcda is not created .
Where I need to specify the path so that it will take .gcno files from home directory and generates the .gcdo files in the current directory??
This can be done using GCOV_PREFIX and GCOV_PREFIX_STRIP
Please, refer to the documentation:
https://gcc.gnu.org/onlinedocs/gcc/Cross-profiling.html
Regards
Thomas
Maybe, you're compiling more than one module, have you checked the dependencies between modules? Please do this:
compile all your code,
then remove the useless .gcno files. (Gcno are generated at compilation time)
Execute your tests (gcda should be created matching gcno files)
Generate your report
Second possibility:
Compile your code
Execute the tests
Remove useless gcno + gcda files
Generate your report
Others:
I guess you can use some options to generate report for a dedicated module, but I'm not very familiar with those options.
Regards

generator-kraken static module out of date?

Just getting started with KrakenJS. After running the generator and looking at the config.json I notice it has the "static" middleware defined as:
"static": {
"module": {
"arguments": [ "path:./.build" ]
}
}
I have two issues/questions:
After running grunt build I see the browserify output in the /.build folder, but when I navigate to /js/app.js it appears to load the file from the /public folder. Shouldn't it be from the /.build folder?
With Express 4+ shouldn't this actually be serve-static?
I can't help but think I'm missing something.
Thanks!
As I guessed, I was missing something.
I dug into the kraken source a bit more and found that the core config defines the "name" property on static as "serve-static", so it is in fact correct when it merges with the config.json in my app.
The other issue I was having with loading from the incorrect folder was because inside the development.json config file the 'kraken-devtools' middleware is configured with the copier compiler, so when the file is requested at runtime it copies it from the /public folder into the /.build folder, overwriting the output from grunt build.

Why does the default MVC 4 project include minified files?

I'm trying to get my head around bundles in MVC 4. From what I've read, you simply point it at a script or bunch of scripts, give it a name, and it'll bundle them up. If you're not in debug it will also minify them.
Sample Code:
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js"));
If it's done dynamically, why does the project have .min.js files for every script? Does the minifying process actually just load .min.js rather than minify it itself?
If you run in debug mode, the .debug.js files are included. If you run in release mode, the .min.js files are included. If the file is not .debug.js or .min.js, it's included in both cases.
In release mode, all the files, are minified and bundled in one file. No matter if they were or not were previously bundled.
I usually have the original, not .min.js or .debug.js files, and let the bundler do all the job of minification.
There is also another important thing you must be aware of: the bundler will reorder the included files according to internal rules. And, if you use wildcards, the files are included alfabetically. This can make fail your scripts if there are dependencies and they are included in the worng order. You can run your site in debug mode to check the order (look at the rendered script tags). If the order is wrong, you can tweak the file names or implement an IBundleOrderer.
This is a very interesting article on bundling.