Skip to content

Commit

Permalink
Sync with latest Jasmine code
Browse files Browse the repository at this point in the history
  • Loading branch information
dfederm committed May 10, 2018
1 parent 6c12b7d commit b7d2c13
Show file tree
Hide file tree
Showing 8 changed files with 648 additions and 599 deletions.
3 changes: 1 addition & 2 deletions .npmignore
@@ -1,2 +1 @@


build/
18 changes: 3 additions & 15 deletions README.md
Expand Up @@ -14,17 +14,7 @@ You can also run a describe block, or a single test.

## Installation

The easiest way is to keep `karma-jasmine-html-reporter` as a devDependency in your `package.json`.
```json
{
"devDependencies": {
"karma": "~0.10",
"karma-jasmine-html-reporter": "~0.1"
}
}
```

You can simply do it by:
You can simply install `karma-jasmine-html-reporter` as a devDependency by:
```bash
npm install karma-jasmine-html-reporter --save-dev
```
Expand All @@ -34,9 +24,7 @@ npm install karma-jasmine-html-reporter --save-dev
// karma.conf.js
module.exports = function(config) {
config.set({

reporters: ['kjhtml']

});
};
```
Expand All @@ -50,6 +38,6 @@ karma start --reporters kjhtml

There's not much to this package.

`adapter.js` and `html.jasmine.reporter.js` are copied with small adjustments from `jasmine/lib/jasmine-core/boot.js` and `jasmine/lib/jasmine-core/jasmine-html.js` respectively.
[`adapter.js`](src/lib/adapter.js), [`html.jasmine.reporter.js`](src/lib/html.jasmine.reporter.js), and [`jasmine.css`](src/css/jasmine.css) are copied with small adjustments from [`jasmine/lib/jasmine-core/boot.js`](https://github.com/jasmine/jasmine/blob/master/lib/jasmine-core/boot.js) and [`jasmine/lib/jasmine-core/jasmine-html.js`](https://github.com/jasmine/jasmine/blob/master/lib/jasmine-core/jasmine-html.js), and [`jasmine/lib/jasmine-core/jasmine.css`](https://github.com/jasmine/jasmine/blob/master/lib/jasmine-core/jasmine.css) respectively.

Just pull over changes from Jasmine as needed.
Just pull over changes from Jasmine as needed. There is a script to help with that; just run `npm run build` and review the changes. Specifically, [`adapter.js`](src/lib/adapter.js) needs a lot of manual removals.
36 changes: 36 additions & 0 deletions build/build.js
@@ -0,0 +1,36 @@
const fs = require("fs");
const path = require("path");
const chalk = require("chalk");

const jasminePackagePath = "node_modules/jasmine-core/lib/jasmine-core";
const srcBasePath = "src";

copyFromJasmine("jasmine.css", "jasmine.css");
copyFromJasmine("jasmine-html.js", "html.jasmine.reporter.js");

copyFromJasmine("boot.js", "adapter.js");
console.log(chalk.yellow("Be sure to review 'adapter.js'. There are many manual edits needed."));

function copyFromJasmine(src, dest) {
let fullSrc = path.join(jasminePackagePath, src);

let destSubdir;
let destExt = path.extname(dest);
switch (destExt) {
case ".css": {
destSubdir = "css";
break;
}
case ".js": {
destSubdir = "lib";
break;
}
default: {
throw new Error(`Unexpected extension: ${destExt}`);
}
}
let fullDest = path.join(srcBasePath, destSubdir, dest);

console.log(`Copying [${chalk.cyan(fullSrc)}] to [${chalk.cyan(fullDest)}]`);
fs.copyFileSync(fullSrc, fullDest);
}
67 changes: 62 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 10 additions & 6 deletions package.json
@@ -1,13 +1,16 @@
{
"name": "karma-jasmine-html-reporter",
"version": "1.0.0",
"version": "1.1.0",
"description": "A Karma plugin. Dynamically displays tests results at debug.html page",
"main": "./src/index.js",
"keywords": [
"karma-plugin",
"karma-reporter",
"html"
],
"scripts": {
"build": "node build/build.js"
},
"repository": {
"url": "https://github.com/dfederm/karma-jasmine-html-reporter"
},
Expand All @@ -30,14 +33,15 @@
"url": "https://github.com/protazy"
}
],
"dependencies": {
"karma-jasmine": "^1.1.1"
},
"peerDependencies": {
"karma": ">=0.9",
"jasmine": "^3.0.0"
"karma-jasmine": ">=1.1",
"jasmine": ">=3"
},
"license": "MIT",
"devDependencies": {},
"devDependencies": {
"chalk": "*",
"jasmine-core": ">=3"
},
"readmeFilename": "README.md"
}
2 changes: 1 addition & 1 deletion src/css/jasmine.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions src/index.js
@@ -1,14 +1,14 @@
var JASMINE_CORE_PATTERN = /([\\/]karma-jasmine[\\/])/i;
var createPattern = function(path) {
return {pattern: path, included: true, served: true, watched: false};
var createPattern = function (path) {
return { pattern: path, included: true, served: true, watched: false };
};

var initReporter = function(files, baseReporterDecorator) {
var initReporter = function (files, baseReporterDecorator) {
var jasmineCoreIndex = 0;

baseReporterDecorator(this);

files.forEach(function(file, index) {
files.forEach(function (file, index) {
if (JASMINE_CORE_PATTERN.test(file.pattern)) {
jasmineCoreIndex = index;
}
Expand All @@ -19,7 +19,7 @@ var initReporter = function(files, baseReporterDecorator) {
files.splice(++jasmineCoreIndex, 0, createPattern(__dirname + '/lib/adapter.js'));
};

initReporter.$inject = ['config.files', 'baseReporterDecorator'];
initReporter.$inject = ['config.files', 'baseReporterDecorator'];

module.exports = {
'reporter:kjhtml': ['type', initReporter]
Expand Down

0 comments on commit b7d2c13

Please sign in to comment.