Skip to content

Commit e2b1ce3

Browse files
committed
0.1.8
- uses preact to reduce bundle size. - 208 KB -> 130 KB (60% reduction in size)
1 parent b7acb20 commit e2b1ce3

File tree

7 files changed

+46
-36
lines changed

7 files changed

+46
-36
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# 0.1.8 (11/13/2017)
2+
3+
- uses preact to reduce bundle size.
4+
- 208 KB -> 130 KB (60% reduction in size)
5+
16
# 0.1.7 (10/18/2017)
27

38
- uses babel-preset-env instead of babel-preset-es2015

docs/example/index.html

+1-5
Large diffs are not rendered by default.

docs/index.html

+2-6
Large diffs are not rendered by default.

index.js

+18-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const Parser = require('tap-parser');
2-
const Through = require('through2');
1+
const Parser = require('tap-parser');
2+
const Through = require('through2');
33
const Duplexer = require('duplexer');
44

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

1717
tap.on('comment', (res) => {
18-
if(!plan) {
19-
data.push({ type: 'test', name: res, start: Date.now(), assertions: [] });
18+
if (!plan) {
19+
data.push({
20+
type: 'test',
21+
name: res,
22+
start: Date.now(),
23+
assertions: []
24+
});
2025

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

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

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

6166
// This is a top level plan
62-
if(data[i].assertions.length == 0) {
67+
if (data[i].assertions.length == 0) {
6368
// move on with the tests
6469
plan = i;
6570
data[plan].tests = [];
6671
delete data[i].assertions;
67-
} else if(plan == -1) {
72+
} else if (plan == -1) {
6873
// this is flat plan that has no parent do nothing
6974
} else {
7075
// We know this is part of the currentPlan
71-
if(!data[plan]) {
76+
if (!data[plan]) {
7277
data[plan] = {
7378
tests: []
7479
};
@@ -84,7 +89,7 @@ module.exports = (callback) => {
8489
data = data.filter((d) => d > '');
8590

8691
function calculateTime(test) {
87-
if(test.end) {
92+
if (test.end) {
8893
return;
8994
}
9095
test.end = test.assertions[test.assertions.length - 1].end;
@@ -93,11 +98,11 @@ module.exports = (callback) => {
9398
});
9499
}
95100
data.forEach((plan) => {
96-
if(plan.tests && plan.tests.length === 0) {
101+
if (plan.tests && plan.tests.length === 0) {
97102
// this is an empty test
98103
plan.end = plan.start;
99-
} else if(plan.tests && plan.tests.length > 0) {
100-
for(var i = 0; i < plan.tests.length; i++) {
104+
} else if (plan.tests && plan.tests.length > 0) {
105+
for (var i = 0; i < plan.tests.length; i++) {
101106
calculateTime(plan.tests[i]);
102107
}
103108
plan.end = plan.tests[plan.tests.length - 1].end;

lib/generate.js

+4
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ module.exports = (report, outfile) => {
5454
]
5555
},
5656
resolve: {
57+
alias: {
58+
'react': 'preact-compat',
59+
'react-dom': 'preact-compat'
60+
},
5761
extensions: ['.js', '.json', '.jsx', '.css'],
5862
modules: [path.resolve(__dirname, 'node_modules'), 'node_modules']
5963
},

package.json

+11-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tap-html",
3-
"version": "0.1.7",
3+
"version": "0.1.8",
44
"description": "📊 an html tap reporter",
55
"author": "Gabriel J. Csapo <[email protected]>",
66
"license": "ISC",
@@ -19,7 +19,7 @@
1919
"coverage": "tap test --coverage --coverage-report=lcov",
2020
"storybook": "start-storybook -p 6006",
2121
"build-storybook": "build-storybook --output-dir=./docs/storybook",
22-
"generate-docs": "tryitout --template=landing --output=./docs"
22+
"generate-docs": "tryitout"
2323
},
2424
"bin": {
2525
"tap-html": "./bin/index.js"
@@ -37,23 +37,26 @@
3737
"html-webpack-inline-source-plugin": "0.0.9",
3838
"html-webpack-plugin": "^2.29.0",
3939
"memory-fs": "^0.4.1",
40+
"preact": "^8.2.6",
41+
"preact-compat": "^3.17.0",
4042
"prop-types": "^15.6.0",
4143
"psychic-ui": "^1.0.7",
42-
"react": "^16.0.0",
43-
"react-dom": "^16.0.0",
4444
"style-loader": "^0.19.0",
45-
"tap-parser": "^6.0.1",
45+
"tap-parser": "^7.0.0",
4646
"through2": "^2.0.3",
4747
"url-loader": "^0.6.2",
4848
"webpack": "^3.8.1"
4949
},
5050
"devDependencies": {
51-
"@storybook/react": "^3.2.12",
51+
"@storybook/react": "^3.2.15",
5252
"babel-minify-webpack-plugin": "^0.2.0",
53+
"babel-polyfill": "^6.26.0",
5354
"eslint": "^4.9.0",
5455
"eslint-plugin-react": "^7.4.0",
55-
"tap": "^10.7.2",
56+
"react": "^16.1.1",
57+
"react-dom": "^16.1.1",
58+
"tap": "^10.7.3",
5659
"tape": "^4.6.3",
57-
"tryitout": "^0.3.4"
60+
"tryitout": "^1.1.1"
5861
}
5962
}

tryitout.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ module.exports = {
1515
</div>
1616
</div>
1717
`,
18+
template: 'landing',
1819
options: {
1920
width: '100%'
2021
},
21-
footer: {
22-
author: 'Made with 🐒 by @gabrielcsapo',
23-
website: 'http://www.gabrielcsapo.com'
24-
}
22+
output: './docs',
23+
footer: `
24+
<div class="text-black">Made with ☕️ by <a href="http://www.gabrielcsapo.com">@gabrielcsapo</a></div>
25+
`
2526
}

0 commit comments

Comments
 (0)