@remotex-labs/xjet 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -8,8 +8,8 @@
8
8
 
9
9
  ## Overview
10
10
 
11
- xJet is a powerful, flexible testing framework for JavaScript and TypeScript applications.
12
- Its mission is to help you "Run Automated Tests Anywhere, Effortlessly".
11
+ xJet is a powerful, flexible testing framework for JavaScript and TypeScript applications.
12
+ Its mission is to help you "Run Automated Tests Anywhere, Effortlessly."
13
13
 
14
14
  ## Features
15
15
 
@@ -25,50 +25,63 @@ Its mission is to help you "Run Automated Tests Anywhere, Effortlessly".
25
25
  npm install @remotex-labs/xjet
26
26
  ```
27
27
 
28
- ## Usage
28
+ ## 🚀 Quick Start
29
29
 
30
- ### Basic Test Example
30
+ Create a test file and start writing tests immediately:
31
31
 
32
32
  ```ts
33
33
  // example.test.ts
34
- describe('Calculator', () => { test('should add two numbers correctly', () => {
35
- const result = 1 + 2; expect(result).toBe(3);
36
- });
37
-
38
- it('should subtract two numbers correctly', () => {
39
- const result = 5 - 2; expect(result).toBe(3); });
34
+ describe('Calculator', () => {
35
+ test('should add two numbers correctly', () => {
36
+ const result = 1 + 2; expect(result).toBe(3);
37
+ });
38
+
39
+ it('should subtract two numbers correctly', () => {
40
+ const result = 5 - 2; expect(result).toBe(3);
41
+ });
40
42
  });
41
43
  ```
42
44
 
43
- ### Running Tests
45
+ ## 📚 Documentation
44
46
 
45
- ```bash
46
- xJet
47
- ```
47
+ For comprehensive guides and reference, check our [documentation](https://remotex-labs.github.io/xJet/):
48
48
 
49
- Run:
49
+ - [CLI Options](https://remotex-labs.github.io/xJet/configuration/cli)
50
+ - [Test Structure](https://remotex-labs.github.io/xJet/tests/test)
51
+ - [Mocking APIs](https://remotex-labs.github.io/xJet/mocks/mock)
52
+ - [Timer Manipulation](https://remotex-labs.github.io/xJet/mocks/timer)
53
+ - [Matchers Reference](https://remotex-labs.github.io/xJet/xjet-expect/equality)
50
54
 
51
- ![Run](./docs/src/public/images/run.png)
55
+ Run:
52
56
 
53
- ![Run](./docs/src/public/images/run1.png)
57
+ ![Run](./docs/public/images/run.png)
54
58
 
55
- ![Run](./docs/src/public/images/run2.png)
59
+ ![Run](./docs/public/images/run1.png)
56
60
 
61
+ ![Run](./docs/public/images/run2.png)
57
62
 
58
63
  ## Documentation
64
+
59
65
  For complete API documentation, examples, and guides, visit: [xJet Documentation](https://remotex-labs.github.io/xJet/)
60
66
 
61
- ## Compatibility
67
+ ## 🔍 Compatibility
68
+
62
69
  - Node.js 20+
63
70
  - All modern browsers (via bundlers)
64
71
  - TypeScript 4.5+
65
72
 
66
- ## Contributing
67
- Contributions are welcome!\
68
- Please see our [Contributing Guide](CONTRIBUTING.md) for details.
73
+ ## 🤝 Contributing
74
+
75
+ Contributions are welcome! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
69
76
 
70
- ## License
71
- This project is licensed under the Mozilla Public License 2.0 see the [LICENSE](LICENSE) file for details.
77
+ ## 📄 License
78
+
79
+ This project is licensed under the Mozilla Public License 2.0 - see the [LICENSE](LICENSE) file for details.
80
+
81
+ ## 💖 Acknowledgements
72
82
 
73
- ## Acknowledgments
74
83
  - Built with TypeScript
84
+ - Inspired by testing frameworks like Jest and Mocha
85
+ - Powered by the esbuild ecosystem
86
+
87
+ Made with ❤️ by the remotex-labs/xJet team
package/dist/bash.js CHANGED
@@ -18,7 +18,7 @@ __ __ | | ___| |_
18
18
  > </\\__/ / __/ |_
19
19
  /_/\\_\\____/ \\___|\\__|
20
20
  `;function z(){return`${Ne.burntOrange(Dt)}
21
- Version: ${Ne.brightPink("1.1.0")}
21
+ Version: ${Ne.brightPink("1.1.1")}
22
22
  `}o(z,"bannerComponent");import{existsSync as zt}from"fs";import{version as Ot}from"process";var _e={bail:!1,files:["**/*.test.ts","**/*.spec.ts"],watch:!1,suites:[],filter:[],verbose:!1,timeout:5e3,parallel:1,exclude:[/node_modules/],reporter:"default",randomize:!1,build:{target:[`node${Ot.slice(1)}`],packages:"bundle",platform:"browser",external:[]}};import{dirname as Ut}from"path";import{createRequire as Gt}from"module";import{Script as jt,createContext as Lt}from"vm";async function M(i,e={},t={}){let r=new jt(i,t),s=Lt(e);return await r.runInContext(s,{breakOnSigint:!0,displayErrors:!1})}o(M,"sandboxExecute");var b=class i extends y{constructor(t,r){if(t instanceof y)return t;super(t.message,"VMRuntimeError");this.originalError=t;t instanceof AggregateError&&Array.isArray(t.errors)&&(this.errors=t.errors.map(s=>new i(s,r))),this.stack=t.stack,this.message=t.message,this.reformatStack(t,r)}static{o(this,"VMRuntimeError")}errors=[];[Symbol.for("nodejs.util.inspect.custom")](){if(this.errors&&this.errors.length>0){let t=this.errors.map(r=>`${r.formattedStack??r.stack}`).join("");return`VMRuntimeError Contains ${this.errors.length} nested errors:
23
23
  ${t}
24
24
  `}return this.formattedStack??this.stack}};import{cwd as Be}from"process";import{build as Bt}from"esbuild";var h=class extends y{static{o(this,"xJetError")}constructor(e,t={withFrameworkFrames:!0}){super(e),this.reformatStack(this,t)}};import{xterm as de}from"@remotex-labs/xansi/xterm.component";import{formatCode as Nt}from"@remotex-labs/xmap/formatter.component";import{highlightCode as _t}from"@remotex-labs/xmap/highlighter.component";var W=class extends y{static{o(this,"esBuildError")}constructor(e){super("esBuildError build failed","esBuildError"),e.aggregateErrors?this.formatAggregateErrors(e.aggregateErrors):this.reformatStack(e,{withFrameworkFrames:!0})}formatAggregateErrors(e){this.formattedStack="";for(let t of e)this.formattedStack+=`
@@ -33,7 +33,7 @@ ${de.lightCoral(`${t.text}: ${t.notes.pop()?.text}`)}
33
33
  `);if(this.outFilePath){let t=vr(this.outFilePath);Tr(t,{recursive:!0}),xr(this.outFilePath,e)}console.log(e)}convertSuiteToXml(e){let t=e.rootDescribe,r=this.countTests(t),s=this.countFailures(t),n=this.countSkipped(t),a=this.formatDuration(e.duration),c=[`name="${e.suiteName}"`,`tests="${r}"`,`failures="${s}"`,`skipped="${n}"`,`time="${a}"`].join(" ");this.xmlParts.push(`<testsuite ${c}>`),this.convertDescribeToXml(t),this.xmlParts.push("</testsuite>")}convertDescribeToXml(e){e.tests.forEach(t=>this.convertTestToXml(t)),e.describes.forEach(t=>this.convertDescribeToXml(t))}convertTestToXml(e){let t=this.formatDuration(e.duration),r=e.description,n=`classname="${e.ancestry.join(".")||"root"}" name="${r}" time="${t}"`;if(e.skipped||e.todo){let c=e.todo?"TODO":"Skipped";this.xmlParts.push(`<testcase ${n}><skipped message="${c}" /></testcase>`);return}if(e.passed){this.xmlParts.push(`<testcase ${n} />`);return}let a=this.formatErrors(e.errors);this.xmlParts.push(`<testcase ${n}>${a}</testcase>`)}formatErrors(e){return e?.length?e.map(t=>`<failure message="${t.name}">${this.escapeXml(t.message)}
34
34
  ${t.formatCode}
35
35
 
36
- ${this.escapeXml(t.stack)}</failure>`).join(""):""}formatDuration(e){return((e??0)/1e3).toFixed(3)}countTests(e){return e.tests.length+e.describes.reduce((t,r)=>t+this.countTests(r),0)}countSkipped(e){return e.tests.filter(r=>r.skipped||r.todo).length+e.describes.reduce((r,s)=>r+this.countSkipped(s),0)}countFailures(e){return e.tests.filter(r=>!r.passed&&!r.skipped&&!r.todo).length+e.describes.reduce((r,s)=>r+this.countFailures(s),0)}escapeXml(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}};import{ANSI as Se,writeRaw as Qe}from"@remotex-labs/xansi";import{xterm as w}from"@remotex-labs/xansi/xterm.component";import{ShadowRenderer as Ye}from"@remotex-labs/xansi/shadow.service";import{xterm as L}from"@remotex-labs/xansi/xterm.component";var Q=4,m={todo:L.hex("#da5aec"),failed:L.hex("#F08080"),passed:L.hex("#90EE90"),skipped:L.hex("#fcaa63"),running:L.hex("#FFD966"),pending:L.hex("#808080")},Ve={5:m.pending("[ Pending ]"),0:m.running("[ RUNNING ]"),4:m.skipped("[ SKIPPED ]"),3:m.passed("[ PASSED ]"),2:m.failed("[ FAILED ]")};var U=class extends O{static{o(this,"ConsoleReporter")}startTime=Date.now();isSingleRunner=!1;updateInterval;maxRunnerNameLength=0;info;status;tests=this.createTests();suites=this.createSuites();suiteMap=new Map;constructor(e,t){super(e,t);let r=process.stdout.rows??24,s=process.stdout.columns??80;this.info=new Ye(r-Q-1,s,1,0),this.status=new Ye(Q,s,r-Q,0)}init(e,t){Qe(Se.HIDE_CURSOR),Qe(Se.CLEAR_SCREEN_UP),this.suiteMap.clear(),this.startTime=Date.now(),this.tests=this.createTests(),this.suites=this.createSuites(),this.isSingleRunner=t.length<2,this.updateInterval=setInterval(this.updateState.bind(this),230),this.maxRunnerNameLength=Math.max(...t.map(r=>r.name.length));for(let r of e)for(let s of t){let n=this.getSuiteKey(s.name,r),a=this.getPrefix(5,s.name,r);this.suiteMap.set(n,{todo:0,total:0,passed:0,failed:0,skipped:0,title:a,details:[]})}this.renderSuites()}log(e){if(e.levelId>this.logLevel||this.logLevel===0)return;let t=this.ensureSuite(e.runner,e.suite),r=[""];r.push(this.getLogPrefix(e)+w.gray(` [${e.ancestry.join(" > ")}]`)),r.push(...e.message.split(`
36
+ ${this.escapeXml(t.stack)}</failure>`).join(""):""}formatDuration(e){return((e??0)/1e3).toFixed(3)}countTests(e){return e.tests.length+e.describes.reduce((t,r)=>t+this.countTests(r),0)}countSkipped(e){return e.tests.filter(r=>r.skipped||r.todo).length+e.describes.reduce((r,s)=>r+this.countSkipped(s),0)}countFailures(e){return e.tests.filter(r=>!r.passed&&!r.skipped&&!r.todo).length+e.describes.reduce((r,s)=>r+this.countFailures(s),0)}escapeXml(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}};import{ANSI as Se,writeRaw as Qe}from"@remotex-labs/xansi";import{xterm as w}from"@remotex-labs/xansi/xterm.component";import{ShadowRenderer as Ye}from"@remotex-labs/xansi/shadow.service";import{xterm as L}from"@remotex-labs/xansi/xterm.component";var Q=4,m={todo:L.hex("#da5aec"),failed:L.hex("#F08080"),passed:L.hex("#90EE90"),skipped:L.hex("#fcaa63"),running:L.hex("#FFD966"),pending:L.hex("#808080")},Ve={5:m.pending("[ Pending ]"),0:m.running("[ RUNNING ]"),4:m.skipped("[ SKIPPED ]"),3:m.passed("[ PASSED ]"),2:m.failed("[ FAILED ]")};var U=class extends O{static{o(this,"ConsoleReporter")}startTime=Date.now();isSingleRunner=!1;updateInterval;maxRunnerNameLength=0;info;status;tests=this.createTests();suites=this.createSuites();suiteMap=new Map;constructor(e,t){super(e,t);let r=process.stdout.rows??24,s=process.stdout.columns??80;this.info=new Ye(r-Q-1,s,1,0),this.status=new Ye(Q,s,r-Q,0)}init(e,t){Qe(Se.HIDE_CURSOR),Qe(Se.CLEAR_SCREEN),this.suiteMap.clear(),this.startTime=Date.now(),this.tests=this.createTests(),this.suites=this.createSuites(),this.isSingleRunner=t.length<2,this.updateInterval=setInterval(this.updateState.bind(this),230),this.maxRunnerNameLength=Math.max(...t.map(r=>r.name.length));for(let r of e)for(let s of t){let n=this.getSuiteKey(s.name,r),a=this.getPrefix(5,s.name,r);this.suiteMap.set(n,{todo:0,total:0,passed:0,failed:0,skipped:0,title:a,details:[]})}this.renderSuites()}log(e){if(e.levelId>this.logLevel||this.logLevel===0)return;let t=this.ensureSuite(e.runner,e.suite),r=[""];r.push(this.getLogPrefix(e)+w.gray(` [${e.ancestry.join(" > ")}]`)),r.push(...e.message.split(`
37
37
  `).map(s=>" ".repeat(2)+s)),e.invocation&&r.push(w.gray(`at (${e.invocation.source}:${e.invocation.line}:${e.invocation.column})`));for(let s of r)t.details.push(s);t.details.push(""),this.renderSuites()}suiteStart(e){let t=this.ensureSuite(e.runner,e.suite);t.title=this.getPrefix(0,e.runner,e.suite),this.renderSuites()}suiteEnd(e){this.suites.total+=1;let t=this.ensureSuite(e.runner,e.suite),r=3;e.error?(this.suites.failed+=1,r=2):t.total===t.skipped+t.todo?(this.suites.skipped+=1,r=4):t.failed>0?(this.suites.failed+=1,r=2):this.suites.passed+=1;let s=this.getPrefix(r,e.runner,e.suite);s+=` ${(e.duration/1e3).toFixed(3)} s`,t.title=s,e.error&&t.details.push(...this.parseError(e.error)),this.renderSuites()}describeEnd(e){let t=this.ensureSuite(e.runner,e.suite);if(e.errors?.length){t.failed+=1;for(let r of e.errors)t.details.push(...this.parseError(r))}}testStart(e){let t=this.ensureSuite(e.runner,e.suite);(e.todo||e.skipped)&&this.incrementTestCounters(e.todo?"todo":"skipped",t)}testEnd(e){let t=this.ensureSuite(e.runner,e.suite);if(e.errors&&e.errors.length>0){this.incrementTestCounters("failed",t);let r=m.failed(`\u25CF ${e.ancestry.join(" > ")} > ${e.description}`);r+=w.gray(` (${(e.duration/1e3).toFixed(3)} s)`),t.details.push(r);for(let s of e.errors)t.details.push(...this.parseError(s))}else this.incrementTestCounters("passed",t)}finish(){this.updateInterval?.close(),this.updateState(),this.info.clearScreen(),this.status.clearScreen(),this.info.flushToTerminal(),this.status.flushToTerminal()}getSuiteKey(e,t){return`${e}::${t}`}ensureSuite(e,t){return this.suiteMap.get(this.getSuiteKey(e,t))}createTests(){return{total:0,passed:0,failed:0,skipped:0,todo:0}}createSuites(){return{total:0,passed:0,failed:0,skipped:0}}parseError(e){let t=["",...e.message.split(`
38
38
  `),""];return t.push(...e.formatCode.split(`
39
39
  `).map(r=>w.dim(r)),""),t.push(...e.stack.split(`