@stacksjs/testing 0.74.19 → 0.74.21
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/dist/index.js +1 -1
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
|
|
2
|
+
import p from"process";function R(){p.env.NODE_ENV="test",p.env.APP_ENV="test"}async function h(){let o=await import("@stacksjs/router");return o.serverResponse}function T(o){let a={status:o.status,headers:o.headers,text:()=>o.text(),json:async()=>await o.clone().json(),assertStatus(s){if(this.status!==s)throw Error(`Expected status ${s}, got ${this.status}`);return a},async assertJson(s){let n=await o.clone().json();for(let[i,u]of Object.entries(s))if(JSON.stringify(n[i])!==JSON.stringify(u))throw Error(`assertJson: expected ${i}=${JSON.stringify(u)}, got ${JSON.stringify(n[i])}`);return a},assertHeader(s,n){let i=o.headers.get(s);if(i===null)throw Error(`assertHeader: missing header '${s}'`);if(n!==void 0){if(!(typeof n==="string"?i===n:n.test(i)))throw Error(`assertHeader: expected ${s}=${String(n)}, got '${i}'`)}return a}};return a}function k(o="http://localhost"){let a=null,s={},n=null;async function i(){if(!a)return null;if(n)return n;let{Auth:t}=await import("@stacksjs/auth"),e=Number(a.id);if(!Number.isFinite(e))throw TypeError(`actingAs() needs a user with a numeric id; got ${JSON.stringify(a.id)}`);let r=await t.loginUsingId(e);if(!r)throw Error(`actingAs() could not authenticate user ${e}: no such user. Create the row first (e.g. via a factory) so a token can be issued against it.`);return n=String(r.token),n}async function u(t){let e={Accept:"application/json",...s};if(t!==void 0)e["Content-Type"]="application/json";let r=await i();if(r&&!e.Authorization&&!e.authorization)e.Authorization=`Bearer ${r}`;return e}async function c(t,e,r){let d=await h(),l=e.startsWith("http")?e:`${o}${e}`,f={method:t,headers:await u(r),body:r===void 0?void 0:typeof r==="string"?r:JSON.stringify(r)},w=await d(new Request(l,f));return T(w)}let g={actingAs(t){return a=t,n=null,g},withHeaders(t){return s={...s,...t},g},get:(t)=>c("GET",t),post:(t,e)=>c("POST",t,e),put:(t,e)=>c("PUT",t,e),patch:(t,e)=>c("PATCH",t,e),delete:(t,e)=>c("DELETE",t,e)};return g}export*from"bun:test";export{k as featureTest,R as setupTestEnvironment};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@stacksjs/testing",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "0.74.
|
|
5
|
+
"version": "0.74.21",
|
|
6
6
|
"description": "The Stacks way of testing.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"contributors": [
|
|
@@ -74,13 +74,13 @@
|
|
|
74
74
|
"prepublishOnly": "bun run build"
|
|
75
75
|
},
|
|
76
76
|
"dependencies": {
|
|
77
|
-
"@stacksjs/auth": "0.74.
|
|
78
|
-
"@stacksjs/cache": "0.74.
|
|
79
|
-
"@stacksjs/config": "0.74.
|
|
80
|
-
"@stacksjs/database": "0.74.
|
|
81
|
-
"@stacksjs/path": "0.74.
|
|
82
|
-
"@stacksjs/router": "0.74.
|
|
83
|
-
"@stacksjs/storage": "0.74.
|
|
77
|
+
"@stacksjs/auth": "0.74.21",
|
|
78
|
+
"@stacksjs/cache": "0.74.21",
|
|
79
|
+
"@stacksjs/config": "0.74.21",
|
|
80
|
+
"@stacksjs/database": "0.74.21",
|
|
81
|
+
"@stacksjs/path": "0.74.21",
|
|
82
|
+
"@stacksjs/router": "0.74.21",
|
|
83
|
+
"@stacksjs/storage": "0.74.21",
|
|
84
84
|
"@stacksjs/ts-cloud": "^0.12.10"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|