Skip to content

Commit

Permalink
Upgraded dependencies; Added testdata for regression testing
Browse files Browse the repository at this point in the history
  • Loading branch information
David Gnanasekaran committed Mar 28, 2019
1 parent 16bbf9c commit 9d469e2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
# Vsts coverage styles

This package helps to convert the external css files linked in an HTML into an internal style i.e., by injecting in HTML using `<style>` tag in the document head.
It follows the same order while injecting CSS back in the HTML.
Converts all externally linked CSS files in an HTML document into internal styles, by loading & injecting the RAW CSS styles as text within `<style>` tags into HTML document `<head>` section. It follows the same exact CSS file linking order, while injecting back the CSS styles using `<style>` tags. So, CSS override orders are preserved and appears as expected.

It doesn't do anything else, so it is as simple and fast as it can.
This plugin was initially designed with an idea to workaround the external CSS linking restrictions in VSTS(Azure DevOps) code coverage report tab in Build Summary. But, this package can also be used in similar situations.

install using `npm install vsts-coverage-styles --save `
It focuses primarily on improving the HTML report manipulation speed by caching the repeatedly accessed external CSS files, thus allowing it to complete its inlining process as fast as it can, compared to similar packages.

Following is how you can consume the package from the nodejs file.
You can install it as development dependency,
using `npm install vsts-coverage-styles --save-dev`

The override css allows you to fix the glitches due to VSTS stripping pseudo selectors like :after & :before selectors, images & charsets
After installation, you can simply require & consume the package from your nodejs file. Also, this package allows you to hook your custom logics to pre-processing and post-processing events using `preProcessFn` & `postProcessFn` params.

```
The override CSS parameter allows you provide additional styles to append to your coverage reports and fix display glitches, that are caused due to stripping of pseudo selectors like :after & :before selectors, images & charsets from your CSS file by VSTS security mechanism.

```JavaScript
/**
* Vsts test coverage view doesn't load external CSS due to security reasons.
* So we are converting all external css files to internal <style> tags using vsts-coverage-styles (node module).
Expand Down Expand Up @@ -45,5 +47,5 @@ vstsCoverageStyles({
});
```

To know about the assumptions and the optimization done for this plugin, check out the following article
To know about the assumptions and optimization factors considered for this plugin, kindly read through the following article
[Code coverage HTML reports are missing styles in VSTS](https://davidsekar.com/aspnetcore/code-coverage-html-reports-are-missing-styles-in-vsts)
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"name": "vsts-coverage-styles",
"version": "1.0.7",
"version": "1.0.8",
"description": "This package helps to convert the external css files in an HTML to an internal style i.e., injected using style tag in the document head.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "run.js"
},
"author": "David Gnanasekaran",
"license": "MIT",
"dependencies": {
"app-root-path": "^2.0.1",
"app-root-path": "^2.2.1",
"cheerio": "^1.0.0-rc.2",
"clean-css": "^4.1.9",
"glob": "^7.1.2",
"merge": "^1.2.0"
"clean-css": "^4.2.1",
"glob": "^7.1.3",
"merge": "^1.2.1"
},
"directories": {
"test": "test"
Expand Down
Binary file added test-sample/test-data.zip
Binary file not shown.

0 comments on commit 9d469e2

Please sign in to comment.