How to exclude a directory from coverage report in vitest?
I'm looking for something like coveragePathIgnorePatterns option as it was in jest:
coveragePathIgnorePatterns: [
'<rootDir>/src/foo.ts',
'<rootDir>/src/bar.ts',
....
],
How could I do that in vitest.config.ts?
inside coverage you need to add exclude ignore pattern.
then it will work. like this:
in vite.config.ts
{
...
test: {
...,
coverage: {
provider: 'istanbul',
exclude: ['src/config/**']
}
}
}
Don't add it outside the coverage.didn't work for me.
Related
GN stands for Generate Ninja. It generates ninja files which build things. The main file is BUILD.GN at the root of the fuchsia source tree
It contains a lot of build_api_module calls:
build_api_module("images") {
testonly = true
data_keys = [ "images" ]
deps = [
# XXX(46415): as the build is specialized by board (bootfs_only)
# for bringup, it is not possible for this to be complete. As this
# is used in the formation of the build API with infrastructure,
# and infrastructure assumes that the board configuration modulates
# the definition of `zircon-a` between bringup/non-bringup, we can
# not in fact have a complete description. See the associated
# conditional at this group also.
"build/images",
# This has the images referred to by $qemu_kernel_label entries.
"//build/zircon/zbi_tests",
]
}
however, it's unclear for me what this does exactly. Looking at its definition on build/config/build_api_module.gn for example:
template("build_api_module") {
if (current_toolchain == default_toolchain) {
generated_file(target_name) {
outputs = [ "$root_build_dir/$target_name.json" ]
forward_variables_from(invoker,
[
"contents",
"data_keys",
"deps",
"metadata",
"testonly",
"visibility",
"walk_keys",
"rebase",
])
output_conversion = "json"
metadata = {
build_api_modules = [ target_name ]
if (defined(invoker.metadata)) {
forward_variables_from(invoker.metadata, "*", [ "build_api_modules" ])
}
}
}
} else {
not_needed([ "target_name" ])
not_needed(invoker, "*")
}
}
it looks like it simply generates a file.
Can someone explain to me how build_api_module("images") ends up building all the zircon kernel images?
The build_api_module() targets generate JSON files that describe something about the current build system configuration. These files are typically consumed by other tools (in some cases dependencies to other build rules) that need to know about the current build.
One example is the tests target which generates the tests.json file. This file is used by fx test to determine which tests are available and match the test name you provide to the component URL to invoke.
Can someone explain to me how build_api_module("images") ends up building all the zircon kernel images?
It doesn't. These targets are descriptive of the current build configuration, they are not prescriptive of what artifacts the build generates. In this specific case, the images.json file is typically used by tools like FEMU and ffx to determine what system images to use on a target device.
Im trying to set up a convention to ignore any test that follows a pattern. The filename would look like this if you wanted jest to ignore it during npm test.
DISABLED.MyComponent.test.js
trying to use testPathIgnorePatterns
testPathIgnorePatterns: ['<rootDir>/src/**/DISABLED.{*}.js'],
The error is either it is still being run, or it throws a error that the regex is invalid.
Jest uses glob patterns to match the test files, so prefixing the default entries in the testMatch configuration with !(DISABLED.) should do the job.
package.json
{
// ... rest of the package
"jest": {
"testMatch": [
"**/__tests__/**/!(DISABLED.)*.[jt]s?(x)",
"**/!(DISABLED.)?(*.)+(spec|test).[tj]s?(x)"
]
}
}
Side note: You can also "disable" the test file by renaming the main describe block to xdescribe or describe.skip, which would give visibility that there are skipped tests instead of completely ignore the file
Test Suites: 1 skipped, 11 passed, 11 of 12 total
Tests: 2 skipped, 112 passed, 114 total
The other answers here are helpful but miss the core fact:
testPathIgnorePatterns can be used to ignore your filenames. The problem is that testPathIgnorePatterns takes a RegExp, not a glob as you've specified.
The default setting for testPathIgnorePatterns is "/node_modules/", so it's probably useful to include it as well.
As an example, to ignore end to end tests that have an "e2e-" prefix, you could use:
"testPathIgnorePatterns": [
"/node_modules/",
"/e2e-"
]
In your specific case, this would be something like the following (note how the . is escaped in /DISABLED\\.):
"testPathIgnorePatterns": [
"/node_modules/",
"/DISABLED\\."
]
testPathIgnorePatterns is an array of regex patterns that ignores any path that matches the listed expressions and should contain the default "/node_modules/" as well. While it is not intended you may as well use testPathIgnorePatterns to exclude specific files:
So, your best bet would be to move the ignored test to s separate folder, e.g.
"jest": {
"testPathIgnorePatterns": [
"/node_modules/",
"<rootDir>/ignore/this/path/"
]
}
So #Teneff 's answer nearly worked for me. I had to move the ! to the front of the statement to get it to work. Hope this helps someone else too! I am using Next.JS 12.
testMatch: [
'**/*.test.{ts,tsx}',
'!**/__tests__/**/(DISABLED.)*.[jt]s?(x)',
'!**/(DISABLED.)?(*.)+(spec|test).[tj]s?(x)',
]
I'm working on app with grunt and typedoc.
I need to prepare documentation using TypeDoc but I have a problem with one scenario.
I have to exclude a few files from documentation which are externals libs.
I can't put those files into exclude section because those files are relating with another. If I tried to exclude it (by put those files into exclude section) I had a errors - something like cannot find to xxx into yyy.ts - where xxx is my excluded element and yyy is related file with xxx. Those
related files are neccessary on this documentation so I can't exclude those too.
I read into TypeDoc documentation about excludeExternals. So I thought that if I set up this boolean as true then I can to define externalPattern to exclude my external files. It's works but only if I put the name of one file - no more.
Do You know how to do it?
It is my typedoc config into gruntfile.js (without excludeExternals options):
typedoc: {
build: {
options: {
module: 'commonjs',
out: '../Documentation/',
name: 'MyApp',
target: 'es5',
exclude: [
'node_modules',
'**/*.d.ts'
],
excludePrivate: true,
mode: 'file'
},
src: [
...some source...
]
}
}
This is list of external files which I have to exclude: A.ts, B.ts, C.ts, D.ts ...
And this is my typedoc config into gruntfile.js (with excludeExternals options):
typedoc: {
build: {
options: {
module: 'commonjs',
out: '../Documentation/',
name: 'MyApp',
target: 'es5',
exclude: [
'node_modules',
'**/*.d.ts'
],
excludeExternals: true,
externalPattern: '**/*/A.ts',
excludePrivate: true,
mode: 'file'
},
src: [
...some source...
]
}
}
This config is working well. I have got a documentation without A.ts file. So now I need to put a few files, so I tried to put on externalPattern something like: **/*/(A|B|C|D).ts but without success (because during recompiling of documentation I had error: Process terminated with code 3. 'B' is not recognized as an internal or external command, operable program or batch file.).
Any ideas?
I found the solution. If I want to exclude externals files using externalPattern I should to write pattern something like that:
externalPattern: "**/*/{A,B,C,D}.ts"
{ } = allows for a comma-separated list of "or" expressions
, = or
Useful for me was this comment from topic about regex in gruntfile.
According to this comment, the right syntax would be **/*/+(A|B|C|D).ts. Also, it looks like you are running into a problem with your shell trying to interpret the pipe characters, so try adding double quotes around the whole thing:
externalPattern: '"**/*/+(A|B|C|D).ts"'
In a traditional Ember app, I have something along the lines of this in my ember-cli-build.js:
//ember-cli-build.js
module.exports = function(defaults) {
var app = new EmberApp(defaults, {
babel: {
includePolyfill: true,
ignore: ['my-ember-ui/models/myFile.js'] // <-- question is here
},
Is there an equivalent to this when using an Ember Engine (or addon)? I couldn't find anything within ember-cli-babel or ember-engines.
I understand that ember-cli-build.js is just for the dummy app when using an engine, so I wouldn't make the change there. I attempted similar to above in the index.js file, but did not have any luck. The file was not ignored by babel. I need a way to ignore a particular file. Thanks!
Well, adding new rules to Cli.build.js is ok depends on what you want to do. However, I may have another solution that you can give it a try.
Babel will look for a .babelrc in the current directory of the file being transpiled. If one does not exist, it will travel up the directory tree until it finds either a .babelrc, or a package.json with a "babel": {} hash within.(.babelrc files are serializable JSON).
{
"plugins": ["transform-react-jsx"],
"ignore": [
"foo.js",
"bar/**/*.js"
]
}
or
{
"name": "my-package",
"version": "1.0.0",
"babel": {
// my babel config here
}
}
There should be another way which seems ok to use. the following does work:
babel src --out-dir build --ignore "**/*.test.js" // or simply add your file
For more information, you can read Babel document
I build my project with Gradle 1.0 and I use the EMMA plugin for code coverage info. I would like to exclude certain files from the coverage report.
How can I achieve that?
Are you including this Gradle script? I think you can exclude classes within your instrumentation definition (see example below). However, it doesn't look like you can set the exclude pattern by using a convention property.
ant.emma(enabled: 'true', verbosity:'info'){
instr(merge:"true", destdir: emmaInstDir.absolutePath, instrpathref:"run.classpath",
metadatafile: new File(emmaInstDir, '/metadata.emma').absolutePath) {
instrpath {
fileset(dir:sourceSets.main.output.classesDir.absolutePath, includes:"**/*.class", excludes:"**/Some*.class")
}
}
}
If I were you I'd try to fork the plugin, add a new field to EmmaPluginConvention that lets you set the exclude pattern and then use that variable in the instrpath definition. After changing the code and verifying that it works send a pull request to the author. I am sure he will incorporate your change.
This doesn't work with gradle 1.5. Emma takes a filter like so:
ant.emma(enabled: 'true', verbosity: $verbosityLevel) {
instr(merge: "true", destdir: emmaInstDir.absolutePath, instrpathref: "run.classpath",
metadatafile: new File(emmaInstDir, '/metadata.emma').absolutePath, filter: "-com.someclass.*" ) {
instrpath {
fileset(dir: sourceSets.main.output.classesDir.absolutePath, includes: "**/*.class" )
}
}
}
the filter follows the definition from this page:
http://emma.sourceforge.net/reference/ch02s06s02.html