Skip to content

Commit

Permalink
0.1.8
Browse files Browse the repository at this point in the history
- uses preact to reduce bundle size.
  - 208 KB -> 130 KB (60% reduction in size)
  • Loading branch information
gabrielcsapo committed Nov 14, 2017
1 parent b7acb20 commit e2b1ce3
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 36 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 0.1.8 (11/13/2017)

- uses preact to reduce bundle size.
- 208 KB -> 130 KB (60% reduction in size)

# 0.1.7 (10/18/2017)

- uses babel-preset-env instead of babel-preset-es2015
Expand Down
6 changes: 1 addition & 5 deletions docs/example/index.html

Large diffs are not rendered by default.

8 changes: 2 additions & 6 deletions docs/index.html

Large diffs are not rendered by default.

31 changes: 18 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Parser = require('tap-parser');
const Through = require('through2');
const Parser = require('tap-parser');
const Through = require('through2');
const Duplexer = require('duplexer');

module.exports = (callback) => {
Expand All @@ -15,8 +15,13 @@ module.exports = (callback) => {
var startTime = Date.now();

tap.on('comment', (res) => {
if(!plan) {
data.push({ type: 'test', name: res, start: Date.now(), assertions: [] });
if (!plan) {
data.push({
type: 'test',
name: res,
start: Date.now(),
assertions: []
});

// get the current index of the plan
// so that we can use this to push the current assertions to it
Expand All @@ -30,7 +35,7 @@ module.exports = (callback) => {
});

tap.on('extra', (res) => {
if(data && currentPlan > 0 && currentAssertion > 0) {
if (data && currentPlan > 0 && currentAssertion > 0) {
data[currentPlan]['assertions'][currentAssertion]['console'] += `${res}\n`;
}
});
Expand All @@ -54,21 +59,21 @@ module.exports = (callback) => {
var plan = -1;

// combine and clean up tests
for(var i = 0; i < data.length; i++) {
for (var i = 0; i < data.length; i++) {
// trims the name from having any extra new line breaks
data[i].name = data[i].name.trim();

// This is a top level plan
if(data[i].assertions.length == 0) {
if (data[i].assertions.length == 0) {
// move on with the tests
plan = i;
data[plan].tests = [];
delete data[i].assertions;
} else if(plan == -1) {
} else if (plan == -1) {
// this is flat plan that has no parent do nothing
} else {
// We know this is part of the currentPlan
if(!data[plan]) {
if (!data[plan]) {
data[plan] = {
tests: []
};
Expand All @@ -84,7 +89,7 @@ module.exports = (callback) => {
data = data.filter((d) => d > '');

function calculateTime(test) {
if(test.end) {
if (test.end) {
return;
}
test.end = test.assertions[test.assertions.length - 1].end;
Expand All @@ -93,11 +98,11 @@ module.exports = (callback) => {
});
}
data.forEach((plan) => {
if(plan.tests && plan.tests.length === 0) {
if (plan.tests && plan.tests.length === 0) {
// this is an empty test
plan.end = plan.start;
} else if(plan.tests && plan.tests.length > 0) {
for(var i = 0; i < plan.tests.length; i++) {
} else if (plan.tests && plan.tests.length > 0) {
for (var i = 0; i < plan.tests.length; i++) {
calculateTime(plan.tests[i]);
}
plan.end = plan.tests[plan.tests.length - 1].end;
Expand Down
4 changes: 4 additions & 0 deletions lib/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ module.exports = (report, outfile) => {
]
},
resolve: {
alias: {
'react': 'preact-compat',
'react-dom': 'preact-compat'
},
extensions: ['.js', '.json', '.jsx', '.css'],
modules: [path.resolve(__dirname, 'node_modules'), 'node_modules']
},
Expand Down
19 changes: 11 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tap-html",
"version": "0.1.7",
"version": "0.1.8",
"description": "📊 an html tap reporter",
"author": "Gabriel J. Csapo <[email protected]>",
"license": "ISC",
Expand All @@ -19,7 +19,7 @@
"coverage": "tap test --coverage --coverage-report=lcov",
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook --output-dir=./docs/storybook",
"generate-docs": "tryitout --template=landing --output=./docs"
"generate-docs": "tryitout"
},
"bin": {
"tap-html": "./bin/index.js"
Expand All @@ -37,23 +37,26 @@
"html-webpack-inline-source-plugin": "0.0.9",
"html-webpack-plugin": "^2.29.0",
"memory-fs": "^0.4.1",
"preact": "^8.2.6",
"preact-compat": "^3.17.0",
"prop-types": "^15.6.0",
"psychic-ui": "^1.0.7",
"react": "^16.0.0",
"react-dom": "^16.0.0",
"style-loader": "^0.19.0",
"tap-parser": "^6.0.1",
"tap-parser": "^7.0.0",
"through2": "^2.0.3",
"url-loader": "^0.6.2",
"webpack": "^3.8.1"
},
"devDependencies": {
"@storybook/react": "^3.2.12",
"@storybook/react": "^3.2.15",
"babel-minify-webpack-plugin": "^0.2.0",
"babel-polyfill": "^6.26.0",
"eslint": "^4.9.0",
"eslint-plugin-react": "^7.4.0",
"tap": "^10.7.2",
"react": "^16.1.1",
"react-dom": "^16.1.1",
"tap": "^10.7.3",
"tape": "^4.6.3",
"tryitout": "^0.3.4"
"tryitout": "^1.1.1"
}
}
9 changes: 5 additions & 4 deletions tryitout.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ module.exports = {
</div>
</div>
`,
template: 'landing',
options: {
width: '100%'
},
footer: {
author: 'Made with 🐒 by @gabrielcsapo',
website: 'http://www.gabrielcsapo.com'
}
output: './docs',
footer: `
<div class="text-black">Made with ☕️ by <a href="http://www.gabrielcsapo.com">@gabrielcsapo</a></div>
`
}

0 comments on commit e2b1ce3

Please sign in to comment.