chromaui / chromatic-e2e

Archive end-to-end tests to be replayed in Storybook and Chromatic
MIT License
13 stars 3 forks source link

Fix error messaging #114

Closed tevanoff closed 3 months ago

tevanoff commented 4 months ago

Issue: #

What Changed

Clean up the error messaging when there's an error with an E2E build, like when the archives dir cannot be found, for example.

Before

> yarn chromatic-e2e -t ...
...
  ✖ Failed to run `chromatic --playwright`:

  Command failed with exit code 1: node /Users/tevanoff/dev/demos/e2e-demo-playwright/node_modules/@chromatic-com/playwright/dist/bin/build-archive-storybook.js --output-dir /var/folders/_5/526r8dsn37n8f9jy1v0hm1080000gn/T/chromatic--42055-G3UlMURZYcdn
/Users/tevanoff/dev/demos/e2e-demo-playwright/node_modules/@chromatic-com/playwright/dist/bin/build-archive-storybook.js:20
`,finalEOL:u=!0,replacer:a=null,spaces:r}={}){let m=u?y:"";return JSON.stringify(i,a,r).replace(/\n/g,y)+m}function n(i){return Buffer.isBuffer(i)&&(i=i.toString("utf8")),i.replace(/^\uFEFF/,"")}c.exports={stringify:t,stripBom:n};}),Bt=$((l,c)=>{var t;try{t=Q();}catch{t=G("fs");}var n=X(),{stringify:i,stripBom:y}=yt();async function u(F,o={}){typeof o=="string"&&(o={encoding:o});let f=o.fs||t,b="throws"in o?o.throws:!0,P=await n.fromCallback(f.readFile)(F,o);P=y(P);let e;try{e=JSON.parse(P,o?o.reviver:null);}catch(s){if(b)throw s.message=`${F}: ${s.message}`,s;return null}return e}var a=n.fromPromise(u);function r(F,o={}){typeof o=="string"&&(o={encoding:o});let f=o.fs||t,b="throws"in o?o.throws:!0;try{let P=f.readFileSync(F,o);return P=y(P),JSON.parse(P,o.reviver)}catch(P){if(b)throw P.message=`${F}: ${P.message}`,P;return null}}async function m(F,o,f={}){let b=f.fs||t,P=i(o,f);await n.fromCallback(b.writeFile)(F,P,f);}var O=n.fromPromise(m);function h(F,o,f={}){let b=f.fs||t,P=i(o,f);return b.writeFileSync(F,P,f)}var C={readFile:a,readFileSync:r,writeFile:O,writeFileSync:h};c.exports=C;}),Kt=$((l,c)=>{var t=Bt();c.exports={readJson:t.readFile,readJsonSync:t.readFileSync,writeJson:t.writeFile,writeJsonSync:t.writeFileSync};}),pt=$((l,c)=>{var t=X().fromCallback,n=Q(),i=G("path"),y=Z(),u=et().pathExists;function a(m,O,h,C){typeof h=="function"&&(C=h,h="utf8");let F=i.dirname(m);u(F,(o,f)=>{if(o)return C(o);if(f)return n.writeFile(m,O,h,C);y.mkdirs(F,b=>{if(b)return C(b);n.writeFile(m,O,h,C);});});}function r(m,...O){let h=i.dirname(m);if(n.existsSync(h))return n.writeFileSync(m,...O);y.mkdirsSync(h),n.writeFileSync(m,...O);}c.exports={outputFile:t(a),outputFileSync:r};}),Ht=$((l,c)=>{var{stringify:t}=yt(),{outputFile:n}=pt();async function i(y,u,a={}){let r=t(u,a);await n(y,r,a);}c.exports=i;}),zt=$((l,c)=>{var{stringify:t}=yt(),{outputFileSync:n}=pt();function i(y,u,a){let r=t(u,a);n(y,r,a);}c.exports=i;}),Xt=$((l,c)=>{var t=X().fromPromise,n=Kt();n.outputJson=t(Ht()),n.outputJsonSync=zt(),n.outputJSON=n.outputJson,n.outputJSONSync=n.outputJsonSync,n.writeJSON=n.writeJson,n.writeJSONSync=n.writeJsonSync,n.readJSON=n.readJson,n.readJSONSync=n.readJsonSync,c.exports=n;}),Qt=$((l,c)=>{var t=Q(),n=G("path"),i=lt().copy,y=ct().remove,u=Z().mkdirp,a=et().pathExists,r=it();function m(o,f,b,P){typeof b=="function"&&(P=b,b={}),b=b||{};let e=b.overwrite||b.clobber||!1;r.checkPaths(o,f,"move",b,(s,p)=>{if(s)return P(s);let{srcStat:d,isChangingCase:k=!1}=p;r.checkParentPaths(o,d,f,"move",S=>{if(S)return P(S);if(O(f))return h(o,f,e,k,P);u(n.dirname(f),v=>v?P(v):h(o,f,e,k,P));});});}function O(o){let f=n.dirname(o);return n.parse(f).root===f}function h(o,f,b,P,e){if(P)return C(o,f,b,e);if(b)return y(f,s=>s?e(s):C(o,f,b,e));a(f,(s,p)=>s?e(s):p?e(new Error("dest already exists.")):C(o,f,b,e));}function C(o,f,b,P){t.rename(o,f,e=>e?e.code!=="EXDEV"?P(e):F(o,f,b,P):P());}function F(o,f,b,P){i(o,f,{overwrite:b,errorOnExist:!0,preserveTimestamps:!0},e=>e?P(e):y(o,P));}c.exports=m;}),Zt=$((l,c)=>{var t=Q(),n=G("path"),i=lt().copySync,y=ct().removeSync,u=Z().mkdirpSync,a=it();function r(F,o,f){f=f||{};let b=f.overwrite||f.clobber||!1,{srcStat:P,isChangingCase:e=!1}=a.checkPathsSync(F,o,"move",f);return a.checkParentPathsSync(F,P,o,"move"),m(o)||u(n.dirname(o)),O(F,o,b,e)}function m(F){let o=n.dirname(F);return n.parse(o).root===o}function O(F,o,f,b){if(b)return h(F,o,f);if(f)return y(o),h(F,o,f);if(t.existsSync(o))throw new Error("dest already exists.");return h(F,o,f)}function h(F,o,f){try{t.renameSync(F,o);}catch(b){if(b.code!=="EXDEV")throw b;return C(F,o,f)}}function C(F,o,f){return i(F,o,{overwrite:f,errorOnExist:!0,preserveTimestamps:!0}),y(F)}c.exports=r;}),te=$((l,c)=>{var t=X().fromCallback;c.exports={move:t(Qt()),moveSync:Zt()};}),ee=$((l,c)=>{c.exports={...nt(),...lt(),...Jt(),...Vt(),...Xt(),...Z(),...te(),...pt(),...et(),...ct()};});function re(){return process.cwd()}function ne(){let{CHROMATIC_ARCHIVE_LOCATION:l}=process.env;return l}function dt(l){let c=ne()||l;return ft__default.default.resolve(re(),c,"chromatic-archives")}function ie(l){return ft__default.default.resolve(dt(l),"archive")}function oe(l){let c=dt(l);if(!xt__default.default.existsSync(c))throw new Error(`Chromatic archives directory cannot be found: ${c}

