Exclude files from Cypress.io Coverage Report - code-coverage

Hi Im using cypress coverage report but I have a class which houses all touch device specific functionality and as I'm running the tests on my Mac, they never run. Is there any way to exclude this class?

you might want to check cypress coverage readme:
...
"nyc": {
"include": [...],
"exclude": [...]
}
...

If this doesn't work:
"nyc": {
"exclude": [...]
}
Then add one more property like this:
"nyc": {
"exclude": [...],
"excludeAfterRemap": true
}

On cypress version 10, what worked for me is to create a .nycrc.json file which contains
{
"exclude": [...],
}

Related

Dependency exports an empty object when bundling component library with Rollup

I'm trying to use rollup to build my React component library. The bundle step completes with a few warnings, however, when I actually try to use it in a Next.js application, I get many "X is not a function" errors when visiting the website. It seems to happen because some dependencies inside the _virtual directory are empty:
For example, this is dist/_virtual/d3-time-format.js (my library uses #visx/scale, which depends on d3-scale, which in turn depends on d3-time-format)
var d3TimeFormat = {exports: {}};
export { d3TimeFormat as d };
//# sourceMappingURL=d3-time-format.js.map
As you can see above, the exports is an empty object, so I get the error "format is not a function". This happens also with other modules, like prop-types (my dependencies depend on it).
This is my rollup.config.js:
import { babel } from '#rollup/plugin-babel';
import commonjs from '#rollup/plugin-commonjs';
import resolve from '#rollup/plugin-node-resolve';
import typescript from '#rollup/plugin-typescript';
import svgr from '#svgr/rollup';
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
function bundle(inputPath) {
return {
input: inputPath,
output: [
{
dir: `./dist`,
format: 'esm',
sourcemap: true,
preserveModules: true,
preserveModulesRoot: 'src',
},
],
plugins: [
peerDepsExternal(),
commonjs(),
resolve(),
svgr({
icon: true,
replaceAttrValues: { '#000': '{props.color}' },
svgProps: { fill: 'currentColor' },
}),
typescript(),
babel({
babelHelpers: 'runtime',
exclude: /node_modules/,
extensions: ['.js', '.ts', '.tsx'],
}),
],
};
}
export default [bundle('./src/index.ts')];
When bundling I get these warnings, not sure if they are relevant:
Would appreciate some guidance on what the files inside _virtual are and why they are generated with an empty object. Thanks#

Set date as artifactory directory name in jenkins pipeline

I have a DSL script that creates a pipeline to push to jfrog artifactory. I want to create a target directory in artifactory with current date as directory name.
import java.text.SimpleDateFormat
env.buildDateString="\${new SimpleDateFormat('yyMMdd').format(new Date())}-\${env.BUILD_NUMBER}"
...
...
//artifactory step
{
"pattern": "*abc*.zip",
"target": "myrepo/application/\${env.buildDateString}\\n/artifacts/"
}
The above script is giving the below snippet
{
"pattern": "*abc*.zip",
"target": "myrepo/application/${env.buildDateString}\n/artifacts/"
}
I want the directory to be created using the date. How to refer the buildDateString in "target" section of artifactory so I get output like this
"target": "myrepo/application/220328/artifacts/"
Why the slashes?
backslash () is used to escape special characters in every type, except dollar-slashy string, where we must use dollar ($) to escape.
In your case just do as below,
env.buildDateString="${new SimpleDateFormat('yyMMdd').format(new Date())}-${env.BUILD_NUMBER}"
{
"pattern": "*abc*.zip",
"target": "myrepo/application/${env.buildDateString}/artifacts/"
}
sample

Webpack rebuild is slow using webpack-dev-middleware when building stylus

I'm using webpack 2, with the webpack-dev-middleware
{
test: /\.styl$/,
use: [
'style-loader',
'css-loader',
{
loader: 'stylus-loader',
options: {
use: [nib()],
},
},
]
},
{
test: /\.jpe?g$|\.gif$|\.png$|\.svg$|\.woff$|\.ttf$|\.wav$|\.mp3$/,
use: [ {
loader: 'file-loader',
options: {
publicPath: '/dist/'
}
} ]
}
Relevant server code:
let compiler = webpack(webpackConfig);
app.use(webpackDevMiddleware(compiler, {
publicPath: ('/dist/')
}));
On the initial build (either using webpack from the console, or on first running my server) the whole process takes ~2000ms. Changing .js files doesn't take long at all (<200ms), but changing stylus files takes a very long time (>90s). If I make a change to the stylus then manually trigger a rebuild with webpack it's really quick, but ideally I'd like the watch to do its magic and for my css to be reloaded in place quickly...
Any ideas why the rebuild is taking such a long with stylus, or how I can debug the issue?

Jenkins: identify trigger type

Is there a way I can identify the trigger for the current build during execution. What I want is to identify if the trigger was an SCM change, cron trigger or user trigger. I have multiple triggers defined for a job and want to use trigger type as a parameter in the shell execution script.
You can use the Rest API to get this info; here's an example:
http://jenkins.yourdomain.com/job/job_name/build_number/api/json?tree=actions[causes[shortDescription]]&pretty=true
returns
{
"actions" : [
{
"causes" : [
{
"shortDescription" : "Started by an SCM change"
}
]
},
{
},
{
},
{
},
{
},
{
},
{
}
]
}
One solution is to use the Run Condition Plugin which can run a different shell script depending on the trigger type. It is not the perfect solution, but it will do what you want.
You can also do it with groovy script. Check out my answer to Jenkins Groovy: What triggered the build
you can get the Cause object and then check for which subtype of cause it is
http://javadoc.jenkins-ci.org/hudson/model/Cause.html
At http(s)://(your-jenkins-server)/jenkins/job/(job-name)/(job-number) , under the "Build Artifacts" and "Changes" sections (if you have them), you should see this icon: . The text next to it should state what caused the build.

How to create key binding to set XML syntax?

I'd like to switch to XML syntax in Sublime Text 2 using some key binding, for example Ctrl+Shift+X.
There is a command for that, I can successfully execute it from console:
view.set_syntax_file("Packages/XML/XML.tmLanguage")
I tried this binding, but it doesn't work:
{ "keys": ["ctrl+shift+x"], "command": "set_syntax_file", "args" : {"syntax_file" : "Packages/XML/XML.tmLanguage" }}
Here API reference for the set_syntax_file command can be found.
Any ideas?
Try this:
{ "keys": ["ctrl+shift+x"], "command": "set_file_type", "args" : {"syntax" : "Packages/XML/XML.tmLanguage" } }
set_syntax_file is an API command, so to use it I created a simple plug-in.

Resources