@gjsify/unit 0.4.43 → 0.5.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
@@ -7,9 +7,7 @@ Part of the [gjsify](https://github.com/gjsify/gjsify) project — Node.js and W
7
7
  ## Installation
8
8
 
9
9
  ```bash
10
- npm install @gjsify/unit
11
- # or
12
- yarn add @gjsify/unit
10
+ gjsify install @gjsify/unit
13
11
  ```
14
12
 
15
13
  ## Usage
package/lib/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import"./_virtual/_rolldown/runtime.js";import{spy as e}from"./spy.js";import"@girs/gjs";import t from"node:assert";import{quitMainLoop as n}from"@gjsify/utils/main-loop";const runtimeGlobals=()=>globalThis,r=runtimeGlobals().imports?.mainloop;let i=0,a=0,o=0,s=``,c=0,l=``,u=[],d={testTimeout:5e3,suiteTimeout:3e4,runTimeout:12e4};var TimeoutError=class extends Error{constructor(e,t){super(`Timeout: "${e}" exceeded ${t}ms`),this.name=`TimeoutError`}};async function withTimeout(e,t,n){if(t<=0)return e();let r,i=new Promise((e,i)=>{r=setTimeout(()=>i(new TimeoutError(n,t)),t)}),a=Promise.resolve(e());a.catch(()=>{});try{return await Promise.race([a,i])}finally{clearTimeout(r)}}const configure=e=>{d={...d,...e}};function applyEnvOverrides(){try{let e=runtimeGlobals().process?.env;if(!e)return;let t=parseInt(e.GJSIFY_TEST_TIMEOUT,10);!isNaN(t)&&t>=0&&(d.testTimeout=t);let n=parseInt(e.GJSIFY_SUITE_TIMEOUT,10);!isNaN(n)&&n>=0&&(d.suiteTimeout=n);let r=parseInt(e.GJSIFY_RUN_TIMEOUT,10);!isNaN(r)&&r>=0&&(d.runTimeout=r)}catch{}}const f=`\x1B[31m`,p=`\x1B[32m`,m=`\x1B[34m`,h=`\x1B[90m`,g=`\x1B[39m`,now=()=>runtimeGlobals().performance?.now?.()??Date.now(),formatDuration=e=>e>=1e3?`${(e/1e3).toFixed(2)}s`:e>=100?`${Math.round(e)}ms`:`${e.toFixed(1)}ms`,_=typeof runtimeGlobals().process?.versions?.gjs!=`string`&&runtimeGlobals().document!==void 0?console.log:globalThis.print||console.log;var v=class MatcherFactory{actualValue;positive;not;constructor(e,t,n){this.actualValue=e,this.positive=t,n?this.not=n:this.not=new MatcherFactory(e,!t,this)}triggerResult(e,t){if(e&&!this.positive||!e&&this.positive){let e=Error(t);throw e.__testFailureCounted=!0,++a,e}}to(e){this.triggerResult(e(this.actualValue),` Expected callback to validate`)}toBe(e){this.triggerResult(this.actualValue===e,` Expected values to match using ===
1
+ import"./_virtual/_rolldown/runtime.js";import{spy as e}from"./spy.js";import"@girs/gjs";import t from"node:assert";import{quitMainLoop as n}from"@gjsify/utils/main-loop";const runtimeGlobals=()=>globalThis,r=runtimeGlobals().imports?.mainloop;let i=0,a=0,o=0,s=``,c=0,l=``,u=[],d={testTimeout:5e3,suiteTimeout:3e4,runTimeout:12e4};var TimeoutError=class extends Error{constructor(e,t){super(`Timeout: "${e}" exceeded ${t}ms`),this.name=`TimeoutError`}};async function withTimeout(e,t,n){if(t<=0)return e();let r,i=new Promise((e,i)=>{r=setTimeout(()=>i(new TimeoutError(n,t)),t)}),a=Promise.resolve(e());a.catch(()=>{});try{return await Promise.race([a,i])}finally{clearTimeout(r)}}const configure=e=>{d={...d,...e}};function applyEnvOverrides(){try{let e=runtimeGlobals().process?.env;if(!e)return;let t=parseInt(e.GJSIFY_TEST_TIMEOUT,10);!isNaN(t)&&t>=0&&(d.testTimeout=t);let n=parseInt(e.GJSIFY_SUITE_TIMEOUT,10);!isNaN(n)&&n>=0&&(d.suiteTimeout=n);let r=parseInt(e.GJSIFY_RUN_TIMEOUT,10);!isNaN(r)&&r>=0&&(d.runTimeout=r)}catch{}}const f=`\x1B[31m`,p=`\x1B[32m`,m=`\x1B[34m`,h=`\x1B[90m`,g=`\x1B[39m`,now=()=>runtimeGlobals().performance?.now?.()??Date.now(),formatDuration=e=>e>=1e3?`${(e/1e3).toFixed(2)}s`:e>=100?`${Math.round(e)}ms`:`${e.toFixed(1)}ms`,_=typeof runtimeGlobals().process?.versions?.gjs!=`string`&&runtimeGlobals().document!==void 0?console.log:globalThis.print||console.log;var v=class MatcherFactory{not;constructor(e,t,n){this.actualValue=e,this.positive=t,n?this.not=n:this.not=new MatcherFactory(e,!t,this)}triggerResult(e,t){if(e&&!this.positive||!e&&this.positive){let e=Error(t);throw e.__testFailureCounted=!0,++a,e}}to(e){this.triggerResult(e(this.actualValue),` Expected callback to validate`)}toBe(e){this.triggerResult(this.actualValue===e,` Expected values to match using ===
2
2
  Expected: ${e} (${typeof e})\n Actual: ${this.actualValue} (${typeof this.actualValue})`)}toEqual(e){this.triggerResult(this.actualValue==e,` Expected values to match using ==
3
3
  Expected: ${e} (${typeof e})\n Actual: ${this.actualValue} (${typeof this.actualValue})`)}toStrictEqual(e){let n=!0,r=``;try{t.deepStrictEqual(this.actualValue,e)}catch(e){n=!1,r=e.message||``}this.triggerResult(n,` Expected values to be deeply strictly equal
4
4
  Expected: ${JSON.stringify(e)}\n Actual: ${JSON.stringify(this.actualValue)}`+(r?`\n ${r}`:``))}toEqualArray(e){let t=this.actualValue,n=Array.isArray(t)&&Array.isArray(e)&&t.length===e.length;for(let r=0;r<t.length&&(n=t[r]==e[r],n);r++);this.triggerResult(n,` Expected array items to match using ==
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/unit",
3
- "version": "0.4.43",
3
+ "version": "0.5.0",
4
4
  "description": "A BDD-style testing framework for Gjs",
5
5
  "module": "lib/esm/index.js",
6
6
  "types": "lib/types/index.d.ts",
@@ -46,20 +46,20 @@
46
46
  "devDependencies": {
47
47
  "@girs/gjs": "4.0.4",
48
48
  "@girs/glib-2.0": "2.88.0-4.0.4",
49
- "@gjsify/cli": "^0.4.43",
50
- "@types/node": "^25.9.1",
49
+ "@gjsify/cli": "^0.5.0",
50
+ "@types/node": "^25.9.2",
51
51
  "typescript": "^6.0.3"
52
52
  },
53
53
  "dependencies": {
54
- "@gjsify/abort-controller": "^0.4.43",
55
- "@gjsify/assert": "^0.4.43",
56
- "@gjsify/buffer": "^0.4.43",
57
- "@gjsify/dom-elements": "^0.4.43",
58
- "@gjsify/dom-exception": "^0.4.43",
59
- "@gjsify/node-globals": "^0.4.43",
60
- "@gjsify/process": "^0.4.43",
61
- "@gjsify/utils": "^0.4.43",
62
- "@gjsify/web-globals": "^0.4.43",
63
- "@gjsify/web-streams": "^0.4.43"
54
+ "@gjsify/abort-controller": "^0.5.0",
55
+ "@gjsify/assert": "^0.5.0",
56
+ "@gjsify/buffer": "^0.5.0",
57
+ "@gjsify/dom-elements": "^0.5.0",
58
+ "@gjsify/dom-exception": "^0.5.0",
59
+ "@gjsify/node-globals": "^0.5.0",
60
+ "@gjsify/process": "^0.5.0",
61
+ "@gjsify/utils": "^0.5.0",
62
+ "@gjsify/web-globals": "^0.5.0",
63
+ "@gjsify/web-streams": "^0.5.0"
64
64
  }
65
65
  }