Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit fe6b969

Browse files
committedJan 28, 2025··
fix: breaking tests
1 parent 017a187 commit fe6b969

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed
 

‎src/plugins/japa/api_client.ts

+12-4
Original file line numberDiff line numberDiff line change
@@ -119,19 +119,27 @@ export function inertiaApiClient(app: ApplicationService): PluginFn {
119119
ApiResponse.macro(
120120
'assertInertiaProps',
121121
function (this: ApiResponse, props: Record<string, unknown>) {
122-
this.ensureHasAssert()
122+
if (!this.assert) {
123+
throw new Error(
124+
'Response assertions are not available. Make sure to install the @japa/assert plugin'
125+
)
126+
}
123127
ensureIsInertiaResponse.call(this)
124-
this.assert!.deepEqual(this.body().props, props)
128+
this.assert.deepEqual(this.body().props, props)
125129
return this
126130
}
127131
)
128132

129133
ApiResponse.macro(
130134
'assertInertiaPropsContains',
131135
function (this: ApiResponse, props: Record<string, unknown>) {
132-
this.ensureHasAssert()
136+
if (!this.assert) {
137+
throw new Error(
138+
'Response assertions are not available. Make sure to install the @japa/assert plugin'
139+
)
140+
}
133141
ensureIsInertiaResponse.call(this)
134-
this.assert!.containsSubset(this.body().props, props)
142+
this.assert.containsSubset(this.body().props, props)
135143
return this
136144
}
137145
)

‎tests_helpers/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { InlineConfig } from 'vite'
2+
import { assert } from '@japa/assert'
23
import { Vite } from '@adonisjs/vite'
34
import { getActiveTest } from '@japa/runner'
45
import type { Test } from '@japa/runner/core'
@@ -57,7 +58,7 @@ export async function runJapaTest(app: ApplicationService, callback: Parameters<
5758
activated: [syncReporter.name],
5859
list: [syncReporter as NamedReporterContract],
5960
},
60-
plugins: [apiClient(), pluginAdonisJS(app), inertiaApiClient(app)],
61+
plugins: [assert(), apiClient(), pluginAdonisJS(app), inertiaApiClient(app)],
6162
files: [],
6263
})
6364
.runTest('testing japa integration', callback)

0 commit comments

Comments
 (0)
Please sign in to comment.