@remotex-labs/xjet 1.1.0 → 1.2.0

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
@@ -4,12 +4,13 @@
4
4
  [![npm version](https://img.shields.io/npm/v/@remotex-labs/xjet.svg)](https://www.npmjs.com/package/@remotex-labs/xjet)
5
5
  [![License: MPL 2.0](https://img.shields.io/badge/License-MPL_2.0-brightgreen.svg)](https://opensource.org/licenses/MPL-2.0)
6
6
  [![Node.js CI](https://github.com/remotex-labs/xJet/actions/workflows/node.js.yml/badge.svg)](https://github.com/remotex-labs/xJet/actions/workflows/node.js.yml)
7
+ [![Discord](https://img.shields.io/discord/1364348850696884234?logo=Discord&label=Discord)](https://discord.gg/BnEUkXJC)
7
8
  [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/remotex-labs/xJet)
8
9
 
9
10
  ## Overview
10
11
 
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".
12
+ xJet is a powerful, flexible testing framework for JavaScript and TypeScript applications.
13
+ Its mission is to help you "Run Automated Tests Anywhere, Effortlessly."
13
14
 
14
15
  ## Features
15
16
 
@@ -25,50 +26,63 @@ Its mission is to help you "Run Automated Tests Anywhere, Effortlessly".
25
26
  npm install @remotex-labs/xjet
26
27
  ```
27
28
 
28
- ## Usage
29
+ ## 🚀 Quick Start
29
30
 
30
- ### Basic Test Example
31
+ Create a test file and start writing tests immediately:
31
32
 
32
33
  ```ts
33
34
  // 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); });
35
+ describe('Calculator', () => {
36
+ test('should add two numbers correctly', () => {
37
+ const result = 1 + 2; expect(result).toBe(3);
38
+ });
39
+
40
+ it('should subtract two numbers correctly', () => {
41
+ const result = 5 - 2; expect(result).toBe(3);
42
+ });
40
43
  });
41
44
  ```
42
45
 
43
- ### Running Tests
46
+ ## 📚 Documentation
44
47
 
45
- ```bash
46
- xJet
47
- ```
48
+ For comprehensive guides and reference, check our [documentation](https://remotex-labs.github.io/xJet/):
48
49
 
49
- Run:
50
+ - [CLI Options](https://remotex-labs.github.io/xJet/configuration/cli)
51
+ - [Test Structure](https://remotex-labs.github.io/xJet/tests/test)
52
+ - [Mocking APIs](https://remotex-labs.github.io/xJet/mocks/mock)
53
+ - [Timer Manipulation](https://remotex-labs.github.io/xJet/mocks/timer)
54
+ - [Matchers Reference](https://remotex-labs.github.io/xJet/xjet-expect/equality)
50
55
 
51
- ![Run](./docs/src/public/images/run.png)
56
+ Run:
52
57
 
53
- ![Run](./docs/src/public/images/run1.png)
58
+ ![Run](./docs/public/images/run.png)
54
59
 
55
- ![Run](./docs/src/public/images/run2.png)
60
+ ![Run](./docs/public/images/run1.png)
56
61
 
62
+ ![Run](./docs/public/images/run2.png)
57
63
 
58
64
  ## Documentation
65
+
59
66
  For complete API documentation, examples, and guides, visit: [xJet Documentation](https://remotex-labs.github.io/xJet/)
60
67
 
61
- ## Compatibility
68
+ ## 🔍 Compatibility
69
+
62
70
  - Node.js 20+
63
71
  - All modern browsers (via bundlers)
64
72
  - TypeScript 4.5+
65
73
 
66
- ## Contributing
67
- Contributions are welcome!\
68
- Please see our [Contributing Guide](CONTRIBUTING.md) for details.
74
+ ## 🤝 Contributing
75
+
76
+ Contributions are welcome! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
69
77
 
70
- ## License
71
- This project is licensed under the Mozilla Public License 2.0 see the [LICENSE](LICENSE) file for details.
78
+ ## 📄 License
79
+
80
+ This project is licensed under the Mozilla Public License 2.0 - see the [LICENSE](LICENSE) file for details.
81
+
82
+ ## 💖 Acknowledgements
72
83
 
73
- ## Acknowledgments
74
84
  - Built with TypeScript
85
+ - Inspired by testing frameworks like Jest and Mocha
86
+ - Powered by the esbuild ecosystem
87
+
88
+ 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.2.0")}
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(`