Skip to content

Commit 336cbb6

Browse files
committed
fix tests
1 parent 7005f26 commit 336cbb6

2 files changed

Lines changed: 19 additions & 69 deletions

File tree

test/__snapshots__/index.test.js.snap

Lines changed: 13 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1549,61 +1549,6 @@ exports[`fixtures build esnext-ts with microbundle 6`] = `
15491549
`;
15501550
15511551
exports[`fixtures build jsx with microbundle 1`] = `
1552-
"Used script: microbundle --raw
1553-
1554-
Directory tree:
1555-
1556-
esnext-ts
1557-
dist
1558-
esnext-ts.esm.js
1559-
esnext-ts.esm.js.map
1560-
esnext-ts.js
1561-
esnext-ts.js.map
1562-
esnext-ts.umd.js
1563-
esnext-ts.umd.js.map
1564-
index.d.ts
1565-
node_modules
1566-
package.json
1567-
src
1568-
index.ts
1569-
tsconfig.json
1570-
1571-
1572-
Build \\"esnextTs\\" to dist:
1573-
1012 B: esnext-ts.js.gz
1574-
913 B: esnext-ts.js.br
1575-
1013 B: esnext-ts.esm.js.gz
1576-
913 B: esnext-ts.esm.js.br
1577-
1072 B: esnext-ts.umd.js.gz
1578-
975 B: esnext-ts.umd.js.br"
1579-
`;
1580-
1581-
exports[`fixtures build jsx with microbundle 2`] = `7`;
1582-
1583-
exports[`fixtures build jsx with microbundle 3`] = `
1584-
"var n=function(){function n(){}return n.prototype.then=function(r,e){var o=new n,i=this.s;if(i){var u=1&i?r:e;if(u){try{t(o,1,u(this.v))}catch(n){t(o,2,n)}return o}return this}return this.o=function(n){try{var i=n.v;1&n.s?t(o,1,r?r(i):i):e?t(o,1,e(i)):t(o,2,i)}catch(n){t(o,2,n)}},o},n}();function t(r,e,o){if(!r.s){if(o instanceof n){if(!o.s)return void(o.o=t.bind(null,r,e));1&e&&(e=o.s),o=o.v}if(o&&o.then)return void o.then(t.bind(null,r,e),t.bind(null,r,2));r.s=e,r.v=o;var i=r.o;i&&i(r)}}function r(t){return t instanceof n&&1&t.s}function e(n,t){try{var r=n()}catch(n){return t(!0,n)}return r&&r.then?r.then(t.bind(null,!1),t.bind(null,!0)):t(!1,r)}\\"undefined\\"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol(\\"Symbol.iterator\\"))),\\"undefined\\"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol(\\"Symbol.asyncIterator\\")));var o=function(){try{var o,i,u,f,h=[],c=!0,a=!1,l=e(function(){return function(e,f){try{var a=function(){o=function(n){var t;if(\\"undefined\\"!=typeof Symbol){if(Symbol.asyncIterator&&null!=(t=n[Symbol.asyncIterator]))return t.call(n);if(Symbol.iterator&&null!=(t=n[Symbol.iterator]))return t.call(n)}throw new TypeError(\\"Object is not async iterable\\")}([1,2]);var e=function(e,o,i){for(var u;;){var f=e();if(r(f)&&(f=f.v),!f)return h;if(f.then){u=0;break}var h=i();if(h&&h.then){if(!r(h)){u=1;break}h=h.s}if(o){var c=o();if(c&&c.then&&!r(c)){u=2;break}}}var a=new n,l=t.bind(null,a,2);return(0===u?f.then(s):1===u?h.then(v):c.then(y)).then(void 0,l),a;function v(n){h=n;do{if(o&&(c=o())&&c.then&&!r(c))return void c.then(y).then(void 0,l);if(!(f=e())||r(f)&&!f.v)return void t(a,1,h);if(f.then)return void f.then(s).then(void 0,l);r(h=i())&&(h=h.v)}while(!h||!h.then);h.then(v).then(void 0,l)}function s(n){n?(h=i())&&h.then?h.then(v).then(void 0,l):v(h):t(a,1,h)}function y(){(f=e())?f.then?f.then(s).then(void 0,l):s(f):t(a,1,h)}}(function(){return!!Promise.resolve(o.next()).then(function(n){return c=i.done,i=n,Promise.resolve(i.value).then(function(n){return u=n,!c})})},function(){return!!(c=!0)},function(){h.push(u)});if(e&&e.then)return e.then(function(){})}()}catch(n){return f(n)}return a&&a.then?a.then(void 0,f):a}(0,function(n){a=!0,f=n})},function(n,t){function r(r){if(n)throw t;return t}var i=e(function(){var n=function(){if(!c&&null!=o.return)return Promise.resolve(o.return()).then(function(){})}();if(n&&n.then)return n.then(function(){})},function(n,t){if(a)throw f;if(n)throw t;return t});return i&&i.then?i.then(r):r()});return Promise.resolve(l&&l.then?l.then(function(n){return h}):h)}catch(n){return Promise.reject(n)}};o().then(console.log);export default o;
1585-
//# sourceMappingURL=esnext-ts.esm.js.map
1586-
"
1587-
`;
1588-
1589-
exports[`fixtures build jsx with microbundle 4`] = `
1590-
"var n=function(){function n(){}return n.prototype.then=function(r,e){var o=new n,i=this.s;if(i){var u=1&i?r:e;if(u){try{t(o,1,u(this.v))}catch(n){t(o,2,n)}return o}return this}return this.o=function(n){try{var i=n.v;1&n.s?t(o,1,r?r(i):i):e?t(o,1,e(i)):t(o,2,i)}catch(n){t(o,2,n)}},o},n}();function t(r,e,o){if(!r.s){if(o instanceof n){if(!o.s)return void(o.o=t.bind(null,r,e));1&e&&(e=o.s),o=o.v}if(o&&o.then)return void o.then(t.bind(null,r,e),t.bind(null,r,2));r.s=e,r.v=o;var i=r.o;i&&i(r)}}function r(t){return t instanceof n&&1&t.s}function e(n,t){try{var r=n()}catch(n){return t(!0,n)}return r&&r.then?r.then(t.bind(null,!1),t.bind(null,!0)):t(!1,r)}\\"undefined\\"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol(\\"Symbol.iterator\\"))),\\"undefined\\"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol(\\"Symbol.asyncIterator\\")));var o=function(){try{var o,i,u,f,h=[],c=!0,a=!1,l=e(function(){return function(e,f){try{var a=function(){o=function(n){var t;if(\\"undefined\\"!=typeof Symbol){if(Symbol.asyncIterator&&null!=(t=n[Symbol.asyncIterator]))return t.call(n);if(Symbol.iterator&&null!=(t=n[Symbol.iterator]))return t.call(n)}throw new TypeError(\\"Object is not async iterable\\")}([1,2]);var e=function(e,o,i){for(var u;;){var f=e();if(r(f)&&(f=f.v),!f)return h;if(f.then){u=0;break}var h=i();if(h&&h.then){if(!r(h)){u=1;break}h=h.s}if(o){var c=o();if(c&&c.then&&!r(c)){u=2;break}}}var a=new n,l=t.bind(null,a,2);return(0===u?f.then(s):1===u?h.then(v):c.then(y)).then(void 0,l),a;function v(n){h=n;do{if(o&&(c=o())&&c.then&&!r(c))return void c.then(y).then(void 0,l);if(!(f=e())||r(f)&&!f.v)return void t(a,1,h);if(f.then)return void f.then(s).then(void 0,l);r(h=i())&&(h=h.v)}while(!h||!h.then);h.then(v).then(void 0,l)}function s(n){n?(h=i())&&h.then?h.then(v).then(void 0,l):v(h):t(a,1,h)}function y(){(f=e())?f.then?f.then(s).then(void 0,l):s(f):t(a,1,h)}}(function(){return!!Promise.resolve(o.next()).then(function(n){return c=i.done,i=n,Promise.resolve(i.value).then(function(n){return u=n,!c})})},function(){return!!(c=!0)},function(){h.push(u)});if(e&&e.then)return e.then(function(){})}()}catch(n){return f(n)}return a&&a.then?a.then(void 0,f):a}(0,function(n){a=!0,f=n})},function(n,t){function r(r){if(n)throw t;return t}var i=e(function(){var n=function(){if(!c&&null!=o.return)return Promise.resolve(o.return()).then(function(){})}();if(n&&n.then)return n.then(function(){})},function(n,t){if(a)throw f;if(n)throw t;return t});return i&&i.then?i.then(r):r()});return Promise.resolve(l&&l.then?l.then(function(n){return h}):h)}catch(n){return Promise.reject(n)}};o().then(console.log),module.exports=o;
1591-
//# sourceMappingURL=esnext-ts.js.map
1592-
"
1593-
`;
1594-
1595-
exports[`fixtures build jsx with microbundle 5`] = `
1596-
"!function(n,t){\\"object\\"==typeof exports&&\\"undefined\\"!=typeof module?module.exports=t():\\"function\\"==typeof define&&define.amd?define(t):(n=n||self).esnextTs=t()}(this,function(){var n=function(){function n(){}return n.prototype.then=function(e,r){var o=new n,i=this.s;if(i){var u=1&i?e:r;if(u){try{t(o,1,u(this.v))}catch(n){t(o,2,n)}return o}return this}return this.o=function(n){try{var i=n.v;1&n.s?t(o,1,e?e(i):i):r?t(o,1,r(i)):t(o,2,i)}catch(n){t(o,2,n)}},o},n}();function t(e,r,o){if(!e.s){if(o instanceof n){if(!o.s)return void(o.o=t.bind(null,e,r));1&r&&(r=o.s),o=o.v}if(o&&o.then)return void o.then(t.bind(null,e,r),t.bind(null,e,2));e.s=r,e.v=o;var i=e.o;i&&i(e)}}function e(t){return t instanceof n&&1&t.s}function r(n,t){try{var e=n()}catch(n){return t(!0,n)}return e&&e.then?e.then(t.bind(null,!1),t.bind(null,!0)):t(!1,e)}\\"undefined\\"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol(\\"Symbol.iterator\\"))),\\"undefined\\"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol(\\"Symbol.asyncIterator\\")));var o=function(){try{var o,i,u,f,c=[],h=!0,a=!1,l=r(function(){return function(r,f){try{var a=function(){o=function(n){var t;if(\\"undefined\\"!=typeof Symbol){if(Symbol.asyncIterator&&null!=(t=n[Symbol.asyncIterator]))return t.call(n);if(Symbol.iterator&&null!=(t=n[Symbol.iterator]))return t.call(n)}throw new TypeError(\\"Object is not async iterable\\")}([1,2]);var r=function(r,o,i){for(var u;;){var f=r();if(e(f)&&(f=f.v),!f)return c;if(f.then){u=0;break}var c=i();if(c&&c.then){if(!e(c)){u=1;break}c=c.s}if(o){var h=o();if(h&&h.then&&!e(h)){u=2;break}}}var a=new n,l=t.bind(null,a,2);return(0===u?f.then(s):1===u?c.then(v):h.then(d)).then(void 0,l),a;function v(n){c=n;do{if(o&&(h=o())&&h.then&&!e(h))return void h.then(d).then(void 0,l);if(!(f=r())||e(f)&&!f.v)return void t(a,1,c);if(f.then)return void f.then(s).then(void 0,l);e(c=i())&&(c=c.v)}while(!c||!c.then);c.then(v).then(void 0,l)}function s(n){n?(c=i())&&c.then?c.then(v).then(void 0,l):v(c):t(a,1,c)}function d(){(f=r())?f.then?f.then(s).then(void 0,l):s(f):t(a,1,c)}}(function(){return!!Promise.resolve(o.next()).then(function(n){return h=i.done,i=n,Promise.resolve(i.value).then(function(n){return u=n,!h})})},function(){return!!(h=!0)},function(){c.push(u)});if(r&&r.then)return r.then(function(){})}()}catch(n){return f(n)}return a&&a.then?a.then(void 0,f):a}(0,function(n){a=!0,f=n})},function(n,t){function e(e){if(n)throw t;return t}var i=r(function(){var n=function(){if(!h&&null!=o.return)return Promise.resolve(o.return()).then(function(){})}();if(n&&n.then)return n.then(function(){})},function(n,t){if(a)throw f;if(n)throw t;return t});return i&&i.then?i.then(e):e()});return Promise.resolve(l&&l.then?l.then(function(n){return c}):c)}catch(n){return Promise.reject(n)}};return o().then(console.log),o});
1597-
//# sourceMappingURL=esnext-ts.umd.js.map
1598-
"
1599-
`;
1600-
1601-
exports[`fixtures build jsx with microbundle 6`] = `
1602-
"export default function foo(): Promise<any[]>;
1603-
"
1604-
`;
1605-
1606-
exports[`fixtures build jsx with microbundle 7`] = `
16071552
"Used script: microbundle
16081553
16091554
Directory tree:
@@ -1617,35 +1562,34 @@ jsx
16171562
jsx.umd.js
16181563
jsx.umd.js.map
16191564
index.js
1620-
node_modules
16211565
package.json
16221566
16231567
16241568
Build \\"jsx\\" to dist:
1625-
181 B: jsx.js.gz
1626-
149 B: jsx.js.br
1627-
181 B: jsx.esm.js.gz
1628-
146 B: jsx.esm.js.br
1629-
268 B: jsx.umd.js.gz
1630-
226 B: jsx.umd.js.br"
1569+
262 B: jsx.js.gz
1570+
209 B: jsx.js.br
1571+
263 B: jsx.esm.js.gz
1572+
212 B: jsx.esm.js.br
1573+
335 B: jsx.umd.js.gz
1574+
278 B: jsx.umd.js.br"
16311575
`;
16321576
1633-
exports[`fixtures build jsx with microbundle 8`] = `6`;
1577+
exports[`fixtures build jsx with microbundle 2`] = `6`;
16341578
1635-
exports[`fixtures build jsx with microbundle 9`] = `
1636-
"const l=(l,e,...n)=>({tag:l,props:e,children:n}),e=({children:l})=>l;export default class{render(){return l(\\"div\\",{id:\\"app\\"},l(\\"h1\\",null,\\"Hello, World!\\"),l(\\"p\\",null,\\"A JSX demo.\\"),l(e,null,l(\\"p\\",null,\\"Test fragment\\")))}}
1579+
exports[`fixtures build jsx with microbundle 3`] = `
1580+
"var n=function(n,r){for(var e=arguments.length,t=new Array(e>2?e-2:0),l=2;l<e;l++)t[l-2]=arguments[l];return{tag:n,props:r,children:t}},r=function(n){return n.children},e=function(){function e(){}return e.prototype.render=function(){return n(\\"div\\",{id:\\"app\\"},n(\\"h1\\",null,\\"Hello, World!\\"),n(\\"p\\",null,\\"A JSX demo.\\"),n(r,null,n(\\"p\\",null,\\"Test fragment\\")))},e}();export default e;
16371581
//# sourceMappingURL=jsx.esm.js.map
16381582
"
16391583
`;
16401584
1641-
exports[`fixtures build jsx with microbundle 10`] = `
1642-
"const l=(l,e,...n)=>({tag:l,props:e,children:n}),e=({children:l})=>l;module.exports=class{render(){return l(\\"div\\",{id:\\"app\\"},l(\\"h1\\",null,\\"Hello, World!\\"),l(\\"p\\",null,\\"A JSX demo.\\"),l(e,null,l(\\"p\\",null,\\"Test fragment\\")))}};
1585+
exports[`fixtures build jsx with microbundle 4`] = `
1586+
"var n=function(n,r){for(var e=arguments.length,t=new Array(e>2?e-2:0),l=2;l<e;l++)t[l-2]=arguments[l];return{tag:n,props:r,children:t}},r=function(n){return n.children};module.exports=function(){function e(){}return e.prototype.render=function(){return n(\\"div\\",{id:\\"app\\"},n(\\"h1\\",null,\\"Hello, World!\\"),n(\\"p\\",null,\\"A JSX demo.\\"),n(r,null,n(\\"p\\",null,\\"Test fragment\\")))},e}();
16431587
//# sourceMappingURL=jsx.js.map
16441588
"
16451589
`;
16461590
1647-
exports[`fixtures build jsx with microbundle 11`] = `
1648-
"!function(e,n){\\"object\\"==typeof exports&&\\"undefined\\"!=typeof module?module.exports=n():\\"function\\"==typeof define&&define.amd?define(n):(e=e||self).jsx=n()}(this,function(){const e=(e,n,...l)=>({tag:e,props:n,children:l}),n=({children:e})=>e;return class{render(){return e(\\"div\\",{id:\\"app\\"},e(\\"h1\\",null,\\"Hello, World!\\"),e(\\"p\\",null,\\"A JSX demo.\\"),e(n,null,e(\\"p\\",null,\\"Test fragment\\")))}}});
1591+
exports[`fixtures build jsx with microbundle 5`] = `
1592+
"!function(n,e){\\"object\\"==typeof exports&&\\"undefined\\"!=typeof module?module.exports=e():\\"function\\"==typeof define&&define.amd?define(e):(n=n||self).jsx=e()}(this,function(){var n=function(n,e){for(var t=arguments.length,r=new Array(t>2?t-2:0),o=2;o<t;o++)r[o-2]=arguments[o];return{tag:n,props:e,children:r}},e=function(n){return n.children};return function(){function t(){}return t.prototype.render=function(){return n(\\"div\\",{id:\\"app\\"},n(\\"h1\\",null,\\"Hello, World!\\"),n(\\"p\\",null,\\"A JSX demo.\\"),n(e,null,n(\\"p\\",null,\\"Test fragment\\")))},t}()});
16491593
//# sourceMappingURL=jsx.umd.js.map
16501594
"
16511595
`;

test/index.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ const FIXTURES_DIR = `${__dirname}/fixtures`;
88
const DEFAULT_SCRIPT = 'microbundle';
99
const TEST_TIMEOUT = 11000;
1010

11+
const sleep = ms => new Promise(r => setTimeout(r, ms));
12+
1113
const join = (arr, delimiter = '') => arr.join(delimiter);
1214

1315
const printTree = (nodes, indentLevel = 0) => {
@@ -39,8 +41,12 @@ describe('fixtures', () => {
3941
fixturePath = resolve(fixturePath, fixtureDir.replace('-with-cwd', ''));
4042
}
4143

44+
await sleep(1);
45+
4246
const output = await buildDirectory(fixtureDir);
4347

48+
await sleep(1);
49+
4450
const printedDir = printTree([dirTree(fixturePath)]);
4551

4652
expect(

0 commit comments

Comments
 (0)