@orieljs/testing 0.1.0-alpha.1 → 0.1.0-alpha.10

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/NOTICE CHANGED
@@ -7,3 +7,10 @@ This product includes software developed by the Oriel project
7
7
  Oriel is licensed under the Apache License, Version 2.0 (see LICENSE).
8
8
  The Oriel name and logo are not covered by that license; see TRADEMARKS.md
9
9
  (https://github.com/orieljs/framework/blob/main/TRADEMARKS.md).
10
+
11
+ @orieljs/support (and @orieljs/framework, which bundles it) includes transliteration data from
12
+ voku/portable-ascii (https://github.com/voku/portable-ascii), Copyright (C) 2019 Lars Moelleken, MIT License.
13
+
14
+ @orieljs/notifications (and @orieljs/framework, which bundles it) includes the HTML and CSS of
15
+ Laravel's default notification mail (laravel/framework, https://github.com/laravel/framework),
16
+ Copyright (c) Taylor Otwell, MIT License.
package/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # @orieljs/testing
2
+
3
+ Testing for Oriel: a fresh application for every test, HTTP requests against it, database helpers and fakes, as Laravel's testing helpers. Tests run on Vitest. In an app, import it from `@orieljs/framework/testing`; `@orieljs/testing` is also published on its own.
4
+
5
+ ```bash
6
+ npm install @orieljs/framework
7
+ npm install -D vitest
8
+ ```
9
+
10
+ ```ts title="tests/Feature/Podcast.test.ts"
11
+ // @filename: tests/TestCase.ts
12
+ import { TestCase as BaseTestCase } from '@orieljs/framework/testing'
13
+ import { afterEach, beforeEach } from 'vitest'
14
+ export class TestCase extends BaseTestCase { static override hooks = { beforeEach, afterEach } }
15
+ // ---cut---
16
+ import { Queue } from '@orieljs/framework'
17
+ import { RefreshDatabase } from '@orieljs/framework/testing'
18
+ import { test } from 'vitest'
19
+ import { ProcessPodcast } from '../../app/Jobs/ProcessPodcast'
20
+ import { User } from '../../app/Models/User'
21
+ import { TestCase } from '../TestCase'
22
+
23
+ const t = TestCase.boot({ uses: [RefreshDatabase] })
24
+
25
+ test('creating a podcast queues its processing', async () => {
26
+ const queue = Queue.fake()
27
+ const user = await User.create({ name: 'Ada', email: 'ada@example.com', password: 'secret' })
28
+
29
+ ;(await t.actingAs(user).post('/podcasts', { title: 'Episode 1' })).assertRedirect('/podcasts')
30
+ queue.assertPushed(ProcessPodcast)
31
+ })
32
+ ```
33
+
34
+ An app's tests extend `tests/TestCase.ts`: `TestCase.boot()` gives each test a new application, and `RefreshDatabase` gives it a migrated database and undoes its changes. `t.get()`, `t.post()` and the other request methods resolve to a `TestResponse`, with assertions such as `assertOk()`, `assertRedirect()`, `assertJson()` and `assertInertia()`. Imported from `@orieljs/framework`, `Mail.fake()`, `Queue.fake()`, `Bus.fake()`, `Event.fake()`, `Notification.fake()` and `Storage.fake()` swap the real services for fakes that record what the app does.
35
+
36
+ Documentation: https://orieljs.vercel.app/docs/testing
37
+
38
+ Status: early alpha. APIs will change.
39
+
40
+ ## License
41
+
42
+ Oriel is open-source software licensed under the Apache License 2.0 (Apache-2.0; see `LICENSE` and `NOTICE`). The Oriel name and logo are trademarks; see `TRADEMARKS.md`.
43
+
44
+ Website: https://orieljs.vercel.app
package/TRADEMARKS.md ADDED
@@ -0,0 +1,33 @@
1
+ # Oriel trademark policy
2
+
3
+ The Oriel code is open source under the Apache License 2.0. The **Oriel name and logo** are not: the license covers
4
+ the code only (section 6 of the license says so), and the name and logo stay with the project. This page explains
5
+ what you can and can't do with them. The goal is simple: people should always be able to tell what is the real Oriel
6
+ and what isn't.
7
+
8
+ ## You can, without asking
9
+
10
+ - Use, change, ship and sell the code, as the license allows.
11
+ - Say that your app or package is "built with Oriel", "for Oriel" or "compatible with Oriel".
12
+ - Name a package `oriel-<something>` or `<something>-for-oriel` when it works with Oriel, as long as it is clear that
13
+ it is not official (for example, don't publish it under the `@orieljs` npm scope).
14
+ - Use the name and logo to write about Oriel, teach it, or link to it, in articles, talks, videos and courses.
15
+ - Use the unmodified logo to point to the project, as it is (no recolouring, cropping or
16
+ distortion).
17
+
18
+ ## You can't, without written permission
19
+
20
+ - Call a fork, a modified copy or a competing product "Oriel", or anything likely to be confused with it.
21
+ - Use the name or logo as the name, logo or domain of your own product, company or service.
22
+ - Suggest that the Oriel project made, endorses or supports your work when it doesn't.
23
+ - Sell merchandise with the name or logo.
24
+
25
+ ## Forks
26
+
27
+ Forks are welcome. Please give yours a different name and logo, keep the `LICENSE` and `NOTICE` files, and say that
28
+ it is based on Oriel.
29
+
30
+ ## Questions
31
+
32
+ Open an issue at https://github.com/orieljs/framework or email meeeet.dev@gmail.com. If you're unsure whether a use
33
+ is fine, ask; the answer is usually yes.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,67 @@
1
- import { Application, ModelInstance, Encrypter, Session, View, Authenticatable, Container, AuthFactory, ServiceProvider, ServiceProviderClass, DatabaseManager, Row, ExceptionHandler, ViewFactory, Class, Token, EventDispatcher, Listener, PendingBatchOptions, Job, BusDispatcher, PendingChain, PendingBatch, Batch, QueuePayload, QueueManager, Queue, QueueJob, MailManager, Mailable, Address, MailRecipient, Mailer, PendingMail, SentMessage, MailTransport, Notifiable, NotificationDispatcher, Notification, NotificationChannel, Filesystem, PutOptions, UploadedFile, FilesystemManager } from '@orieljs/contracts';
1
+ import { Application, ModelInstance, InertiaPage, Encrypter, Session, View, Authenticatable, Container, AuthFactory, ServiceProvider, ServiceProviderClass, DatabaseManager, Row, ExceptionHandler, ViewFactory, Class, Token, EventDispatcher, Listener, PendingBatchOptions, Job, BusDispatcher, PendingChain, PendingBatch, Batch, QueuePayload, QueueManager, Queue, QueueJob, MailManager, Mailable, Address, MailRecipient, Mailer, PendingMail, SentMessage, MailTransport, Notifiable, NotificationDispatcher, Notification, NotificationChannel, Filesystem, PutOptions, UploadedFile, FilesystemManager } from '@orieljs/contracts';
2
+
3
+ /** A date the tests travel to: a Date, an ISO string or milliseconds since the epoch. */
4
+ type TravelDate = Date | string | number;
5
+ /**
6
+ * Laravel's travelTo(): the clock stands at `date` (new Date(), Date.now() and now() all read it) until travelBack().
7
+ * With a callback, it runs there and the clock travels back after it; its result is returned.
8
+ */
9
+ declare function travelTo(date: TravelDate): void;
10
+ declare function travelTo<R>(date: TravelDate, callback: (date: Date) => R): R;
11
+ /** Laravel's travelBack(): the real clock again. Returns the real time. */
12
+ declare function travelBack(): Date;
13
+ /** Laravel's freezeTime(): holds the clock where it is now. Returns that time, or the callback's result. */
14
+ declare function freezeTime(): Date;
15
+ declare function freezeTime<R>(callback: (date: Date) => R): R;
16
+ /** Laravel's freezeSecond(): freezeTime() at the start of the current second. */
17
+ declare function freezeSecond(): Date;
18
+ declare function freezeSecond<R>(callback: (date: Date) => R): R;
19
+ /** Laravel's travel(5).minutes(): moves the clock on (a negative value moves it back) from where it stands. */
20
+ declare function travel(value: number): Wormhole;
21
+ /**
22
+ * Laravel's Wormhole: each unit moves the clock by `value` of it (months and years overflow as Carbon's do: 31 January
23
+ * plus a month is 3 March), in UTC. With a callback, it runs there, the clock travels back after it, and its result is
24
+ * returned. JavaScript dates hold milliseconds, so there are no microseconds.
25
+ */
26
+ declare class Wormhole {
27
+ #private;
28
+ readonly value: number;
29
+ constructor(value: number);
30
+ millisecond(): void;
31
+ millisecond<R>(callback: () => R): R;
32
+ milliseconds(): void;
33
+ milliseconds<R>(callback: () => R): R;
34
+ second(): void;
35
+ second<R>(callback: () => R): R;
36
+ seconds(): void;
37
+ seconds<R>(callback: () => R): R;
38
+ minute(): void;
39
+ minute<R>(callback: () => R): R;
40
+ minutes(): void;
41
+ minutes<R>(callback: () => R): R;
42
+ hour(): void;
43
+ hour<R>(callback: () => R): R;
44
+ hours(): void;
45
+ hours<R>(callback: () => R): R;
46
+ day(): void;
47
+ day<R>(callback: () => R): R;
48
+ days(): void;
49
+ days<R>(callback: () => R): R;
50
+ week(): void;
51
+ week<R>(callback: () => R): R;
52
+ weeks(): void;
53
+ weeks<R>(callback: () => R): R;
54
+ month(): void;
55
+ month<R>(callback: () => R): R;
56
+ months(): void;
57
+ months<R>(callback: () => R): R;
58
+ year(): void;
59
+ year<R>(callback: () => R): R;
60
+ years(): void;
61
+ years<R>(callback: () => R): R;
62
+ /** Laravel's Wormhole::back(). */
63
+ static back(): Date;
64
+ }
2
65
 
3
66
  /**
4
67
  * Laravel's PendingCommand: `await t.artisan('inspire').expectsOutput('…').assertExitCode(0)`.
@@ -43,6 +106,90 @@ type JsonStructure = Array<string | {
43
106
  [key: string]: JsonStructure;
44
107
  };
45
108
 
109
+ type Json = unknown;
110
+ type Scope<T extends AssertableJson> = (json: T) => unknown;
111
+ /**
112
+ * Laravel's Illuminate\Testing\Fluent\AssertableJson: fluent, scoped assertions over decoded JSON. Inside a scope
113
+ * (has(key, callback), first(), each()) every property must be interacted with, or etc() must be called.
114
+ */
115
+ declare class AssertableJson {
116
+ protected readonly props: Json;
117
+ protected readonly path: string | undefined;
118
+ protected interactedKeys: string[];
119
+ constructor(props: Json, path?: string | undefined);
120
+ static fromJson(json: Json): AssertableJson;
121
+ /** A child scope of the same class (subclasses override to keep their extra state out of scopes). */
122
+ protected newScope(props: Json, path: string): AssertableJson;
123
+ protected dotPath(key?: string): string;
124
+ /** The value at `key` in this scope, or the whole scope. */
125
+ protected prop(key?: string): Json;
126
+ /** A literal key of this scope wins over a dot path, like Laravel's Arr::get (keys such as 'items.0.name'). */
127
+ private hasOwnKey;
128
+ private exists;
129
+ protected interactsWith(key: string | number): void;
130
+ /** Every property of the scope was checked (called when a scope ends). */
131
+ interacted(): void;
132
+ /** Allow the properties this scope didn't check. */
133
+ etc(): this;
134
+ /** has('key'), has('key', 3), has('key', json => …), has('key', 3, first => …), or has(3) for the root size. */
135
+ has(key: string | number, length?: number | Scope<this>, callback?: Scope<this>): this;
136
+ /** hasAll(['a', 'b']) or hasAll({ items: 3 }). */
137
+ hasAll(keys: string | string[] | Record<string, number>): this;
138
+ hasAny(keys: string | string[]): this;
139
+ missing(key: string): this;
140
+ missingAll(keys: string | string[]): this;
141
+ /** count(3) checks this scope's size; count('items', 3) a property's. */
142
+ count(key: string | number, length?: number): this;
143
+ countBetween(key: string, min: number, max: number): this;
144
+ /** where('name', 'Ann'), or where('name', value => value.startsWith('A')). Objects compare ignoring key order. */
145
+ where(key: string, expected: unknown): this;
146
+ whereNot(key: string, expected: unknown): this;
147
+ whereNull(key: string): this;
148
+ whereNotNull(key: string): this;
149
+ whereAll(bindings: Record<string, unknown>): this;
150
+ /** whereType('id', 'integer'), whereType('name', 'string|null'), whereType('tags', ['array', 'null']). */
151
+ whereType(key: string, expected: string | string[]): this;
152
+ whereAllType(bindings: Record<string, string | string[]>): this;
153
+ /** The list contains every expected value (or one passing the callback); a string contains the substring. */
154
+ whereContains(key: string, expected: unknown): this;
155
+ protected scope(key: string, callback: Scope<this>): this;
156
+ first(callback: Scope<this>): this;
157
+ each(callback: Scope<this>): this;
158
+ when(condition: unknown, callback: (json: this) => unknown, otherwise?: (json: this) => unknown): this;
159
+ dump(key?: string): this;
160
+ toArray(): Json;
161
+ }
162
+
163
+ /** The page object of a response: the JSON body of an Inertia visit, or the page script of a first visit. */
164
+ declare function inertiaPageOf(response: TestResponse): InertiaPage;
165
+ /** Inertia's AssertableInertia: AssertableJson over the page props, plus the page component, url, version and flash. */
166
+ declare class AssertableInertia extends AssertableJson {
167
+ #private;
168
+ static fromTestResponse(response: TestResponse): AssertableInertia;
169
+ /** Scopes are plain AssertableJson: the page-level methods only make sense at the root. */
170
+ protected newScope(props: unknown, path: string): AssertableJson;
171
+ get page(): InertiaPage;
172
+ /** The component name; the page file must exist unless `shouldExist` is false (inertia.testing.ensure_pages_exist). */
173
+ component(value?: string, shouldExist?: boolean): this;
174
+ url(value: string): this;
175
+ version(value: string): this;
176
+ /** The flash data has `key` (dot paths allowed), equal to `expected` when given. */
177
+ hasFlash(key: string, ...expected: [] | [unknown]): this;
178
+ missingFlash(key: string): this;
179
+ static assertFlashHas(flash: Record<string, unknown>, key: string, ...expected: [] | [unknown]): void;
180
+ static assertFlashMissing(flash: Record<string, unknown>, key: string): void;
181
+ /**
182
+ * Requests the page again as a partial reload (only/except) and checks it is the same page. Uses the test's
183
+ * HTTP client, so the session and cookies carry over.
184
+ */
185
+ reload(callback?: (page: AssertableInertia) => unknown, only?: string | string[], except?: string | string[]): Promise<this>;
186
+ reloadOnly(only: string | string[], callback?: (page: AssertableInertia) => unknown): Promise<this>;
187
+ reloadExcept(except: string | string[], callback?: (page: AssertableInertia) => unknown): Promise<this>;
188
+ /** Loads the deferred props of every group (or the given groups) in one partial reload. */
189
+ loadDeferredProps(groupsOrCallback: string | string[] | ((page: AssertableInertia) => unknown), callback?: (page: AssertableInertia) => unknown): Promise<this>;
190
+ toArray(): Record<string, unknown>;
191
+ }
192
+
46
193
  /** Laravel's CookieValuePrefix: hmac_sha1(name + 'v2', key) + '|' (41 characters), as Auth's EncryptCookies writes it. */
47
194
  declare function cookiePrefix(name: string, key: Uint8Array): string;
48
195
  /** What EncryptCookies puts in a browser cookie: encrypt(prefix + value, serialize: false). */
@@ -83,6 +230,8 @@ interface ResponseContext {
83
230
  views?: View[];
84
231
  /** The last error the exception handler rendered. */
85
232
  exception?: unknown;
233
+ /** The client that sent the request (Inertia reloads reuse it, keeping the session and cookies). */
234
+ client?: HttpClient;
86
235
  }
87
236
  /** Laravel's TestResponse: a Response with its body already read, plus fluent assertions. */
88
237
  declare class TestResponse {
@@ -146,8 +295,24 @@ declare class TestResponse {
146
295
  assertSeeText(value: string | string[], escape?: boolean): this;
147
296
  assertDontSeeText(value: string | string[], escape?: boolean): this;
148
297
  assertSeeTextInOrder(values: string[], escape?: boolean): this;
149
- /** The response JSON contains `data` (a subset match: extra keys in the response are fine). */
150
- assertJson(data: Record<string, unknown> | unknown[]): this;
298
+ /**
299
+ * The response JSON contains `data` (a subset match: extra keys in the response are fine), or fluent
300
+ * assertions: assertJson(json => json.has('data', 3).etc()).
301
+ */
302
+ assertJson(data: Record<string, unknown> | unknown[] | ((json: AssertableJson) => unknown)): this;
303
+ /**
304
+ * An Inertia page response, with optional fluent assertions over its props. An async callback (reload(),
305
+ * loadDeferredProps()) makes this return a promise: await it.
306
+ */
307
+ assertInertia(callback: (page: AssertableInertia) => Promise<unknown>): Promise<this>;
308
+ assertInertia(callback?: (page: AssertableInertia) => unknown): this;
309
+ /** The Inertia page object of this response. */
310
+ inertiaPage(): InertiaPage;
311
+ /** The page props, or one prop by dot path. */
312
+ inertiaProps<T = unknown>(key?: string): T;
313
+ /** Inertia flash data waiting in the session for the next page (after a redirect). */
314
+ assertInertiaFlash(key: string, ...expected: [] | [unknown]): this;
315
+ assertInertiaFlashMissing(key: string): this;
151
316
  /** The response JSON equals `data` exactly (object key order is ignored). */
152
317
  assertExactJson(data: unknown): this;
153
318
  /** The value at `path` equals `expected` (strictly), or passes the predicate. */
@@ -252,6 +417,11 @@ declare class HttpClient {
252
417
  defaultGuard: string | undefined;
253
418
  /** Session attributes carried from one request to the next (Laravel keeps one session store per test). */
254
419
  session: Record<string, unknown> | undefined;
420
+ /**
421
+ * withSession() and flushSession() since the last started session: applied to the stored session (the one the
422
+ * session cookie points to) once the next request starts it, so they win over what it holds, as in Laravel.
423
+ */
424
+ sessionChanges: Array<(session: Session) => void>;
255
425
  /** from(url): the session's previous URL for the next request only (Laravel sets it once). */
256
426
  previousUrl: string | undefined;
257
427
  /** Requests whose actingAs users reached the guards (the AuthFactory they went through). */
@@ -260,6 +430,12 @@ declare class HttpClient {
260
430
  request(method: string, uri: string, options?: RequestOptions): Promise<TestResponse>;
261
431
  /** Runs `fn` in a scope prepared like a request's (carried session, actingAs users), e.g. for assertAuthenticated(). */
262
432
  inScope<T>(fn: (scope: Container) => T | Promise<T>): Promise<T>;
433
+ /**
434
+ * Runs `run` in a request scope like this client's requests have (a request for `method uri` bound, the carried
435
+ * session, actingAs users), then carries the session and the users on, as after a request. Live.test() runs its
436
+ * mount and updates through it.
437
+ */
438
+ withinRequest<T>(run: () => Promise<T>, method?: string, uri?: string): Promise<T>;
263
439
  /** Runs the request through the app's real HttpKernel, in a request scope this client owns. */
264
440
  protected send(request: Request): Promise<TestResponse>;
265
441
  /** Prepares the request scope: recorders, the carried session and actingAs users. */
@@ -271,6 +447,10 @@ declare class HttpClient {
271
447
  * request sticks. Reads each actingAs guard back and forgets or replaces its user to match.
272
448
  */
273
449
  protected syncActingAs(auth: AuthFactory): Promise<void>;
450
+ /** Applies the pending withSession()/flushSession() changes once the session has loaded what it stored. */
451
+ protected applyOnStart(session: Session): void;
452
+ /** Applies the pending withSession()/flushSession() changes to the session, once. */
453
+ protected applyPending(session: Session): void;
274
454
  /** The request's (scoped) Session, created now so the carried attributes are in place before StartSession. */
275
455
  protected scopeSession(scope: Container): Session | undefined;
276
456
  buildRequest(method: string, uri: string, options: RequestOptions): Request;
@@ -333,6 +513,11 @@ declare abstract class InteractsWithApplication {
333
513
  protected defineEnvironment(_app: Application): void | Promise<void>;
334
514
  setUp(): Promise<void>;
335
515
  tearDown(): Promise<void>;
516
+ /**
517
+ * Laravel's withoutVite(): in this test's requests vite([...]) and viteReactRefresh() render nothing, so feature
518
+ * tests of pages pass before `vite build` has written public/build/manifest.json.
519
+ */
520
+ withoutVite(): this;
336
521
  /** Runs in tearDown(), before the application is thrown away (in registration order). */
337
522
  beforeApplicationDestroyed(callback: Callback): void;
338
523
  }
@@ -344,6 +529,8 @@ declare abstract class MakesHttpRequests extends InteractsWithApplication {
344
529
  /** The current test's HTTP client (created on first use). */
345
530
  protected get http(): HttpClient;
346
531
  protected createHttpClient(): HttpClient;
532
+ /** Live.test() runs in this test's request scope (Live reads the same token: no import between the packages). */
533
+ setUp(): Promise<void>;
347
534
  tearDown(): Promise<void>;
348
535
  withHeaders(headers: Headers$1): this;
349
536
  withHeader(name: string, value: string): this;
@@ -360,9 +547,9 @@ declare abstract class MakesHttpRequests extends InteractsWithApplication {
360
547
  followingRedirects(): this;
361
548
  /** Sets the Referer and the session's previous URL, so redirect()->back() goes there. */
362
549
  from(url: string): this;
363
- /** Puts data in the session for the following requests (Laravel's withSession()). */
550
+ /** Puts data in the session for the following requests, over what the stored session holds (Laravel's withSession()). */
364
551
  withSession(data: Record<string, unknown>): this;
365
- /** Empties the session carried between requests. */
552
+ /** Empties the session, the stored one included, so the next request starts with none (Laravel's flushSession()). */
366
553
  flushSession(): this;
367
554
  /** Every following request is authenticated as `user` on `guard` (which also becomes the default guard). */
368
555
  actingAs(user: Authenticatable, guard?: string): this;
@@ -421,11 +608,28 @@ declare abstract class InteractsWithConsole extends InteractsWithDatabase {
421
608
  artisan(command: string, parameters?: Record<string, unknown>): PendingCommand;
422
609
  }
423
610
 
611
+ /**
612
+ * Laravel's InteractsWithTime: `t.travelTo(date)`, `t.travel(5).minutes()`, `t.freezeTime()`, `t.travelBack()`.
613
+ * The functions of the same names do the same outside a test case. A test case's tearDown travels back, so each of its
614
+ * tests ends in the real time; with the plain functions, call `travelBack()` in your own `afterEach()` or pass a callback.
615
+ */
616
+ declare abstract class InteractsWithTime extends InteractsWithConsole {
617
+ travelTo(date: TravelDate): void;
618
+ travelTo<R>(date: TravelDate, callback: (date: Date) => R): R;
619
+ travel(value: number): Wormhole;
620
+ travelBack(): Date;
621
+ freezeTime(): Date;
622
+ freezeTime<R>(callback: (date: Date) => R): R;
623
+ freezeSecond(): Date;
624
+ freezeSecond<R>(callback: (date: Date) => R): R;
625
+ tearDown(): Promise<void>;
626
+ }
627
+
424
628
  /**
425
629
  * Laravel's TestCase. Extend it in tests/TestCase.ts (override createApplication() and set `static hooks`),
426
630
  * then in each file: `const t = TestCase.boot()`, or `TestCase.boot({ uses: [RefreshDatabase] })`.
427
631
  */
428
- declare abstract class TestCase extends InteractsWithConsole {
632
+ declare abstract class TestCase extends InteractsWithTime {
429
633
  }
430
634
 
431
635
  /**
@@ -490,11 +694,11 @@ declare function install<T extends object, F extends T>(token: Token<T>, fake: F
490
694
  declare function nameOf(target: Target | object): string;
491
695
  /** A recorded object (or string event) matches a target: same constructor, or the same (class) name. */
492
696
  declare function matches(item: unknown, target: Target): boolean;
493
- /** Bus's ShouldQueue marker (the Queueable base class sets it on its prototype); the same Symbol.for key as 06. */
697
+ /** Bus's ShouldQueue marker (the Queueable base class sets it on its prototype); the same Symbol.for key as Bus's. */
494
698
  declare const SHOULD_QUEUE: unique symbol;
495
699
  /**
496
- * A verbatim copy of Bus's isQueueable() (06-queue-bus.md; Testing can't import Bus). The rule is read on the
497
- * instance: the ShouldQueue marker, a value for any ShouldQueue option, or uniqueId()/retryUntil().
700
+ * A copy of Bus's isQueueable(), read on the instance: ShouldQueue's `shouldQueue: true` (own field or prototype),
701
+ * the SHOULD_QUEUE symbol, a value for any ShouldQueue option, or uniqueId()/retryUntil().
498
702
  */
499
703
  declare function isQueueable(job: unknown): boolean;
500
704
 
@@ -504,6 +708,8 @@ interface DispatchedEvent {
504
708
  payload: unknown[];
505
709
  }
506
710
  type EventFilter<E> = (event: E, payload: unknown[]) => boolean;
711
+ /** A listener as assertListening() expects it: a class, a [class, method] pair, a closure, or Function for any closure. */
712
+ type ExpectedListener = Listener<never> | readonly [Class<object>, string] | FunctionConstructor;
507
713
  /**
508
714
  * Laravel's Event::fake(): records dispatched events instead of running listeners. With a list, only those
509
715
  * events are faked and everything else reaches the original dispatcher (so model events keep working).
@@ -534,11 +740,17 @@ declare class EventFake implements EventDispatcher {
534
740
  assertDispatchedTimes<E>(event: Class<E> | string, times?: number): void;
535
741
  assertNotDispatched<E>(event: Class<E> | string, callback?: EventFilter<E>): void;
536
742
  assertNothingDispatched(): void;
537
- /** The original dispatcher has a listener for the event. */
538
- assertListening(event: Class<unknown> | string): void;
743
+ /**
744
+ * Laravel's assertListening(event, listener): the original dispatcher has that listener for the event (a class, a
745
+ * [class, method] pair, the same closure, or Function for any closure; wildcard listeners count for a string event).
746
+ * With only the event, any listener will do.
747
+ */
748
+ assertListening(event: Class<unknown> | string, listener?: ExpectedListener): void;
539
749
  /** The recorded events (objects, or names for string events) that match. */
540
750
  dispatched<E>(event: Class<E> | string, callback?: EventFilter<E>): E[];
541
751
  hasDispatched(event: Class<unknown> | string): boolean;
752
+ /** The original dispatcher's listeners for the event, as registered, wildcard ones included for a string event. */
753
+ private listenersFor;
542
754
  private shouldFake;
543
755
  }
544
756
 
@@ -692,6 +904,8 @@ declare class MailFake implements MailManager {
692
904
  mailer(name?: string): Mailer;
693
905
  to(recipients: MailRecipient | MailRecipient[]): PendingMail;
694
906
  send(mailable: Mailable): Promise<SentMessage | undefined>;
907
+ /** Recorded as sent, never queued, like the real sendNow(). */
908
+ sendNow(mailable: Mailable): Promise<SentMessage | undefined>;
695
909
  queue(mailable: Mailable): Promise<void>;
696
910
  extend(_transport: string, _factory: (config: Record<string, unknown>) => MailTransport): void;
697
911
  /** Sent (not queued) at least once; a number asserts the count; a filter gets (mailable, record). */
@@ -713,6 +927,7 @@ declare class MailFake implements MailManager {
713
927
  hasQueued(mailable: Target<Mailable>): boolean;
714
928
  private pending;
715
929
  private sendVia;
930
+ private sendNowVia;
716
931
  private queueVia;
717
932
  private record;
718
933
  private matching;
@@ -772,6 +987,7 @@ interface StoredFile {
772
987
  mimeType: string | undefined;
773
988
  modified: Date;
774
989
  }
990
+ /** By the extension as PHP's pathinfo() reads it: after the last dot of the base name ('.pdf' is a PDF, 'pdf' isn't). */
775
991
  declare function guessMimeType(path: string): string | undefined;
776
992
  /**
777
993
  * An in-memory disk implementing the Filesystem contract, with Laravel's fake-disk assertions. (Laravel's fake
@@ -792,7 +1008,12 @@ declare class FakeDisk implements Filesystem {
792
1008
  readStream(path: string): Promise<ReadableStream<Uint8Array>>;
793
1009
  put(path: string, contents: string | Uint8Array | ReadableStream<Uint8Array>, options?: PutOptions): Promise<boolean>;
794
1010
  putFile(directory: string, file: UploadedFile, options?: PutOptions): Promise<string>;
1011
+ /**
1012
+ * The upload's own type, as the S3 disk sends it: its extension(), never the MIME type the client sent as such nor
1013
+ * the stored name's type.
1014
+ */
795
1015
  putFileAs(directory: string, file: UploadedFile, name: string, options?: PutOptions): Promise<string>;
1016
+ private write;
796
1017
  delete(paths: string | string[]): Promise<boolean>;
797
1018
  copy(from: string, to: string): Promise<boolean>;
798
1019
  move(from: string, to: string): Promise<boolean>;
@@ -852,10 +1073,18 @@ declare class StorageFake implements FilesystemManager {
852
1073
 
853
1074
  /** Laravel's UploadedFile::fake(): File objects to post as multipart uploads (t.post(uri, { avatar: file })). */
854
1075
  declare const FakeFile: {
855
- /** A file of `kilobytes` KiB (zero bytes), typed by `mimeType` or the extension. */
1076
+ /**
1077
+ * A file of `kilobytes` KiB typed by `mimeType` or the name's extension. Validation reads a file's bytes, so the
1078
+ * file starts like its type (a PDF's `%PDF-`, a PNG's signature, text for text types) and passes `mimes` for its
1079
+ * name, as Laravel's fakes do. It is at least its type's leading bytes and never empty, whatever the size asked for.
1080
+ * An image made this way has no readable size: use image() for `dimensions`.
1081
+ */
856
1082
  create(name: string, kilobytes?: number, mimeType?: string): File;
857
- /** A real PNG image of the given size (typed by the name's extension, like Laravel's image()). */
1083
+ /**
1084
+ * A real white image of the given size in the format the name's extension asks for: png, jpg/jpeg, gif, webp or
1085
+ * bmp (any other name gets a JPEG, as Laravel's fakes do), so image, mimes and dimensions pass on it.
1086
+ */
858
1087
  image(name: string, width?: number, height?: number): File;
859
1088
  };
860
1089
 
861
- export { AnonymousNotifiable, type BatchRecord, type BootOptions, BusFake, type CountOrFilter, DatabaseMigrations, type DatabaseTestOptions, DatabaseTransactions, type DispatchedEvent, EventFake, type ExpectedErrors, FakeDisk, FakeFile, HttpClient, InteractsWithApplication, InteractsWithConsole, InteractsWithDatabase, type JsonStructure, MailFake, MailRecord, MakesHttpRequests, NotificationFake, PendingCommand, type PushedJob, QueueFake, RefreshDatabase, RefreshDatabaseState, type RequestData, type RequestOptions, type ResponseContext, type ResponseCookie, SHOULD_QUEUE, type SentNotification, StorageFake, TESTING_ENVIRONMENT, type TableOrModel, type Target, TestCase, type TestHooks, TestResponse, type TestTrait, actingAsAuthFactory, addresses, applyEnvironment, cookieHeader, cookiePrefix, decryptCookie, encryptCookie, flatten, guessMimeType, install, isExpired, isQueueable, matches, nameOf, parseSetCookie, recordingExceptionHandler, recordingViewFactory, responseCookies, runCommand, usingInMemoryDatabase };
1090
+ export { AnonymousNotifiable, AssertableInertia, AssertableJson, type BatchRecord, type BootOptions, BusFake, type CountOrFilter, DatabaseMigrations, type DatabaseTestOptions, DatabaseTransactions, type DispatchedEvent, EventFake, type ExpectedErrors, type ExpectedListener, FakeDisk, FakeFile, HttpClient, InteractsWithApplication, InteractsWithConsole, InteractsWithDatabase, InteractsWithTime, type JsonStructure, MailFake, MailRecord, MakesHttpRequests, NotificationFake, PendingCommand, type PushedJob, QueueFake, RefreshDatabase, RefreshDatabaseState, type RequestData, type RequestOptions, type ResponseContext, type ResponseCookie, SHOULD_QUEUE, type SentNotification, StorageFake, TESTING_ENVIRONMENT, type TableOrModel, type Target, TestCase, type TestHooks, TestResponse, type TestTrait, type TravelDate, Wormhole, actingAsAuthFactory, addresses, applyEnvironment, cookieHeader, cookiePrefix, decryptCookie, encryptCookie, flatten, freezeSecond, freezeTime, guessMimeType, inertiaPageOf, install, isExpired, isQueueable, matches, nameOf, parseSetCookie, recordingExceptionHandler, recordingViewFactory, responseCookies, runCommand, travel, travelBack, travelTo, usingInMemoryDatabase };