Error: Chromatic archives directory cannot be found: /Users/tevanoff/dev/demos/e2e-demo-playwright/test-results/chromatic-archives

Please make sure that you have run your E2E tests, or have set the CHROMATIC_ARCHIVE_LOCATION env var if the output directory for the tests is not in the standard location.
at oe (/Users/tevanoff/dev/demos/e2e-demo-playwright/node_modules/@chromatic-com/playwright/dist/bin/build-archive-storybook.js:20:4233)
at bt (/Users/tevanoff/dev/demos/e2e-demo-playwright/node_modules/@chromatic-com/playwright/dist/bin/build-archive-storybook.js:22:1588)
at Object.<anonymous> (/Users/tevanoff/dev/demos/e2e-demo-playwright/node_modules/@chromatic-com/playwright/dist/bin/build-archive-storybook.js:22:1885)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:86:12)
at node:internal/main/run_main_module:23:47

After

> yarn chromatic-e2e -t ...
...
✖ Failed to run `chromatic --playwright`:

Command failed with exit code 1: node /Users/tevanoff/dev/demos/e2e-demo-playwright/node_modules/@chromatic-com/playwright/dist/bin/build-archive-storybook.js --output-dir /var/folders/_5/526r8dsn37n8f9jy1v0hm1080000gn/T/chromatic--50839-XKwjzA2vkqro
Chromatic archives directory cannot be found: /Users/tevanoff/dev/demos/e2e-demo-playwright/test-results/chromatic-archives

Please make sure that you have run your E2E tests, or have set the CHROMATIC_ARCHIVE_LOCATION env var if the output directory for the tests is not in the standard location.

How to test